Changed handling of padding data.
Review URL: http://webrtc-codereview.appspot.com/331008 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1252 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
dbba1f969f
commit
061fa5b828
@ -804,12 +804,6 @@ RTPReceiver::IncomingRTPPacket(WebRtcRTPHeader* rtpHeader,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(length - rtpHeader->header.headerLength == 0)
|
|
||||||
{
|
|
||||||
// ok keepalive packet
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word8 firstPayloadByte = 0;
|
WebRtc_Word8 firstPayloadByte = 0;
|
||||||
if(length > 0)
|
if(length > 0)
|
||||||
{
|
{
|
||||||
@ -829,9 +823,23 @@ RTPReceiver::IncomingRTPPacket(WebRtcRTPHeader* rtpHeader,
|
|||||||
audioSpecific.channels = 0;
|
audioSpecific.channels = 0;
|
||||||
audioSpecific.frequency = 0;
|
audioSpecific.frequency = 0;
|
||||||
|
|
||||||
if(CheckPayloadChanged(rtpHeader, firstPayloadByte, isRED, audioSpecific, videoSpecific) == -1)
|
if (CheckPayloadChanged(rtpHeader,
|
||||||
|
firstPayloadByte,
|
||||||
|
isRED,
|
||||||
|
audioSpecific,
|
||||||
|
videoSpecific) == -1)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id, "%s received invalid payloadtype", __FUNCTION__);
|
if (length - rtpHeader->header.headerLength == 0)
|
||||||
|
{
|
||||||
|
// ok keepalive packet
|
||||||
|
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, _id,
|
||||||
|
"%s received keepalive",
|
||||||
|
__FUNCTION__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id,
|
||||||
|
"%s received invalid payloadtype",
|
||||||
|
__FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
CheckCSRC(rtpHeader);
|
CheckCSRC(rtpHeader);
|
||||||
@ -847,7 +855,7 @@ RTPReceiver::IncomingRTPPacket(WebRtcRTPHeader* rtpHeader,
|
|||||||
payloadDataLength,
|
payloadDataLength,
|
||||||
audioSpecific,
|
audioSpecific,
|
||||||
isRED);
|
isRED);
|
||||||
}else
|
} else
|
||||||
{
|
{
|
||||||
retVal = ParseVideoCodecSpecific(rtpHeader,
|
retVal = ParseVideoCodecSpecific(rtpHeader,
|
||||||
payloadData,
|
payloadData,
|
||||||
|
@ -231,7 +231,8 @@ RTPReceiverVideo::ParseVideoCodecSpecific(WebRtcRTPHeader* rtpHeader,
|
|||||||
|
|
||||||
_criticalSectionReceiverVideo->Enter();
|
_criticalSectionReceiverVideo->Enter();
|
||||||
|
|
||||||
_videoBitRate.Update(payloadDataLength, nowMS);
|
_videoBitRate.Update(payloadDataLength + rtpHeader->header.paddingLength,
|
||||||
|
nowMS);
|
||||||
|
|
||||||
// Add headers, ideally we would like to include for instance
|
// Add headers, ideally we would like to include for instance
|
||||||
// Ethernet header here as well.
|
// Ethernet header here as well.
|
||||||
@ -647,14 +648,21 @@ RTPReceiverVideo::ReceiveVp8Codec(WebRtcRTPHeader* rtpHeader,
|
|||||||
const WebRtc_UWord8* payloadData,
|
const WebRtc_UWord8* payloadData,
|
||||||
const WebRtc_UWord16 payloadDataLength)
|
const WebRtc_UWord16 payloadDataLength)
|
||||||
{
|
{
|
||||||
|
bool success;
|
||||||
|
ModuleRTPUtility::RTPPayload parsedPacket;
|
||||||
|
if (payloadDataLength == 0)
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
parsedPacket.info.VP8.dataLength = 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
ModuleRTPUtility::RTPPayloadParser rtpPayloadParser(kRtpVp8Video,
|
ModuleRTPUtility::RTPPayloadParser rtpPayloadParser(kRtpVp8Video,
|
||||||
payloadData,
|
payloadData,
|
||||||
payloadDataLength,
|
payloadDataLength,
|
||||||
_id);
|
_id);
|
||||||
|
|
||||||
ModuleRTPUtility::RTPPayload parsedPacket;
|
success = rtpPayloadParser.Parse(parsedPacket);
|
||||||
const bool success = rtpPayloadParser.Parse(parsedPacket);
|
}
|
||||||
|
|
||||||
// from here down we only work on local data
|
// from here down we only work on local data
|
||||||
_criticalSectionReceiverVideo->Leave();
|
_criticalSectionReceiverVideo->Leave();
|
||||||
|
|
||||||
@ -665,6 +673,12 @@ RTPReceiverVideo::ReceiveVp8Codec(WebRtcRTPHeader* rtpHeader,
|
|||||||
if (parsedPacket.info.VP8.dataLength == 0)
|
if (parsedPacket.info.VP8.dataLength == 0)
|
||||||
{
|
{
|
||||||
// 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.
|
||||||
|
rtpHeader->frameType = kFrameEmpty;
|
||||||
|
if (CallbackOfReceivedPayloadData(NULL, 0, rtpHeader) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rtpHeader->frameType = (parsedPacket.frameType == ModuleRTPUtility::kIFrame) ? kVideoFrameKey : kVideoFrameDelta;
|
rtpHeader->frameType = (parsedPacket.frameType == ModuleRTPUtility::kIFrame) ? kVideoFrameKey : kVideoFrameDelta;
|
||||||
|
@ -545,50 +545,52 @@ RTPSenderVideo::SendGeneric(const WebRtc_Word8 payloadType,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
void RTPSenderVideo::SendPadData(WebRtc_Word8 payload_type,
|
||||||
RTPSenderVideo::SendPadData(const WebRtcRTPHeader* rtpHeader,
|
WebRtc_UWord32 capture_timestamp,
|
||||||
const WebRtc_UWord32 bytes)
|
WebRtc_Word32 bytes) {
|
||||||
{
|
// Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
|
||||||
const WebRtc_UWord16 rtpHeaderLength = _rtpSender.RTPHeaderLength();
|
int max_length = 224;
|
||||||
WebRtc_UWord32 maxLength = _rtpSender.MaxPayloadLength() -
|
WebRtc_UWord8 data_buffer[IP_PACKET_SIZE];
|
||||||
FECPacketOverhead() - rtpHeaderLength;
|
|
||||||
WebRtc_UWord8 dataBuffer[IP_PACKET_SIZE];
|
|
||||||
|
|
||||||
if(bytes<maxLength)
|
|
||||||
{
|
|
||||||
// For a small packet don't spend too much time
|
|
||||||
maxLength = bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (; bytes > 0; bytes -= max_length) {
|
||||||
|
WebRtc_Word32 header_length;
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(_sendVideoCritsect);
|
CriticalSectionScoped cs(_sendVideoCritsect);
|
||||||
|
|
||||||
// Send paded data
|
// Correct seq num, timestamp and payload type.
|
||||||
// Correct seq num, time stamp and payloadtype
|
header_length = _rtpSender.BuildRTPheader(
|
||||||
// We reuse the last seq number
|
data_buffer,
|
||||||
_rtpSender.BuildRTPheader(dataBuffer, rtpHeader->header.payloadType,
|
payload_type,
|
||||||
false, 0, false, false);
|
false, // No markerbit.
|
||||||
|
capture_timestamp,
|
||||||
|
true, // Timestamp provided.
|
||||||
|
true); // Increment sequence number.
|
||||||
|
|
||||||
// Version 0 to be compatible with old ViE
|
}
|
||||||
dataBuffer[0] &= !0x80;
|
data_buffer[0] |= 0x20; // Set padding bit.
|
||||||
|
WebRtc_Word32* data =
|
||||||
|
reinterpret_cast<WebRtc_Word32*>(&(data_buffer[header_length]));
|
||||||
|
|
||||||
// Set relay SSRC
|
int padding_bytes_in_packet = max_length;
|
||||||
ModuleRTPUtility::AssignUWord32ToBuffer(dataBuffer+8,
|
if (bytes < max_length) {
|
||||||
rtpHeader->header.ssrc);
|
padding_bytes_in_packet = (bytes + 16) & 0xffe0; // Keep our modulus 32.
|
||||||
// Start at 12
|
}
|
||||||
WebRtc_Word32* data = (WebRtc_Word32*)&(dataBuffer[12]);
|
if (padding_bytes_in_packet < 32) {
|
||||||
|
// Sanity don't send empty packets.
|
||||||
// Build data buffer
|
return;
|
||||||
for(WebRtc_UWord32 j = 0; j < ((maxLength>>2)-4) && j < (bytes>>4); j++)
|
}
|
||||||
{
|
// Fill data buffer with random data.
|
||||||
|
for(int j = 0; j < (padding_bytes_in_packet >> 2); j++) {
|
||||||
data[j] = rand();
|
data[j] = rand();
|
||||||
}
|
}
|
||||||
}
|
// Set number of padding bytes in the last byte of the packet.
|
||||||
// Min
|
data_buffer[header_length + padding_bytes_in_packet - 1] =
|
||||||
WebRtc_UWord16 length = (WebRtc_UWord16)(bytes<maxLength?bytes:maxLength);
|
padding_bytes_in_packet;
|
||||||
|
|
||||||
// Send the packet
|
// Send the packet
|
||||||
return _rtpSender.SendToNetwork(dataBuffer, length, rtpHeaderLength, true);
|
_rtpSender.SendToNetwork(data_buffer,
|
||||||
|
padding_bytes_in_packet,
|
||||||
|
header_length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word32
|
||||||
|
@ -68,8 +68,9 @@ public:
|
|||||||
|
|
||||||
WebRtc_UWord32 MaxConfiguredBitrateVideo() const;
|
WebRtc_UWord32 MaxConfiguredBitrateVideo() const;
|
||||||
|
|
||||||
WebRtc_Word32 SendPadData(const WebRtcRTPHeader* rtpHeader,
|
void SendPadData(WebRtc_Word8 payload_type,
|
||||||
const WebRtc_UWord32 bytes);
|
WebRtc_UWord32 capture_timestamp,
|
||||||
|
WebRtc_Word32 bytes);
|
||||||
|
|
||||||
// FEC
|
// FEC
|
||||||
WebRtc_Word32 SetGenericFECStatus(const bool enable,
|
WebRtc_Word32 SetGenericFECStatus(const bool enable,
|
||||||
|
Loading…
Reference in New Issue
Block a user