Route CodecSpecificInfo from encoder to packetizer
Making a long chain of interface changes to route a CodecSpecificInfo struct from the video encoder function to the RTPSenderVideo. This will be used to convey information needed by the RTP packetizer when building the RTP headers. Review URL: http://webrtc-codereview.appspot.com/56001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@140 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -47,7 +47,10 @@ public:
|
||||
//
|
||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK
|
||||
// <0 - Error
|
||||
virtual WebRtc_Word32 Encode(const RawImage& inputImage, const void* /*codecSpecificInfo*/, VideoFrameType /*frameType*/);
|
||||
virtual WebRtc_Word32
|
||||
Encode(const RawImage& inputImage,
|
||||
const CodecSpecificInfo* /*codecSpecificInfo*/,
|
||||
VideoFrameType /*frameType*/);
|
||||
|
||||
// Register an encode complete callback object.
|
||||
//
|
||||
|
@@ -117,7 +117,9 @@ I420Encoder::InitEncode(const VideoCodec* codecSettings,
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
I420Encoder::Encode(const RawImage& inputImage, const void* /*codecSpecificInfo*/, VideoFrameType /*frameTypes*/)
|
||||
I420Encoder::Encode(const RawImage& inputImage,
|
||||
const CodecSpecificInfo* /*codecSpecificInfo*/,
|
||||
VideoFrameType /*frameTypes*/)
|
||||
{
|
||||
if (!_inited)
|
||||
{
|
||||
|
@@ -54,9 +54,10 @@ public:
|
||||
// should be dropped to keep bit rate or frame rate.
|
||||
// = 0, if OK.
|
||||
// < 0, on error.
|
||||
virtual WebRtc_Word32 Encoded(EncodedImage& encodedImage,
|
||||
const void* codecSpecificInfo = NULL,
|
||||
const RTPFragmentationHeader* fragmentation = NULL) = 0;
|
||||
virtual WebRtc_Word32
|
||||
Encoded(EncodedImage& encodedImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo = NULL,
|
||||
const RTPFragmentationHeader* fragmentation = NULL) = 0;
|
||||
};
|
||||
|
||||
class VideoEncoder
|
||||
@@ -96,9 +97,10 @@ public:
|
||||
// - frameType : The frame type to encode
|
||||
//
|
||||
// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
|
||||
virtual WebRtc_Word32 Encode(const RawImage& inputImage,
|
||||
const void* codecSpecificInfo = NULL,
|
||||
VideoFrameType frameType = kDeltaFrame) = 0;
|
||||
virtual WebRtc_Word32
|
||||
Encode(const RawImage& inputImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo = NULL,
|
||||
VideoFrameType frameType = kDeltaFrame) = 0;
|
||||
|
||||
// Register an encode complete callback object.
|
||||
//
|
||||
|
@@ -87,7 +87,7 @@ public:
|
||||
// WEBRTC_VIDEO_CODEC_TIMEOUT
|
||||
|
||||
virtual WebRtc_Word32 Encode(const RawImage& inputImage,
|
||||
const void* codecSpecificInfo,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
VideoFrameType frameType);
|
||||
|
||||
// Register an encode complete callback object.
|
||||
|
@@ -376,7 +376,7 @@ VP8Encoder::MaxIntraTarget(WebRtc_Word32 optimalBuffersize)
|
||||
|
||||
WebRtc_Word32
|
||||
VP8Encoder::Encode(const RawImage& inputImage,
|
||||
const void* codecSpecificInfo,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
VideoFrameType frameTypes)
|
||||
{
|
||||
if (!_inited)
|
||||
|
@@ -20,6 +20,7 @@ namespace webrtc
|
||||
|
||||
class VideoEncoder;
|
||||
class VideoDecoder;
|
||||
struct CodecSpecificInfo;
|
||||
|
||||
class VideoCodingModule : public Module
|
||||
{
|
||||
@@ -234,9 +235,10 @@ public:
|
||||
//
|
||||
// Return value : VCM_OK, on success.
|
||||
// < 0, on error.
|
||||
virtual WebRtc_Word32 AddVideoFrame(const VideoFrame& videoFrame,
|
||||
const VideoContentMetrics* _contentMetrics = NULL,
|
||||
const void* codecSpecificInfo = NULL) = 0;
|
||||
virtual WebRtc_Word32 AddVideoFrame(
|
||||
const VideoFrame& videoFrame,
|
||||
const VideoContentMetrics* _contentMetrics = NULL,
|
||||
const CodecSpecificInfo* codecSpecificInfo = NULL) = 0;
|
||||
|
||||
// Next frame encoded should be of the type frameType.
|
||||
//
|
||||
|
@@ -82,12 +82,14 @@ struct VCMFrameCount
|
||||
class VCMPacketizationCallback
|
||||
{
|
||||
public:
|
||||
virtual WebRtc_Word32 SendData(const FrameType frameType,
|
||||
const WebRtc_UWord8 payloadType,
|
||||
const WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_UWord8* payloadData,
|
||||
const WebRtc_UWord32 payloadSize,
|
||||
const RTPFragmentationHeader& fragmentationHeader) = 0;
|
||||
virtual WebRtc_Word32 SendData(
|
||||
const FrameType frameType,
|
||||
const WebRtc_UWord8 payloadType,
|
||||
const WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_UWord8* payloadData,
|
||||
const WebRtc_UWord32 payloadSize,
|
||||
const RTPFragmentationHeader& fragmentationHeader,
|
||||
const RTPVideoTypeHeader* rtpTypeHdr) = 0;
|
||||
protected:
|
||||
virtual ~VCMPacketizationCallback() {}
|
||||
};
|
||||
|
@@ -64,7 +64,9 @@ VCMGenericEncoder::InitEncode(const VideoCodec* settings, WebRtc_Word32 numberOf
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
VCMGenericEncoder::Encode(const VideoFrame& inputFrame, const void* codecSpecificInfo, FrameType frameType)
|
||||
VCMGenericEncoder::Encode(const VideoFrame& inputFrame,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
FrameType frameType)
|
||||
{
|
||||
RawImage rawImage(inputFrame.Buffer(), inputFrame.Length(), inputFrame.Size());
|
||||
rawImage._width = inputFrame.Width();
|
||||
@@ -174,8 +176,10 @@ VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
VCMEncodedFrameCallback::Encoded(EncodedImage &encodedImage, const void* codecSpecificInfo,
|
||||
const RTPFragmentationHeader* fragmentationHeader)
|
||||
VCMEncodedFrameCallback::Encoded(
|
||||
EncodedImage &encodedImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
const RTPFragmentationHeader* fragmentationHeader)
|
||||
{
|
||||
FrameType frameType = VCMEncodedFrame::ConvertFrameType(encodedImage._frameType);
|
||||
|
||||
@@ -189,12 +193,25 @@ VCMEncodedFrameCallback::Encoded(EncodedImage &encodedImage, const void* codecSp
|
||||
fwrite(encodedImage._buffer, 1, encodedImage._length, _bitStreamAfterEncoder);
|
||||
}
|
||||
|
||||
WebRtc_Word32 callbackReturn = _sendCallback->SendData(frameType,
|
||||
_payloadType,
|
||||
encodedImage._timeStamp,
|
||||
encodedImage._buffer,
|
||||
encodedBytes,
|
||||
*fragmentationHeader);
|
||||
RTPVideoTypeHeader rtpTypeHeader;
|
||||
RTPVideoTypeHeader* rtpTypeHeaderPtr = &rtpTypeHeader;
|
||||
if (codecSpecificInfo)
|
||||
{
|
||||
CopyCodecSpecific(*codecSpecificInfo, &rtpTypeHeaderPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
rtpTypeHeaderPtr = NULL;
|
||||
}
|
||||
|
||||
WebRtc_Word32 callbackReturn = _sendCallback->SendData(
|
||||
frameType,
|
||||
_payloadType,
|
||||
encodedImage._timeStamp,
|
||||
encodedImage._buffer,
|
||||
encodedBytes,
|
||||
*fragmentationHeader,
|
||||
rtpTypeHeaderPtr);
|
||||
if (callbackReturn < 0)
|
||||
{
|
||||
return callbackReturn;
|
||||
@@ -226,4 +243,18 @@ VCMEncodedFrameCallback::SetMediaOpt(VCMMediaOptimization *mediaOpt)
|
||||
_mediaOpt = mediaOpt;
|
||||
}
|
||||
|
||||
void VCMEncodedFrameCallback::CopyCodecSpecific(const CodecSpecificInfo& info,
|
||||
RTPVideoTypeHeader** rtp) {
|
||||
switch (info.codecType)
|
||||
{
|
||||
//TODO(hlundin): Implement case for kVideoCodecVP8.
|
||||
default: {
|
||||
// No codec specific info. Change RTP header pointer to NULL.
|
||||
*rtp = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@@ -32,8 +32,10 @@ public:
|
||||
/*
|
||||
* Callback implementation - codec encode complete
|
||||
*/
|
||||
WebRtc_Word32 Encoded(EncodedImage& encodedImage, const void* codecSpecificInfo = NULL,
|
||||
const RTPFragmentationHeader* fragmentationHeader = NULL);
|
||||
WebRtc_Word32 Encoded(
|
||||
EncodedImage& encodedImage,
|
||||
const CodecSpecificInfo* codecSpecificInfo = NULL,
|
||||
const RTPFragmentationHeader* fragmentationHeader = NULL);
|
||||
/*
|
||||
* Get number of encoded bytes
|
||||
*/
|
||||
@@ -52,14 +54,20 @@ public:
|
||||
void SetInternalSource(bool internalSource) { _internalSource = internalSource; };
|
||||
|
||||
private:
|
||||
VCMPacketizationCallback* _sendCallback;
|
||||
VCMMediaOptimization* _mediaOpt;
|
||||
WebRtc_UWord32 _encodedBytes;
|
||||
WebRtc_UWord8 _payloadType;
|
||||
VideoCodecType _codecType;
|
||||
bool _internalSource;
|
||||
FILE* _bitStreamAfterEncoder;
|
||||
/*
|
||||
* Map information from info into rtp. If no relevant information is found
|
||||
* in info, rtp is set to NULL.
|
||||
*/
|
||||
static void CopyCodecSpecific(const CodecSpecificInfo& info,
|
||||
RTPVideoTypeHeader** rtp);
|
||||
|
||||
VCMPacketizationCallback* _sendCallback;
|
||||
VCMMediaOptimization* _mediaOpt;
|
||||
WebRtc_UWord32 _encodedBytes;
|
||||
WebRtc_UWord8 _payloadType;
|
||||
VideoCodecType _codecType;
|
||||
bool _internalSource;
|
||||
FILE* _bitStreamAfterEncoder;
|
||||
};// end of VCMEncodeFrameCallback class
|
||||
|
||||
|
||||
@@ -94,7 +102,7 @@ public:
|
||||
* frameType : The requested frame type to encode
|
||||
*/
|
||||
WebRtc_Word32 Encode(const VideoFrame& inputFrame,
|
||||
const void* codecSpecificInfo,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
FrameType frameType);
|
||||
/**
|
||||
* Set new target bit rate and frame rate
|
||||
|
@@ -708,7 +708,7 @@ VideoCodingModuleImpl::SetVideoProtection(VCMVideoProtection videoProtection, bo
|
||||
WebRtc_Word32
|
||||
VideoCodingModuleImpl::AddVideoFrame(const VideoFrame& videoFrame,
|
||||
const VideoContentMetrics* _contentMetrics,
|
||||
const void* codecSpecificInfo)
|
||||
const CodecSpecificInfo* codecSpecificInfo)
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceVideoCoding, VCMId(_id), "AddVideoFrame()");
|
||||
CriticalSectionScoped cs(_sendCritSect);
|
||||
|
@@ -132,9 +132,10 @@ public:
|
||||
virtual WebRtc_Word32 SetVideoProtection(VCMVideoProtection videoProtection, bool enable);
|
||||
|
||||
// Add one raw video frame to the encoder, blocking.
|
||||
virtual WebRtc_Word32 AddVideoFrame(const VideoFrame& videoFrame,
|
||||
const VideoContentMetrics* _contentMetrics = NULL,
|
||||
const void* codecSpecificInfo = NULL);
|
||||
virtual WebRtc_Word32 AddVideoFrame(
|
||||
const VideoFrame& videoFrame,
|
||||
const VideoContentMetrics* _contentMetrics = NULL,
|
||||
const CodecSpecificInfo* codecSpecificInfo = NULL);
|
||||
|
||||
// Next frame encoded should be of the type frameType.
|
||||
virtual WebRtc_Word32 FrameTypeRequest(FrameType frameType);
|
||||
|
Reference in New Issue
Block a user