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:
hlundin@google.com 2011-07-01 08:32:57 +00:00
parent b5427cbd35
commit 6b04739e04
24 changed files with 173 additions and 93 deletions

View File

@ -541,12 +541,14 @@ public:
*
* return -1 on failure else 0
*/
virtual WebRtc_Word32 SendOutgoingData(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation = NULL) = 0;
virtual WebRtc_Word32
SendOutgoingData(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation = NULL,
const RTPVideoTypeHeader* rtpTypeHdr = NULL) = 0;
/**************************************************************************
*

View File

@ -1076,7 +1076,8 @@ ModuleRtpRtcpImpl::SendOutgoingData(const FrameType frameType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation)
const RTPFragmentationHeader* fragmentation,
const RTPVideoTypeHeader* rtpTypeHdr)
{
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, _id,
"SendOutgoingData(frameType:%d payloadType:%d timeStamp:%u payloadSize:%u)",
@ -1095,11 +1096,13 @@ ModuleRtpRtcpImpl::SendOutgoingData(const FrameType frameType,
if(!haveChildModules)
{
retVal = _rtpSender.SendOutgoingData(frameType,
payloadType,
payloadType,
timeStamp,
payloadData,
payloadSize,
fragmentation);
fragmentation,
NULL,
rtpTypeHdr);
} else
{
CriticalSectionScoped lock(_criticalSectionModulePtrs);
@ -1115,7 +1118,9 @@ ModuleRtpRtcpImpl::SendOutgoingData(const FrameType frameType,
timeStamp,
payloadData,
payloadSize,
fragmentation);
fragmentation,
NULL,
rtpTypeHdr);
item = _childModules.Next(item);
}
@ -1130,7 +1135,8 @@ ModuleRtpRtcpImpl::SendOutgoingData(const FrameType frameType,
payloadData,
payloadSize,
fragmentation,
codecInfo);
codecInfo,
rtpTypeHdr);
item = _childModules.Next(item);
}

View File

@ -27,6 +27,7 @@ class MatlabPlot;
#endif
namespace webrtc {
class ModuleRtpRtcpImpl : public ModuleRtpRtcpPrivate, private TMMBRHelp
{
public:
@ -224,12 +225,14 @@ public:
virtual WebRtc_Word32 RegisterSendTransport(Transport* outgoingTransport);
// Used by the codec module to deliver a video or audio frame for packetization
virtual WebRtc_Word32 SendOutgoingData(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation = NULL);
virtual WebRtc_Word32
SendOutgoingData(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation = NULL,
const RTPVideoTypeHeader* rtpTypeHdr = NULL);
/*
* RTCP

View File

@ -644,7 +644,8 @@ RTPSender::SendOutgoingData(const FrameType frameType,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codecInfo)
VideoCodecInformation* codecInfo,
const RTPVideoTypeHeader* rtpTypeHdr)
{
{
// Drop this packet if we're not sending media packets
@ -686,7 +687,8 @@ RTPSender::SendOutgoingData(const FrameType frameType,
payloadData,
payloadSize,
fragmentation,
codecInfo);
codecInfo,
rtpTypeHdr);
}
}

View File

@ -124,13 +124,15 @@ public:
WebRtc_Word32 SetMaxPayloadLength(const WebRtc_UWord16 length,
const WebRtc_UWord16 packetOverHead);
WebRtc_Word32 SendOutgoingData(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codecInfo = NULL);
WebRtc_Word32
SendOutgoingData(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codecInfo = NULL,
const RTPVideoTypeHeader* rtpTypeHdr = NULL);
/*
* NACK

View File

@ -367,7 +367,8 @@ RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codecInfo)
VideoCodecInformation* codecInfo,
const RTPVideoTypeHeader* rtpTypeHdr)
{
if( payloadSize == 0)
{
@ -406,8 +407,8 @@ RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType,
payloadData, payloadSize);
break;
case kRtpVp8Video:
retVal = SendVP8(frameType, payloadType, captureTimeStamp, payloadData,
payloadSize, fragmentation);
retVal = SendVP8(frameType, payloadType, captureTimeStamp,
payloadData, payloadSize, fragmentation, rtpTypeHdr);
break;
default:
assert(false);
@ -1211,7 +1212,8 @@ RTPSenderVideo::SendVP8(const FrameType frameType,
const WebRtc_UWord32 captureTimeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation)
const RTPFragmentationHeader* fragmentation,
const RTPVideoTypeHeader* rtpTypeHdr)
{
const WebRtc_UWord16 rtpHeaderLength = _rtpSender.RTPHeaderLength();
WebRtc_UWord16 vp8HeaderLength = 1;

View File

@ -54,7 +54,8 @@ public:
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation,
VideoCodecInformation* codecInfo);
VideoCodecInformation* codecInfo,
const RTPVideoTypeHeader* rtpTypeHdr);
WebRtc_Word32 SendRTPIntraRequest();
@ -118,7 +119,9 @@ private:
const WebRtc_UWord32 captureTimeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation);
const RTPFragmentationHeader* fragmentation,
const RTPVideoTypeHeader* /*rtpTypeHdr*/);
// TODO(hlundin): Remove comments once we start using rtpTypeHdr.
// MPEG 4
WebRtc_Word32 FindMPEG4NALU(const WebRtc_UWord8* inData ,WebRtc_Word32 MaxPayloadLength);

