Decoupled video rtp receiver from rtp receiver.
BUG= Review URL: https://webrtc-codereview.appspot.com/995005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3292 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -17,7 +17,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
class MockRTPReceiverVideo : public RTPReceiverVideo {
|
class MockRTPReceiverVideo : public RTPReceiverVideo {
|
||||||
public:
|
public:
|
||||||
MockRTPReceiverVideo() : RTPReceiverVideo(0, NULL) {}
|
MockRTPReceiverVideo() : RTPReceiverVideo(0, NULL, NULL) {}
|
||||||
MOCK_METHOD1(ChangeUniqueId,
|
MOCK_METHOD1(ChangeUniqueId,
|
||||||
void(const WebRtc_Word32 id));
|
void(const WebRtc_Word32 id));
|
||||||
MOCK_METHOD3(ReceiveRecoveredPacketCallback,
|
MOCK_METHOD3(ReceiveRecoveredPacketCallback,
|
||||||
|
@ -34,7 +34,6 @@ RTPReceiver::RTPReceiver(const WebRtc_Word32 id,
|
|||||||
RtpRtcpClock* clock,
|
RtpRtcpClock* clock,
|
||||||
ModuleRtpRtcpImpl* owner,
|
ModuleRtpRtcpImpl* owner,
|
||||||
RtpAudioFeedback* incomingMessagesCallback) :
|
RtpAudioFeedback* incomingMessagesCallback) :
|
||||||
RTPReceiverVideo(id, owner),
|
|
||||||
Bitrate(clock),
|
Bitrate(clock),
|
||||||
_id(id),
|
_id(id),
|
||||||
_audio(audio),
|
_audio(audio),
|
||||||
@ -97,6 +96,7 @@ RTPReceiver::RTPReceiver(const WebRtc_Word32 id,
|
|||||||
_RTX(false),
|
_RTX(false),
|
||||||
_ssrcRTX(0) {
|
_ssrcRTX(0) {
|
||||||
_rtpReceiverAudio = new RTPReceiverAudio(id, this, incomingMessagesCallback);
|
_rtpReceiverAudio = new RTPReceiverAudio(id, this, incomingMessagesCallback);
|
||||||
|
_rtpReceiverVideo = new RTPReceiverVideo(id, this, owner);
|
||||||
|
|
||||||
memset(_currentRemoteCSRC, 0, sizeof(_currentRemoteCSRC));
|
memset(_currentRemoteCSRC, 0, sizeof(_currentRemoteCSRC));
|
||||||
memset(_currentRemoteEnergy, 0, sizeof(_currentRemoteEnergy));
|
memset(_currentRemoteEnergy, 0, sizeof(_currentRemoteEnergy));
|
||||||
@ -123,6 +123,7 @@ RTPReceiver::~RTPReceiver() {
|
|||||||
delete it->second;
|
delete it->second;
|
||||||
_payloadTypeMap.erase(it);
|
_payloadTypeMap.erase(it);
|
||||||
}
|
}
|
||||||
|
delete _rtpReceiverVideo;
|
||||||
delete _rtpReceiverAudio;
|
delete _rtpReceiverAudio;
|
||||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
|
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
|
||||||
}
|
}
|
||||||
@ -398,7 +399,8 @@ WebRtc_Word32 RTPReceiver::RegisterReceivePayload(
|
|||||||
payload = _rtpReceiverAudio->RegisterReceiveAudioPayload(
|
payload = _rtpReceiverAudio->RegisterReceiveAudioPayload(
|
||||||
payloadName, payloadType, frequency, channels, rate);
|
payloadName, payloadType, frequency, channels, rate);
|
||||||
} else {
|
} else {
|
||||||
payload = RegisterReceiveVideoPayload(payloadName, payloadType, rate);
|
payload = _rtpReceiverVideo->RegisterReceiveVideoPayload(
|
||||||
|
payloadName, payloadType, rate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (payload == NULL) {
|
if (payload == NULL) {
|
||||||
@ -755,20 +757,13 @@ WebRtc_Word32 RTPReceiver::IncomingRTPPacket(
|
|||||||
|
|
||||||
WebRtc_Word32 retVal = 0;
|
WebRtc_Word32 retVal = 0;
|
||||||
if(_audio) {
|
if(_audio) {
|
||||||
retVal = _rtpReceiverAudio->ParseAudioCodecSpecific(rtp_header,
|
retVal = _rtpReceiverAudio->ParseAudioCodecSpecific(
|
||||||
payload_data,
|
rtp_header, payload_data, payload_data_length, audio_specific, is_red);
|
||||||
payload_data_length,
|
|
||||||
audio_specific,
|
|
||||||
is_red);
|
|
||||||
} else {
|
} else {
|
||||||
retVal = ParseVideoCodecSpecific(rtp_header,
|
retVal = _rtpReceiverVideo->ParseVideoCodecSpecific(
|
||||||
payload_data,
|
rtp_header, payload_data, payload_data_length,
|
||||||
payload_data_length,
|
video_specific.videoCodecType, is_red, packet, packet_length,
|
||||||
video_specific.videoCodecType,
|
_clock.GetTimeInMS());
|
||||||
is_red,
|
|
||||||
packet,
|
|
||||||
packet_length,
|
|
||||||
_clock.GetTimeInMS());
|
|
||||||
}
|
}
|
||||||
if(retVal < 0) {
|
if(retVal < 0) {
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -29,7 +29,7 @@ class RtpRtcpFeedback;
|
|||||||
class ModuleRtpRtcpImpl;
|
class ModuleRtpRtcpImpl;
|
||||||
class Trace;
|
class Trace;
|
||||||
|
|
||||||
class RTPReceiver : public RTPReceiverVideo, public Bitrate
|
class RTPReceiver : public Bitrate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RTPReceiver(const WebRtc_Word32 id,
|
RTPReceiver(const WebRtc_Word32 id,
|
||||||
@ -161,6 +161,10 @@ public:
|
|||||||
const WebRtc_UWord8* payloadData,
|
const WebRtc_UWord8* payloadData,
|
||||||
const WebRtc_UWord16 payloadSize,
|
const WebRtc_UWord16 payloadSize,
|
||||||
const WebRtcRTPHeader* rtpHeader);
|
const WebRtcRTPHeader* rtpHeader);
|
||||||
|
|
||||||
|
virtual WebRtc_Word8 REDPayloadType() const;
|
||||||
|
|
||||||
|
bool HaveNotReceivedPackets() const;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual bool RetransmitOfOldPacket(const WebRtc_UWord16 sequenceNumber,
|
virtual bool RetransmitOfOldPacket(const WebRtc_UWord16 sequenceNumber,
|
||||||
@ -171,10 +175,6 @@ protected:
|
|||||||
const WebRtc_UWord16 bytes,
|
const WebRtc_UWord16 bytes,
|
||||||
const bool oldPacket);
|
const bool oldPacket);
|
||||||
|
|
||||||
virtual WebRtc_Word8 REDPayloadType() const;
|
|
||||||
|
|
||||||
bool HaveNotReceivedPackets() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Is RED configured with payload type payloadType
|
// Is RED configured with payload type payloadType
|
||||||
bool REDPayloadType(const WebRtc_Word8 payloadType) const;
|
bool REDPayloadType(const WebRtc_Word8 payloadType) const;
|
||||||
@ -194,6 +194,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RTPReceiverAudio* _rtpReceiverAudio;
|
RTPReceiverAudio* _rtpReceiverAudio;
|
||||||
|
RTPReceiverVideo* _rtpReceiverVideo;
|
||||||
|
|
||||||
WebRtc_Word32 _id;
|
WebRtc_Word32 _id;
|
||||||
const bool _audio;
|
const bool _audio;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "critical_section_wrapper.h"
|
#include "critical_section_wrapper.h"
|
||||||
#include "receiver_fec.h"
|
#include "receiver_fec.h"
|
||||||
|
#include "rtp_receiver.h"
|
||||||
#include "rtp_rtcp_impl.h"
|
#include "rtp_rtcp_impl.h"
|
||||||
#include "rtp_utility.h"
|
#include "rtp_utility.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
@ -27,8 +28,10 @@ WebRtc_UWord32 BitRateBPS(WebRtc_UWord16 x )
|
|||||||
}
|
}
|
||||||
|
|
||||||
RTPReceiverVideo::RTPReceiverVideo(const WebRtc_Word32 id,
|
RTPReceiverVideo::RTPReceiverVideo(const WebRtc_Word32 id,
|
||||||
|
RTPReceiver* parent,
|
||||||
ModuleRtpRtcpImpl* owner)
|
ModuleRtpRtcpImpl* owner)
|
||||||
: _id(id),
|
: _id(id),
|
||||||
|
_parent(parent),
|
||||||
_criticalSectionReceiverVideo(
|
_criticalSectionReceiverVideo(
|
||||||
CriticalSectionWrapper::CreateCriticalSection()),
|
CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_currentFecFrameDecoded(false),
|
_currentFecFrameDecoded(false),
|
||||||
@ -114,8 +117,8 @@ WebRtc_Word32 RTPReceiverVideo::ParseVideoCodecSpecific(
|
|||||||
}
|
}
|
||||||
// Pass the length of FEC packets so that they can be accounted for in
|
// Pass the length of FEC packets so that they can be accounted for in
|
||||||
// the bandwidth estimator.
|
// the bandwidth estimator.
|
||||||
retVal = CallbackOfReceivedPayloadData(NULL, payloadDataLength,
|
retVal = _parent->CallbackOfReceivedPayloadData(NULL, payloadDataLength,
|
||||||
rtpHeader);
|
rtpHeader);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// will leave the _criticalSectionReceiverVideo critsect
|
// will leave the _criticalSectionReceiverVideo critsect
|
||||||
@ -173,7 +176,8 @@ WebRtc_Word32 RTPReceiverVideo::ReceiveRecoveredPacketCallback(
|
|||||||
_currentFecFrameDecoded = true;
|
_currentFecFrameDecoded = true;
|
||||||
|
|
||||||
ModuleRTPUtility::Payload* payload = NULL;
|
ModuleRTPUtility::Payload* payload = NULL;
|
||||||
if (PayloadTypeToPayload(rtpHeader->header.payloadType, payload) != 0) {
|
if (_parent->PayloadTypeToPayload(
|
||||||
|
rtpHeader->header.payloadType, payload) != 0) {
|
||||||
_criticalSectionReceiverVideo->Leave();
|
_criticalSectionReceiverVideo->Leave();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -186,8 +190,8 @@ WebRtc_Word32 RTPReceiverVideo::ReceiveRecoveredPacketCallback(
|
|||||||
const WebRtc_UWord8 REDForFECHeaderLength = 1;
|
const WebRtc_UWord8 REDForFECHeaderLength = 1;
|
||||||
|
|
||||||
// replace pltype
|
// replace pltype
|
||||||
recoveredPacket[1] &= 0x80; // reset
|
recoveredPacket[1] &= 0x80; // Reset.
|
||||||
recoveredPacket[1] += REDPayloadType(); // replace with RED payload type
|
recoveredPacket[1] += _parent->REDPayloadType();
|
||||||
|
|
||||||
// add RED header
|
// add RED header
|
||||||
recoveredPacket[rtpHeaderLength] = rtpHeader->header.payloadType;
|
recoveredPacket[rtpHeaderLength] = rtpHeader->header.payloadType;
|
||||||
@ -273,7 +277,7 @@ WebRtc_Word32 RTPReceiverVideo::ReceiveVp8Codec(
|
|||||||
// we have an "empty" VP8 packet, it's ok, could be one way video
|
// we have an "empty" VP8 packet, it's ok, could be one way video
|
||||||
// Inform the jitter buffer about this packet.
|
// Inform the jitter buffer about this packet.
|
||||||
rtpHeader->frameType = kFrameEmpty;
|
rtpHeader->frameType = kFrameEmpty;
|
||||||
if (CallbackOfReceivedPayloadData(NULL, 0, rtpHeader) != 0) {
|
if (_parent->CallbackOfReceivedPayloadData(NULL, 0, rtpHeader) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -306,9 +310,9 @@ WebRtc_Word32 RTPReceiverVideo::ReceiveVp8Codec(
|
|||||||
toHeader->partitionId = fromHeader->partitionID;
|
toHeader->partitionId = fromHeader->partitionID;
|
||||||
toHeader->beginningOfPartition = fromHeader->beginningOfPartition;
|
toHeader->beginningOfPartition = fromHeader->beginningOfPartition;
|
||||||
|
|
||||||
if(CallbackOfReceivedPayloadData(parsedPacket.info.VP8.data,
|
if(_parent->CallbackOfReceivedPayloadData(parsedPacket.info.VP8.data,
|
||||||
parsedPacket.info.VP8.dataLength,
|
parsedPacket.info.VP8.dataLength,
|
||||||
rtpHeader) != 0) {
|
rtpHeader) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -322,16 +326,16 @@ WebRtc_Word32 RTPReceiverVideo::ReceiveGenericCodec(
|
|||||||
rtpHeader->frameType = kVideoFrameKey;
|
rtpHeader->frameType = kVideoFrameKey;
|
||||||
|
|
||||||
bool isFirstPacketInFrame =
|
bool isFirstPacketInFrame =
|
||||||
(SequenceNumber() + 1) == rtpHeader->header.sequenceNumber &&
|
(_parent->SequenceNumber() + 1) == rtpHeader->header.sequenceNumber &&
|
||||||
TimeStamp() != rtpHeader->header.timestamp;
|
(_parent->TimeStamp() != rtpHeader->header.timestamp);
|
||||||
|
|
||||||
if (isFirstPacketInFrame || HaveNotReceivedPackets()) {
|
if (isFirstPacketInFrame || _parent->HaveNotReceivedPackets()) {
|
||||||
rtpHeader->type.Video.isFirstPacket = true;
|
rtpHeader->type.Video.isFirstPacket = true;
|
||||||
}
|
}
|
||||||
_criticalSectionReceiverVideo->Leave();
|
_criticalSectionReceiverVideo->Leave();
|
||||||
|
|
||||||
if (CallbackOfReceivedPayloadData(payloadData, payloadDataLength,
|
if (_parent->CallbackOfReceivedPayloadData(payloadData, payloadDataLength,
|
||||||
rtpHeader) != 0) {
|
rtpHeader) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -20,13 +20,15 @@
|
|||||||
#include "scoped_ptr.h"
|
#include "scoped_ptr.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class ReceiverFEC;
|
|
||||||
class ModuleRtpRtcpImpl;
|
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
|
class ModuleRtpRtcpImpl;
|
||||||
|
class ReceiverFEC;
|
||||||
|
class RTPReceiver;
|
||||||
|
|
||||||
class RTPReceiverVideo {
|
class RTPReceiverVideo {
|
||||||
public:
|
public:
|
||||||
RTPReceiverVideo(const WebRtc_Word32 id,
|
RTPReceiverVideo(const WebRtc_Word32 id,
|
||||||
|
RTPReceiver* parent,
|
||||||
ModuleRtpRtcpImpl* owner);
|
ModuleRtpRtcpImpl* owner);
|
||||||
|
|
||||||
virtual ~RTPReceiverVideo();
|
virtual ~RTPReceiverVideo();
|
||||||
@ -54,25 +56,6 @@ class RTPReceiverVideo {
|
|||||||
void SetPacketOverHead(WebRtc_UWord16 packetOverHead);
|
void SetPacketOverHead(WebRtc_UWord16 packetOverHead);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WebRtc_Word32 CallbackOfReceivedPayloadData(
|
|
||||||
const WebRtc_UWord8* payloadData,
|
|
||||||
const WebRtc_UWord16 payloadSize,
|
|
||||||
const WebRtcRTPHeader* rtpHeader) = 0;
|
|
||||||
|
|
||||||
virtual WebRtc_UWord32 TimeStamp() const = 0;
|
|
||||||
virtual WebRtc_UWord16 SequenceNumber() const = 0;
|
|
||||||
|
|
||||||
virtual WebRtc_UWord32 PayloadTypeToPayload(
|
|
||||||
const WebRtc_UWord8 payloadType,
|
|
||||||
ModuleRTPUtility::Payload*& payload) const = 0;
|
|
||||||
|
|
||||||
virtual bool RetransmitOfOldPacket(
|
|
||||||
const WebRtc_UWord16 sequenceNumber,
|
|
||||||
const WebRtc_UWord32 rtpTimeStamp) const = 0;
|
|
||||||
|
|
||||||
virtual WebRtc_Word8 REDPayloadType() const = 0;
|
|
||||||
virtual bool HaveNotReceivedPackets() const = 0;
|
|
||||||
|
|
||||||
WebRtc_Word32 SetCodecType(const RtpVideoCodecTypes videoType,
|
WebRtc_Word32 SetCodecType(const RtpVideoCodecTypes videoType,
|
||||||
WebRtcRTPHeader* rtpHeader) const;
|
WebRtcRTPHeader* rtpHeader) const;
|
||||||
|
|
||||||
@ -95,6 +78,7 @@ class RTPReceiverVideo {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
WebRtc_Word32 _id;
|
WebRtc_Word32 _id;
|
||||||
|
RTPReceiver* _parent;
|
||||||
|
|
||||||
CriticalSectionWrapper* _criticalSectionReceiverVideo;
|
CriticalSectionWrapper* _criticalSectionReceiverVideo;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user