OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
(...skipping 94 matching lines...) Loading... |
105 int8_t payload_type, | 105 int8_t payload_type, |
106 uint32_t timestamp, | 106 uint32_t timestamp, |
107 int64_t capture_time_ms, | 107 int64_t capture_time_ms, |
108 const uint8_t* payload_data, | 108 const uint8_t* payload_data, |
109 size_t payload_size, | 109 size_t payload_size, |
110 const RTPFragmentationHeader* fragmentation, | 110 const RTPFragmentationHeader* fragmentation, |
111 const RTPVideoHeader* rtp_header, | 111 const RTPVideoHeader* rtp_header, |
112 uint32_t* transport_frame_id_out); | 112 uint32_t* transport_frame_id_out); |
113 | 113 |
114 // RTP header extension | 114 // RTP header extension |
115 int32_t SetTransmissionTimeOffset(int32_t transmission_time_offset); | |
116 int32_t SetAbsoluteSendTime(uint32_t absolute_send_time); | |
117 void SetVideoRotation(VideoRotation rotation); | |
118 int32_t SetTransportSequenceNumber(uint16_t sequence_number); | |
119 | |
120 int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id); | 115 int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id); |
121 bool IsRtpHeaderExtensionRegistered(RTPExtensionType type); | 116 bool IsRtpHeaderExtensionRegistered(RTPExtensionType type); |
122 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type); | 117 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type); |
123 | 118 |
124 size_t RtpHeaderExtensionLength() const; | 119 size_t RtpHeaderExtensionLength() const; |
125 | 120 |
126 uint16_t BuildRtpHeaderExtension(uint8_t* data_buffer, bool marker_bit) const | |
127 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
128 | |
129 uint8_t BuildTransmissionTimeOffsetExtension(uint8_t* data_buffer) const | |
130 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
131 uint8_t BuildAudioLevelExtension(uint8_t* data_buffer) const | |
132 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
133 uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const | |
134 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
135 uint8_t BuildVideoRotationExtension(uint8_t* data_buffer) const | |
136 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
137 uint8_t BuildTransportSequenceNumberExtension(uint8_t* data_buffer, | |
138 uint16_t sequence_number) const | |
139 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
140 uint8_t BuildPlayoutDelayExtension(uint8_t* data_buffer, | |
141 uint16_t min_playout_delay_ms, | |
142 uint16_t max_playout_delay_ms) const | |
143 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
144 | |
145 // Verifies that the specified extension is registered, and that it is | |
146 // present in rtp packet. If extension is not registered kNotRegistered is | |
147 // returned. If extension cannot be found in the rtp header, or if it is | |
148 // malformed, kError is returned. Otherwise *extension_offset is set to the | |
149 // offset of the extension from the beginning of the rtp packet and kOk is | |
150 // returned. | |
151 enum class ExtensionStatus { | |
152 kNotRegistered, | |
153 kOk, | |
154 kError, | |
155 }; | |
156 ExtensionStatus VerifyExtension(RTPExtensionType extension_type, | |
157 uint8_t* rtp_packet, | |
158 size_t rtp_packet_length, | |
159 const RTPHeader& rtp_header, | |
160 size_t extension_length_bytes, | |
161 size_t* extension_offset) const | |
162 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
163 | |
164 bool UpdateAudioLevel(uint8_t* rtp_packet, | |
165 size_t rtp_packet_length, | |
166 const RTPHeader& rtp_header, | |
167 bool is_voiced, | |
168 uint8_t dBov) const; | |
169 | |
170 bool UpdateVideoRotation(uint8_t* rtp_packet, | |
171 size_t rtp_packet_length, | |
172 const RTPHeader& rtp_header, | |
173 VideoRotation rotation) const; | |
174 | |
175 bool TimeToSendPacket(uint16_t sequence_number, | 121 bool TimeToSendPacket(uint16_t sequence_number, |
176 int64_t capture_time_ms, | 122 int64_t capture_time_ms, |
177 bool retransmission, | 123 bool retransmission, |
178 int probe_cluster_id); | 124 int probe_cluster_id); |
179 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id); | 125 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id); |
180 | 126 |
181 // NACK. | 127 // NACK. |
182 int SelectiveRetransmissions() const; | 128 int SelectiveRetransmissions() const; |
183 int SetSelectiveRetransmissions(uint8_t settings); | 129 int SetSelectiveRetransmissions(uint8_t settings); |
184 void OnReceivedNack(const std::vector<uint16_t>& nack_sequence_numbers, | 130 void OnReceivedNack(const std::vector<uint16_t>& nack_sequence_numbers, |
(...skipping 18 matching lines...) Loading... |
203 void SetRtxPayloadType(int payload_type, int associated_payload_type); | 149 void SetRtxPayloadType(int payload_type, int associated_payload_type); |
204 | 150 |
205 // Create empty packet, fills ssrc, csrcs and reserve place for header | 151 // Create empty packet, fills ssrc, csrcs and reserve place for header |
206 // extensions RtpSender updates before sending. | 152 // extensions RtpSender updates before sending. |
207 std::unique_ptr<RtpPacketToSend> AllocatePacket() const; | 153 std::unique_ptr<RtpPacketToSend> AllocatePacket() const; |
208 // Allocate sequence number for provided packet. | 154 // Allocate sequence number for provided packet. |
209 // Save packet's fields to generate padding that doesn't break media stream. | 155 // Save packet's fields to generate padding that doesn't break media stream. |
210 // Return false if sending was turned off. | 156 // Return false if sending was turned off. |
211 bool AssignSequenceNumber(RtpPacketToSend* packet); | 157 bool AssignSequenceNumber(RtpPacketToSend* packet); |
212 | 158 |
213 // Functions wrapping RTPSenderInterface. | |
214 int32_t BuildRTPheader(uint8_t* data_buffer, | |
215 int8_t payload_type, | |
216 bool marker_bit, | |
217 uint32_t capture_timestamp, | |
218 int64_t capture_time_ms, | |
219 bool timestamp_provided = true, | |
220 bool inc_sequence_number = true); | |
221 int32_t BuildRtpHeader(uint8_t* data_buffer, | |
222 int8_t payload_type, | |
223 bool marker_bit, | |
224 uint32_t capture_timestamp, | |
225 int64_t capture_time_ms); | |
226 | |
227 size_t RtpHeaderLength() const; | 159 size_t RtpHeaderLength() const; |
228 uint16_t AllocateSequenceNumber(uint16_t packets_to_send); | 160 uint16_t AllocateSequenceNumber(uint16_t packets_to_send); |
229 size_t MaxPayloadLength() const; | 161 size_t MaxPayloadLength() const; |
230 | 162 |
231 uint32_t SSRC() const; | 163 uint32_t SSRC() const; |
232 | 164 |
233 // Deprecated. Create RtpPacketToSend instead and use next function. | |
234 bool SendToNetwork(uint8_t* data_buffer, | |
235 size_t payload_length, | |
236 size_t rtp_header_length, | |
237 int64_t capture_time_ms, | |
238 StorageType storage, | |
239 RtpPacketSender::Priority priority); | |
240 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, | 165 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, |
241 StorageType storage, | 166 StorageType storage, |
242 RtpPacketSender::Priority priority); | 167 RtpPacketSender::Priority priority); |
243 | 168 |
244 // Audio. | 169 // Audio. |
245 | 170 |
246 // Send a DTMF tone using RFC 2833 (4733). | 171 // Send a DTMF tone using RFC 2833 (4733). |
247 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); | 172 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); |
248 | 173 |
249 // Set audio packet size, used to determine when it's time to send a DTMF | 174 // Set audio packet size, used to determine when it's time to send a DTMF |
(...skipping 48 matching lines...) Loading... |
298 typedef std::map<int64_t, int> SendDelayMap; | 223 typedef std::map<int64_t, int> SendDelayMap; |
299 | 224 |
300 size_t SendPadData(size_t bytes, int probe_cluster_id); | 225 size_t SendPadData(size_t bytes, int probe_cluster_id); |
301 | 226 |
302 size_t DeprecatedSendPadData(size_t bytes, | 227 size_t DeprecatedSendPadData(size_t bytes, |
303 bool timestamp_provided, | 228 bool timestamp_provided, |
304 uint32_t timestamp, | 229 uint32_t timestamp, |
305 int64_t capture_time_ms, | 230 int64_t capture_time_ms, |
306 int probe_cluster_id); | 231 int probe_cluster_id); |
307 | 232 |
308 size_t CreateRtpHeader(uint8_t* header, | |
309 int8_t payload_type, | |
310 uint32_t ssrc, | |
311 bool marker_bit, | |
312 uint32_t timestamp, | |
313 uint16_t sequence_number, | |
314 const std::vector<uint32_t>& csrcs) const | |
315 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
316 | |
317 bool PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet, | 233 bool PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet, |
318 bool send_over_rtx, | 234 bool send_over_rtx, |
319 bool is_retransmit, | 235 bool is_retransmit, |
320 int probe_cluster_id); | 236 int probe_cluster_id); |
321 | 237 |
322 // Return the number of bytes sent. Note that both of these functions may | 238 // Return the number of bytes sent. Note that both of these functions may |
323 // return a larger value that their argument. | 239 // return a larger value that their argument. |
324 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id); | 240 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id); |
325 | 241 |
326 std::unique_ptr<RtpPacketToSend> BuildRtxPacket( | 242 std::unique_ptr<RtpPacketToSend> BuildRtxPacket( |
(...skipping 46 matching lines...) Loading... |
373 | 289 |
374 Transport *transport_; | 290 Transport *transport_; |
375 bool sending_media_ GUARDED_BY(send_critsect_); | 291 bool sending_media_ GUARDED_BY(send_critsect_); |
376 | 292 |
377 size_t max_payload_length_; | 293 size_t max_payload_length_; |
378 | 294 |
379 int8_t payload_type_ GUARDED_BY(send_critsect_); | 295 int8_t payload_type_ GUARDED_BY(send_critsect_); |
380 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; | 296 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; |
381 | 297 |
382 RtpHeaderExtensionMap rtp_header_extension_map_ GUARDED_BY(send_critsect_); | 298 RtpHeaderExtensionMap rtp_header_extension_map_ GUARDED_BY(send_critsect_); |
383 int32_t transmission_time_offset_; | |
384 uint32_t absolute_send_time_; | |
385 VideoRotation rotation_; | |
386 bool video_rotation_active_; | 299 bool video_rotation_active_; |
387 uint16_t transport_sequence_number_; | |
388 | 300 |
389 // Tracks the current request for playout delay limits from application | 301 // Tracks the current request for playout delay limits from application |
390 // and decides whether the current RTP frame should include the playout | 302 // and decides whether the current RTP frame should include the playout |
391 // delay extension on header. | 303 // delay extension on header. |
392 PlayoutDelayOracle playout_delay_oracle_; | 304 PlayoutDelayOracle playout_delay_oracle_; |
393 bool playout_delay_active_ GUARDED_BY(send_critsect_); | 305 bool playout_delay_active_ GUARDED_BY(send_critsect_); |
394 | 306 |
395 RtpPacketHistory packet_history_; | 307 RtpPacketHistory packet_history_; |
396 | 308 |
397 // Statistics | 309 // Statistics |
(...skipping 32 matching lines...) Loading... |
430 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); | 342 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); |
431 | 343 |
432 RateLimiter* const retransmission_rate_limiter_; | 344 RateLimiter* const retransmission_rate_limiter_; |
433 | 345 |
434 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); | 346 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); |
435 }; | 347 }; |
436 | 348 |
437 } // namespace webrtc | 349 } // namespace webrtc |
438 | 350 |
439 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 351 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
OLD | NEW |