Bug 1293422 - Add PacketizeMode0 to RtpPacketizerH264; r=jesup a=ritu
authorDan Minor <dminor@mozilla.com>
Tue, 09 Aug 2016 15:59:48 -0400
changeset 347649 96c1a1c7fbaad98436cde8821e959bb0e32adacd
parent 347648 a6fcbbeaddff2a06a9350f2264f0330fc2c1a0b5
child 347650 0463f6653d4830bb793fb43678161dc08b827389
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, ritu
bugs1293422
milestone50.0a2
Bug 1293422 - Add PacketizeMode0 to RtpPacketizerH264; r=jesup a=ritu We were previously using PacketizeFuA which stripped the NAL header. Since the fragment fit in a single packet it would then be sent without any header causing difficulties on the receiving side. This adds a PacketizeMode0 which leaves the header intact. MozReview-Commit-ID: 91rbveSuXtT
media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_h264.h
--- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
+++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
@@ -151,25 +151,40 @@ void RtpPacketizerH264::SetPayloadData(
   fragmentation_.CopyFrom(*fragmentation);
   GeneratePackets();
 }
 
 void RtpPacketizerH264::GeneratePackets() {
   for (size_t i = 0; i < fragmentation_.fragmentationVectorSize;) {
     size_t fragment_offset = fragmentation_.fragmentationOffset[i];
     size_t fragment_length = fragmentation_.fragmentationLength[i];
-    if (fragment_length > max_payload_len_ || packetization_mode_ == 0) {
+    if (packetization_mode_ == 0) {
+      PacketizeMode0(fragment_offset, fragment_length);
+      ++i;
+    } else if (fragment_length > max_payload_len_) {
       PacketizeFuA(fragment_offset, fragment_length);
       ++i;
     } else {
       i = PacketizeStapA(i, fragment_offset, fragment_length);
     }
   }
 }
 
+void RtpPacketizerH264::PacketizeMode0(size_t fragment_offset,
+                                       size_t fragment_length) {
+
+  uint8_t header = payload_data_[fragment_offset];
+  packets_.push(Packet(fragment_offset,
+                       fragment_length,
+                       true,
+                       true,
+                       false,
+                       header));
+}
+
 void RtpPacketizerH264::PacketizeFuA(size_t fragment_offset,
                                      size_t fragment_length) {
   // Fragment payload into packets (FU-A).
   // Strip out the original header and leave room for the FU-A header.
   fragment_length -= kNalHeaderSize;
   size_t offset = fragment_offset + kNalHeaderSize;
   size_t bytes_available = max_payload_len_ - kFuAHeaderSize;
   size_t fragments =
--- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_h264.h
+++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_h264.h
@@ -69,16 +69,17 @@ class RtpPacketizerH264 : public RtpPack
     bool first_fragment;
     bool last_fragment;
     bool aggregated;
     uint8_t header;
   };
   typedef std::queue<Packet> PacketQueue;
 
   void GeneratePackets();
+  void PacketizeMode0(size_t fragment_offset, size_t fragment_length);
   void PacketizeFuA(size_t fragment_offset, size_t fragment_length);
   int PacketizeStapA(size_t fragment_index,
                      size_t fragment_offset,
                      size_t fragment_length);
   void NextAggregatePacket(uint8_t* buffer, size_t* bytes_to_send);
   void NextFragmentPacket(uint8_t* buffer, size_t* bytes_to_send);
 
   const uint8_t* payload_data_;