OLD | NEW |
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(FrameType frame_type, size_t max_payload_len); | 29 RtpPacketizerH264(size_t max_payload_len, |
| 30 H264PacketizationMode packetization_mode); |
30 | 31 |
31 virtual ~RtpPacketizerH264(); | 32 virtual ~RtpPacketizerH264(); |
32 | 33 |
33 void SetPayloadData(const uint8_t* payload_data, | 34 void SetPayloadData(const uint8_t* payload_data, |
34 size_t payload_size, | 35 size_t payload_size, |
35 const RTPFragmentationHeader* fragmentation) override; | 36 const RTPFragmentationHeader* fragmentation) override; |
36 | 37 |
37 // Get the next payload with H264 payload header. | 38 // Get the next payload with H264 payload header. |
38 // Write payload and set marker bit of the |packet|. | 39 // Write payload and set marker bit of the |packet|. |
39 // The parameter |last_packet| is true for the last packet of the frame, false | 40 // The parameter |last_packet| is true for the last packet of the frame, false |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const Fragment source_fragment; | 80 const Fragment source_fragment; |
80 bool first_fragment; | 81 bool first_fragment; |
81 bool last_fragment; | 82 bool last_fragment; |
82 bool aggregated; | 83 bool aggregated; |
83 uint8_t header; | 84 uint8_t header; |
84 }; | 85 }; |
85 | 86 |
86 void GeneratePackets(); | 87 void GeneratePackets(); |
87 void PacketizeFuA(size_t fragment_index); | 88 void PacketizeFuA(size_t fragment_index); |
88 size_t PacketizeStapA(size_t fragment_index); | 89 size_t PacketizeStapA(size_t fragment_index); |
| 90 void PacketizeSingleNalu(size_t fragment_index); |
89 void NextAggregatePacket(RtpPacketToSend* rtp_packet); | 91 void NextAggregatePacket(RtpPacketToSend* rtp_packet); |
90 void NextFragmentPacket(RtpPacketToSend* rtp_packet); | 92 void NextFragmentPacket(RtpPacketToSend* rtp_packet); |
91 | 93 |
92 const size_t max_payload_len_; | 94 const size_t max_payload_len_; |
| 95 const H264PacketizationMode packetization_mode_; |
93 std::deque<Fragment> input_fragments_; | 96 std::deque<Fragment> input_fragments_; |
94 std::queue<PacketUnit> packets_; | 97 std::queue<PacketUnit> packets_; |
95 | 98 |
96 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerH264); | 99 RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerH264); |
97 }; | 100 }; |
98 | 101 |
99 // Depacketizer for H264. | 102 // Depacketizer for H264. |
100 class RtpDepacketizerH264 : public RtpDepacketizer { | 103 class RtpDepacketizerH264 : public RtpDepacketizer { |
101 public: | 104 public: |
102 RtpDepacketizerH264(); | 105 RtpDepacketizerH264(); |
103 virtual ~RtpDepacketizerH264(); | 106 virtual ~RtpDepacketizerH264(); |
104 | 107 |
105 bool Parse(ParsedPayload* parsed_payload, | 108 bool Parse(ParsedPayload* parsed_payload, |
106 const uint8_t* payload_data, | 109 const uint8_t* payload_data, |
107 size_t payload_data_length) override; | 110 size_t payload_data_length) override; |
108 | 111 |
109 private: | 112 private: |
110 bool ParseFuaNalu(RtpDepacketizer::ParsedPayload* parsed_payload, | 113 bool ParseFuaNalu(RtpDepacketizer::ParsedPayload* parsed_payload, |
111 const uint8_t* payload_data); | 114 const uint8_t* payload_data); |
112 bool ProcessStapAOrSingleNalu(RtpDepacketizer::ParsedPayload* parsed_payload, | 115 bool ProcessStapAOrSingleNalu(RtpDepacketizer::ParsedPayload* parsed_payload, |
113 const uint8_t* payload_data); | 116 const uint8_t* payload_data); |
114 | 117 |
115 size_t offset_; | 118 size_t offset_; |
116 size_t length_; | 119 size_t length_; |
117 std::unique_ptr<rtc::Buffer> modified_buffer_; | 120 std::unique_ptr<rtc::Buffer> modified_buffer_; |
118 }; | 121 }; |
119 } // namespace webrtc | 122 } // namespace webrtc |
120 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_ | 123 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_H264_H_ |
OLD | NEW |