Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc

Issue 2528343002: H.264 packetization mode 0 (try 3) (Closed)
Patch Set: Changed from enum to enum class Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d2c9a301896abe69705de540265d45a8c5857c30 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc
@@ -77,9 +77,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 +163,19 @@ 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);
- ++i;
- } else {
- i = PacketizeStapA(i);
+ switch (packetization_mode_) {
+ case H264PacketizationMode::SingleNalUnit:
+ PacketizeSingleNalu(i);
+ ++i;
+ break;
+ case H264PacketizationMode::NonInterleaved:
+ if (input_fragments_[i].length > max_payload_len_) {
+ PacketizeFuA(i);
+ ++i;
+ } else {
+ i = PacketizeStapA(i);
+ }
+ break;
hbos 2016/12/02 10:21:26 case default: RTC_NOTREACHED();
sprang_webrtc 2016/12/02 10:52:29 I disagree. If you have an enum class with all val
hbos 2016/12/02 11:04:45 Oh right, neat, no default!
hta-webrtc 2016/12/02 11:09:01 With an enum, it's better to leave the default off
}
}
}
@@ -229,6 +238,21 @@ 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)
+ << "Payload size left " << payload_size_left << ", fragment length "
+ << fragment->length << ", packetization mode "
+ << (packetization_mode_ == H264PacketizationMode::SingleNalUnit
+ ? "SingleNalUnit"
+ : "NonInterleaved");
+ 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 +273,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(packetization_mode_ == H264PacketizationMode::NonInterleaved);
hbos 2016/12/02 10:21:26 nit: RTC_CHECK_EQ
hta-webrtc 2016/12/02 11:09:01 I tried. The RTC_CHECK_EQ macro borks on "enum cla
hbos 2016/12/02 11:58:42 Acknowledged.
NextAggregatePacket(buffer, bytes_to_send);
RTC_CHECK_LE(*bytes_to_send, max_payload_len_);
} else {
+ RTC_CHECK(packetization_mode_ == H264PacketizationMode::NonInterleaved);
NextFragmentPacket(buffer, bytes_to_send);
RTC_CHECK_LE(*bytes_to_send, max_payload_len_);
}

Powered by Google App Engine
This is Rietveld 408576698