Index: webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc |
index b32e78ef9abee9f89e2f7a1ce742437af37468dc..553391d9786e75abeda3c2c879e1a360faa6327c 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc |
@@ -11,6 +11,7 @@ |
#include "webrtc/modules/rtp_rtcp/source/rtp_format_h264.h" |
#include <string.h> |
+ |
magjed_webrtc
2016/11/04 13:57:05
nit: revert this empty line
hta-webrtc
2016/11/09 09:27:10
Done.
|
#include <memory> |
#include <utility> |
#include <vector> |
@@ -77,9 +78,10 @@ bool ParseStapAStartOffsets(const uint8_t* nalu_ptr, |
} // namespace |
-RtpPacketizerH264::RtpPacketizerH264(FrameType frame_type, |
- size_t max_payload_len) |
- : max_payload_len_(max_payload_len) {} |
+RtpPacketizerH264::RtpPacketizerH264(size_t max_payload_len, |
+ H264PacketizationMode packetization_mode) |
+ : max_payload_len_(max_payload_len), |
+ packetization_mode_(packetization_mode) {} |
RtpPacketizerH264::~RtpPacketizerH264() { |
} |
@@ -162,11 +164,17 @@ void RtpPacketizerH264::SetPayloadData( |
void RtpPacketizerH264::GeneratePackets() { |
for (size_t i = 0; i < input_fragments_.size();) { |
- if (input_fragments_[i].length > max_payload_len_) { |
- PacketizeFuA(i); |
+ if (packetization_mode_ == kH264PacketizationMode0) { |
+ PacketizeSingleNalu(i); |
++i; |
} else { |
- i = PacketizeStapA(i); |
+ RTC_CHECK_EQ(packetization_mode_, kH264PacketizationMode1); |
+ if (input_fragments_[i].length > max_payload_len_) { |
+ PacketizeFuA(i); |
+ ++i; |
+ } else { |
+ i = PacketizeStapA(i); |
+ } |
} |
} |
} |
@@ -229,6 +237,16 @@ size_t RtpPacketizerH264::PacketizeStapA(size_t fragment_index) { |
return fragment_index; |
} |
+void RtpPacketizerH264::PacketizeSingleNalu(size_t fragment_index) { |
+ // Add a single NALU to the queue, no aggregation. |
+ size_t payload_size_left = max_payload_len_; |
+ const Fragment* fragment = &input_fragments_[fragment_index]; |
+ RTC_CHECK_GE(payload_size_left, fragment->length); |
+ RTC_CHECK_GT(fragment->length, 0u); |
+ packets_.push(PacketUnit(*fragment, true /* first */, true /* last */, |
+ false /* aggregated */, fragment->buffer[0])); |
+} |
+ |
bool RtpPacketizerH264::NextPacket(uint8_t* buffer, |
size_t* bytes_to_send, |
bool* last_packet) { |
@@ -249,9 +267,11 @@ bool RtpPacketizerH264::NextPacket(uint8_t* buffer, |
input_fragments_.pop_front(); |
RTC_CHECK_LE(*bytes_to_send, max_payload_len_); |
} else if (packet.aggregated) { |
+ RTC_CHECK_EQ(packetization_mode_, kH264PacketizationMode1); |
NextAggregatePacket(buffer, bytes_to_send); |
RTC_CHECK_LE(*bytes_to_send, max_payload_len_); |
} else { |
+ RTC_CHECK_EQ(packetization_mode_, kH264PacketizationMode1); |
NextFragmentPacket(buffer, bytes_to_send); |
RTC_CHECK_LE(*bytes_to_send, max_payload_len_); |
} |