View File

@ -148,7 +148,8 @@ WebRtc_Word32 VideoCoder::SendData(
WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader& fragmentationHeader)
const RTPFragmentationHeader& fragmentationHeader,
const RTPVideoTypeHeader* rtpTypeHdr)
{
// Store the data in _videoEncodedData which is a pointer to videoFrame in
// Encode(..)

View File

@ -63,7 +63,8 @@ private:
const WebRtc_UWord32 /*timeStamp*/,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader& /* fragmentationHeader*/);
const RTPFragmentationHeader& /* fragmentationHeader*/,
const RTPVideoTypeHeader* rtpTypeHdr);
WebRtc_UWord32 _instanceID;
VideoCodingModule* _vcm;

View File

@ -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.
//

View File

@ -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)
{

View File

@ -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.
//

View File

@ -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.

View File

@ -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)

View File

@ -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.
//

View File

@ -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() {}
};

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -900,9 +900,10 @@ WebRtc_Word32 ViECapturer::InitEncode(const VideoCodec* codecSettings,
* Encode
* Orders the Capture device to create a certain frame type.
*/
WebRtc_Word32 ViECapturer::Encode(const RawImage& inputImage,
const void* codecSpecificInfo, /*= NULL,*/
VideoFrameType frameType /*= kDeltaFrame*/)
WebRtc_Word32
ViECapturer::Encode(const RawImage& inputImage,
const CodecSpecificInfo* codecSpecificInfo, /*= NULL,*/
VideoFrameType frameType /*= kDeltaFrame*/)
{
CriticalSectionScoped cs(_encodingCritsect);

View File

@ -125,7 +125,8 @@ protected:
WebRtc_Word32 numberOfCores,
WebRtc_UWord32 maxPayloadSize);
virtual WebRtc_Word32 Encode(const RawImage& inputImage,
const void* codecSpecificInfo = NULL,
const CodecSpecificInfo* codecSpecificInfo =
NULL,
VideoFrameType frameType = kDeltaFrame);
virtual WebRtc_Word32 RegisterEncodeCompleteCallback(
EncodedImageCallback* callback);

View File

@ -767,12 +767,14 @@ WebRtc_Word32 ViEEncoder::UpdateProtectionMethod()
// ----------------------------------------------------------------------------
// SendData
// ----------------------------------------------------------------------------
WebRtc_Word32 ViEEncoder::SendData(const FrameType frameType,
const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const webrtc::RTPFragmentationHeader& fragmentationHeader)
WebRtc_Word32
ViEEncoder::SendData(const FrameType frameType,
const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const webrtc::RTPFragmentationHeader& fragmentationHeader,
const RTPVideoTypeHeader* rtpTypeHdr)
{
{
CriticalSectionScoped cs(_dataCritsect);
@ -793,7 +795,8 @@ WebRtc_Word32 ViEEncoder::SendData(const FrameType frameType,
WebRtc_Word32 retVal = _rtpRtcp.SendOutgoingData(frameType, payloadType,
timeStamp, payloadData,
payloadSize,
&fragmentationHeader);
&fragmentationHeader,
rtpTypeHdr);
return retVal;
}

View File

@ -86,12 +86,14 @@ public:
// Loss protection
WebRtc_Word32 UpdateProtectionMethod();
// Implements VCMPacketizationCallback
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);
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);
// Implements VideoProtectionCallback
virtual WebRtc_Word32 ProtectionRequest(const WebRtc_UWord8 deltaFECRate,
const WebRtc_UWord8 keyFECRate,