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