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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_format_h264.h

Issue 2871173008: Fix packetization logic to leave space for extensions in the last packet (Closed)
Patch Set: Impelement Danilchap@ comments Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_ 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_ 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_
13 13
14 #include <deque> 14 #include <deque>
15 #include <memory> 15 #include <memory>
16 #include <queue> 16 #include <queue>
17 #include <string> 17 #include <string>
18 18
19 #include "webrtc/base/buffer.h" 19 #include "webrtc/base/buffer.h"
20 #include "webrtc/base/constructormagic.h" 20 #include "webrtc/base/constructormagic.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 24
25 class RtpPacketizerH264 : public RtpPacketizer { 25 class RtpPacketizerH264 : public RtpPacketizer {
26 public: 26 public:
27 // Initialize with payload from encoder. 27 // Initialize with payload from encoder.
28 // The payload_data must be exactly one encoded H264 frame. 28 // The payload_data must be exactly one encoded H264 frame.
29 RtpPacketizerH264(size_t max_payload_len, 29 RtpPacketizerH264(size_t max_payload_len,
30 size_t last_packet_reduction_len,
30 H264PacketizationMode packetization_mode); 31 H264PacketizationMode packetization_mode);
31 32
32 virtual ~RtpPacketizerH264(); 33 virtual ~RtpPacketizerH264();
33 34
34 void SetPayloadData(const uint8_t* payload_data, 35 size_t SetPayloadData(const uint8_t* payload_data,
35 size_t payload_size, 36 size_t payload_size,
36 const RTPFragmentationHeader* fragmentation) override; 37 const RTPFragmentationHeader* fragmentation) override;
37 38
38 // Get the next payload with H264 payload header. 39 // Get the next payload with H264 payload header.
39 // Write payload and set marker bit of the |packet|. 40 // Write payload and set marker bit of the |packet|.
40 // The parameter |last_packet| is true for the last packet of the frame, false
41 // otherwise (i.e., call the function again to get the next packet).
42 // Returns true on success, false otherwise. 41 // Returns true on success, false otherwise.
43 bool NextPacket(RtpPacketToSend* rtp_packet, bool* last_packet) override; 42 bool NextPacket(RtpPacketToSend* rtp_packet) override;
44 43
45 ProtectionType GetProtectionType() override; 44 ProtectionType GetProtectionType() override;
46 45
47 StorageType GetStorageType(uint32_t retransmission_settings) override; 46 StorageType GetStorageType(uint32_t retransmission_settings) override;
48 47
49 std::string ToString() override; 48 std::string ToString() override;
50 49
51 private: 50 private:
52 // Input fragments (NAL units), with an optionally owned temporary buffer, 51 // Input fragments (NAL units), with an optionally owned temporary buffer,
53 // used in case the fragment gets modified. 52 // used in case the fragment gets modified.
(...skipping 27 matching lines...) Expand all
81 bool first_fragment; 80 bool first_fragment;
82 bool last_fragment; 81 bool last_fragment;
83 bool aggregated; 82 bool aggregated;
84 uint8_t header; 83 uint8_t header;
85 }; 84 };
86 85
87 void GeneratePackets(); 86 void GeneratePackets();
88 void PacketizeFuA(size_t fragment_index); 87 void PacketizeFuA(size_t fragment_index);
89 size_t PacketizeStapA(size_t fragment_index); 88 size_t PacketizeStapA(size_t fragment_index);
90 void PacketizeSingleNalu(size_t fragment_index); 89 void PacketizeSingleNalu(size_t fragment_index);
91 void NextAggregatePacket(RtpPacketToSend* rtp_packet); 90 void NextAggregatePacket(RtpPacketToSend* rtp_packet, bool last);
92 void NextFragmentPacket(RtpPacketToSend* rtp_packet); 91 void NextFragmentPacket(RtpPacketToSend* rtp_packet);
93 92
94 const size_t max_payload_len_; 93 const size_t max_payload_len_;
94 const size_t last_packet_reduction_len_;
95 size_t num_packets_left_;
95 const H264PacketizationMode packetization_mode_; 96 const H264PacketizationMode packetization_mode_;
96 std::deque<Fragment> input_fragments_; 97 std::deque<Fragment> input_fragments_;
97 std::queue<PacketUnit> packets_; 98 std::queue<PacketUnit> packets_;
98 99
99 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerH264); 100 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerH264);
100 }; 101 };
101 102
102 // Depacketizer for H264. 103 // Depacketizer for H264.
103 class RtpDepacketizerH264 : public RtpDepacketizer { 104 class RtpDepacketizerH264 : public RtpDepacketizer {
104 public: 105 public:
105 RtpDepacketizerH264(); 106 RtpDepacketizerH264();
106 virtual ~RtpDepacketizerH264(); 107 virtual ~RtpDepacketizerH264();
107 108
108 bool Parse(ParsedPayload* parsed_payload, 109 bool Parse(ParsedPayload* parsed_payload,
109 const uint8_t* payload_data, 110 const uint8_t* payload_data,
110 size_t payload_data_length) override; 111 size_t payload_data_length) override;
111 112
112 private: 113 private:
113 bool ParseFuaNalu(RtpDepacketizer::ParsedPayload* parsed_payload, 114 bool ParseFuaNalu(RtpDepacketizer::ParsedPayload* parsed_payload,
114 const uint8_t* payload_data); 115 const uint8_t* payload_data);
115 bool ProcessStapAOrSingleNalu(RtpDepacketizer::ParsedPayload* parsed_payload, 116 bool ProcessStapAOrSingleNalu(RtpDepacketizer::ParsedPayload* parsed_payload,
116 const uint8_t* payload_data); 117 const uint8_t* payload_data);
117 118
118 size_t offset_; 119 size_t offset_;
119 size_t length_; 120 size_t length_;
120 std::unique_ptr<rtc::Buffer> modified_buffer_; 121 std::unique_ptr<rtc::Buffer> modified_buffer_;
121 }; 122 };
122 } // namespace webrtc 123 } // namespace webrtc
123 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_ 124 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_format.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698