Bug 985254: modify upstream h264 packetization patch to make it work r=pkerr

This commit is contained in:
Randell Jesup 2014-05-24 18:28:01 -04:00
parent fe6e9b77c7
commit 295343b36e
6 changed files with 25 additions and 36 deletions

View File

@ -1064,6 +1064,11 @@ inline bool IsNewerTimestamp(uint32_t timestamp, uint32_t prev_timestamp) {
static_cast<uint32_t>(timestamp - prev_timestamp) < 0x80000000;
}
inline bool IsNewerOrSameTimestamp(uint32_t timestamp, uint32_t prev_timestamp) {
return timestamp == prev_timestamp ||
static_cast<uint32_t>(timestamp - prev_timestamp) < 0x80000000;
}
inline uint16_t LatestSequenceNumber(uint16_t sequence_number1,
uint16_t sequence_number2) {
return IsNewerSequenceNumber(sequence_number1, sequence_number2) ?

View File

@ -271,15 +271,16 @@ int32_t RTPReceiverVideo::ReceiveH264Codec(WebRtcRTPHeader* rtp_header,
payload_length = payload_data_length;
rtp_header->type.Video.codec = kRtpVideoH264;
rtp_header->type.Video.isFirstPacket = true; // First packet
rtp_header->type.Video.isFirstPacket = true;
RTPVideoHeaderH264* h264_header = &rtp_header->type.Video.codecHeader.H264;
h264_header->nalu_header = payload_data[0];
h264_header->single_nalu = true;
// WebRtcRTPHeader
if (nal_type == RtpFormatH264::kH264NALU_IDR) {
rtp_header->frameType = kVideoFrameKey;
rtp_header->type.Video.isFirstPacket = false;
if (nal_type == RtpFormatH264::kH264NALU_SPS ||
nal_type == RtpFormatH264::kH264NALU_PPS ||
nal_type == RtpFormatH264::kH264NALU_IDR) {
rtp_header->frameType = kVideoFrameKey; // not really....
} else {
rtp_header->frameType = kVideoFrameDelta;
}

View File

@ -528,6 +528,11 @@ int32_t RTPSenderVideo::SendH264(const FrameType frameType,
rtpHeaderLength, captureTimeStamp,
capture_time_ms, storage, protect)) {
}
if (ret_val == 0) {
// single NAL unit
last = true;
}
}
return 0;
}

View File

@ -51,14 +51,14 @@ bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const {
assert(frame != NULL);
if (in_initial_state_)
return false;
return !IsNewerTimestamp(frame->TimeStamp(), time_stamp_);
return !IsNewerOrSameTimestamp(frame->TimeStamp(), time_stamp_);
}
bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const {
assert(packet != NULL);
if (in_initial_state_)
return false;
return !IsNewerTimestamp(packet->timestamp, time_stamp_);
return !IsNewerOrSameTimestamp(packet->timestamp, time_stamp_);
}
void VCMDecodingState::SetState(const VCMFrameBuffer* frame) {

View File

@ -112,27 +112,11 @@ void VCMPacket::CopyCodecSpecifics(const RTPVideoHeader& videoHeader) {
case kRtpVideoH264: {
uint8_t nal_type = videoHeader.codecHeader.H264.nalu_header & RtpFormatH264::kH264NAL_TypeMask;
if (videoHeader.codecHeader.H264.single_nalu) {
if (nal_type == RtpFormatH264::kH264NALU_SPS ||
nal_type == RtpFormatH264::kH264NALU_PPS) {
insertStartCode = true;
isFirstPacket = false;
markerBit = false;
} else {
isFirstPacket = true;
markerBit = true;
insertStartCode = true;
}
} else {
// Fragmented NALU
if (isFirstPacket) {
insertStartCode = true;
if (nal_type == RtpFormatH264::kH264NALU_IDR) {
// We always assume IDR is pre-leaded with a PPS or SPS/PPS.
isFirstPacket = false;
}
} else {
insertStartCode = false;
}
isFirstPacket = true;
markerBit = true;
}
if (isFirstPacket) {
insertStartCode = true;
}
if (isFirstPacket && markerBit)
@ -144,6 +128,7 @@ void VCMPacket::CopyCodecSpecifics(const RTPVideoHeader& videoHeader) {
else
completeNALU = kNaluIncomplete;
codec = kVideoCodecH264;
break;
}
default: {
codec = kVideoCodecUnknown;

View File

@ -423,15 +423,8 @@ int VCMSessionInfo::InsertPacket(const VCMPacket& packet,
if (packet.codec == kVideoCodecH264) {
RTPVideoHeaderH264 h264 = packet.codecSpecificHeader.codecHeader.H264;
uint8_t nal_type = h264.nalu_header & RtpFormatH264::kH264NAL_TypeMask;
bool potential_start = false;
if (nal_type == RtpFormatH264::kH264NALU_SPS ||
nal_type == RtpFormatH264::kH264NALU_PPS ||
packet.codecSpecificHeader.codecHeader.H264.single_nalu) {
potential_start = true;
} else {
potential_start = packet.isFirstPacket;
}
if (potential_start) {
if (packet.isFirstPacket) {
if (HaveFirstPacket() == false ||
IsNewerSequenceNumber(first_packet_seq_num_, packet.seqNum)) {
first_packet_seq_num_ = packet.seqNum;