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 17 matching lines...) Expand all Loading... |
28 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
32 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" | 32 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" |
33 #include "webrtc/transport.h" | 33 #include "webrtc/transport.h" |
34 | 34 |
35 namespace webrtc { | 35 namespace webrtc { |
36 | 36 |
37 class RateLimiter; | 37 class RateLimiter; |
| 38 class RtcEventLog; |
| 39 class RtpPacketToSend; |
38 class RTPSenderAudio; | 40 class RTPSenderAudio; |
39 class RTPSenderVideo; | 41 class RTPSenderVideo; |
40 class RtcEventLog; | |
41 | 42 |
42 class RTPSenderInterface { | 43 class RTPSenderInterface { |
43 public: | 44 public: |
44 RTPSenderInterface() {} | 45 RTPSenderInterface() {} |
45 virtual ~RTPSenderInterface() {} | 46 virtual ~RTPSenderInterface() {} |
46 | 47 |
47 virtual uint32_t SSRC() const = 0; | 48 virtual uint32_t SSRC() const = 0; |
48 virtual uint32_t Timestamp() const = 0; | 49 virtual uint32_t Timestamp() const = 0; |
49 | 50 |
50 // Deprecated version of BuildRtpHeader(). |timestamp_provided| and | 51 // Deprecated version of BuildRtpHeader(). |timestamp_provided| and |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 int64_t capture_time_ms) override; | 271 int64_t capture_time_ms) override; |
271 | 272 |
272 size_t RtpHeaderLength() const override; | 273 size_t RtpHeaderLength() const override; |
273 uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override; | 274 uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override; |
274 size_t MaxPayloadLength() const override; | 275 size_t MaxPayloadLength() const override; |
275 | 276 |
276 // Current timestamp. | 277 // Current timestamp. |
277 uint32_t Timestamp() const override; | 278 uint32_t Timestamp() const override; |
278 uint32_t SSRC() const override; | 279 uint32_t SSRC() const override; |
279 | 280 |
| 281 // Deprecated. Create RtpPacketToSend instead and use next function. |
280 bool SendToNetwork(uint8_t* data_buffer, | 282 bool SendToNetwork(uint8_t* data_buffer, |
281 size_t payload_length, | 283 size_t payload_length, |
282 size_t rtp_header_length, | 284 size_t rtp_header_length, |
283 int64_t capture_time_ms, | 285 int64_t capture_time_ms, |
284 StorageType storage, | 286 StorageType storage, |
285 RtpPacketSender::Priority priority) override; | 287 RtpPacketSender::Priority priority) override; |
| 288 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, |
| 289 StorageType storage, |
| 290 RtpPacketSender::Priority priority); |
286 | 291 |
287 // Audio. | 292 // Audio. |
288 | 293 |
289 // Send a DTMF tone using RFC 2833 (4733). | 294 // Send a DTMF tone using RFC 2833 (4733). |
290 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); | 295 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); |
291 | 296 |
292 // Set audio packet size, used to determine when it's time to send a DTMF | 297 // Set audio packet size, used to determine when it's time to send a DTMF |
293 // packet in silence (CNG). | 298 // packet in silence (CNG). |
294 int32_t SetAudioPacketSize(uint16_t packet_size_samples); | 299 int32_t SetAudioPacketSize(uint16_t packet_size_samples); |
295 | 300 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 357 |
353 size_t CreateRtpHeader(uint8_t* header, | 358 size_t CreateRtpHeader(uint8_t* header, |
354 int8_t payload_type, | 359 int8_t payload_type, |
355 uint32_t ssrc, | 360 uint32_t ssrc, |
356 bool marker_bit, | 361 bool marker_bit, |
357 uint32_t timestamp, | 362 uint32_t timestamp, |
358 uint16_t sequence_number, | 363 uint16_t sequence_number, |
359 const std::vector<uint32_t>& csrcs) const | 364 const std::vector<uint32_t>& csrcs) const |
360 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | 365 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); |
361 | 366 |
362 bool PrepareAndSendPacket(uint8_t* buffer, | 367 bool PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet, |
363 size_t length, | |
364 int64_t capture_time_ms, | |
365 bool send_over_rtx, | 368 bool send_over_rtx, |
366 bool is_retransmit, | 369 bool is_retransmit, |
367 int probe_cluster_id); | 370 int probe_cluster_id); |
368 | 371 |
369 // Return the number of bytes sent. Note that both of these functions may | 372 // Return the number of bytes sent. Note that both of these functions may |
370 // return a larger value that their argument. | 373 // return a larger value that their argument. |
371 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id); | 374 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id); |
372 | 375 |
373 void BuildPaddingPacket(uint8_t* packet, | 376 std::unique_ptr<RtpPacketToSend> BuildRtxPacket( |
374 size_t header_length, | 377 const RtpPacketToSend& packet); |
375 size_t padding_length); | |
376 | 378 |
377 bool BuildRtxPacket(uint8_t* buffer, size_t* length, uint8_t* buffer_rtx); | 379 bool SendPacketToNetwork(const RtpPacketToSend& packet, |
378 | |
379 bool SendPacketToNetwork(const uint8_t* packet, | |
380 size_t size, | |
381 const PacketOptions& options); | 380 const PacketOptions& options); |
382 | 381 |
383 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); | 382 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); |
384 void UpdateOnSendPacket(int packet_id, | 383 void UpdateOnSendPacket(int packet_id, |
385 int64_t capture_time_ms, | 384 int64_t capture_time_ms, |
386 uint32_t ssrc); | 385 uint32_t ssrc); |
387 | 386 |
388 // Find the byte position of the RTP extension as indicated by |type| in | 387 // Find the byte position of the RTP extension as indicated by |type| in |
389 // |rtp_packet|. Return false if such extension doesn't exist. | 388 // |rtp_packet|. Return false if such extension doesn't exist. |
390 bool FindHeaderExtensionPosition(RTPExtensionType type, | 389 bool FindHeaderExtensionPosition(RTPExtensionType type, |
391 const uint8_t* rtp_packet, | 390 const uint8_t* rtp_packet, |
392 size_t rtp_packet_length, | 391 size_t rtp_packet_length, |
393 const RTPHeader& rtp_header, | 392 const RTPHeader& rtp_header, |
394 size_t* position) const | 393 size_t* position) const |
395 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | 394 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); |
396 | 395 |
397 void UpdateTransmissionTimeOffset(uint8_t* rtp_packet, | 396 bool UpdateTransportSequenceNumber(RtpPacketToSend* packet, |
398 size_t rtp_packet_length, | 397 int* packet_id) const; |
399 const RTPHeader& rtp_header, | |
400 int64_t time_diff_ms) const; | |
401 void UpdateAbsoluteSendTime(uint8_t* rtp_packet, | |
402 size_t rtp_packet_length, | |
403 const RTPHeader& rtp_header, | |
404 int64_t now_ms) const; | |
405 | |
406 bool UpdateTransportSequenceNumber(uint8_t* rtp_packet, | |
407 size_t rtp_packet_length, | |
408 const RTPHeader& rtp_header, | |
409 int* sequence_number) const; | |
410 | 398 |
411 void UpdatePlayoutDelayLimits(uint8_t* rtp_packet, | 399 void UpdatePlayoutDelayLimits(uint8_t* rtp_packet, |
412 size_t rtp_packet_length, | 400 size_t rtp_packet_length, |
413 const RTPHeader& rtp_header, | 401 const RTPHeader& rtp_header, |
414 uint16_t min_playout_delay, | 402 uint16_t min_playout_delay, |
415 uint16_t max_playout_delay) const; | 403 uint16_t max_playout_delay) const; |
416 | 404 |
417 bool AllocateTransportSequenceNumber(int* packet_id) const; | 405 void UpdateRtpStats(const RtpPacketToSend& packet, |
418 | |
419 void UpdateRtpStats(const uint8_t* buffer, | |
420 size_t packet_length, | |
421 const RTPHeader& header, | |
422 bool is_rtx, | 406 bool is_rtx, |
423 bool is_retransmit); | 407 bool is_retransmit); |
424 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; | 408 bool IsFecPacket(const RtpPacketToSend& packet) const; |
425 | 409 |
426 Clock* const clock_; | 410 Clock* const clock_; |
427 const int64_t clock_delta_ms_; | 411 const int64_t clock_delta_ms_; |
428 Random random_ GUARDED_BY(send_critsect_); | 412 Random random_ GUARDED_BY(send_critsect_); |
429 | 413 |
430 const bool audio_configured_; | 414 const bool audio_configured_; |
431 const std::unique_ptr<RTPSenderAudio> audio_; | 415 const std::unique_ptr<RTPSenderAudio> audio_; |
432 const std::unique_ptr<RTPSenderVideo> video_; | 416 const std::unique_ptr<RTPSenderVideo> video_; |
433 | 417 |
434 RtpPacketSender* const paced_sender_; | 418 RtpPacketSender* const paced_sender_; |
(...skipping 16 matching lines...) Expand all Loading... |
451 VideoRotation rotation_; | 435 VideoRotation rotation_; |
452 bool video_rotation_active_; | 436 bool video_rotation_active_; |
453 uint16_t transport_sequence_number_; | 437 uint16_t transport_sequence_number_; |
454 | 438 |
455 // Tracks the current request for playout delay limits from application | 439 // Tracks the current request for playout delay limits from application |
456 // and decides whether the current RTP frame should include the playout | 440 // and decides whether the current RTP frame should include the playout |
457 // delay extension on header. | 441 // delay extension on header. |
458 PlayoutDelayOracle playout_delay_oracle_; | 442 PlayoutDelayOracle playout_delay_oracle_; |
459 bool playout_delay_active_ GUARDED_BY(send_critsect_); | 443 bool playout_delay_active_ GUARDED_BY(send_critsect_); |
460 | 444 |
461 RTPPacketHistory packet_history_; | 445 RtpPacketHistory packet_history_; |
462 | 446 |
463 // Statistics | 447 // Statistics |
464 rtc::CriticalSection statistics_crit_; | 448 rtc::CriticalSection statistics_crit_; |
465 SendDelayMap send_delays_ GUARDED_BY(statistics_crit_); | 449 SendDelayMap send_delays_ GUARDED_BY(statistics_crit_); |
466 FrameCounts frame_counts_ GUARDED_BY(statistics_crit_); | 450 FrameCounts frame_counts_ GUARDED_BY(statistics_crit_); |
467 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); | 451 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); |
468 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); | 452 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); |
469 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); | 453 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); |
470 RateStatistics total_bitrate_sent_ GUARDED_BY(statistics_crit_); | 454 RateStatistics total_bitrate_sent_ GUARDED_BY(statistics_crit_); |
471 RateStatistics nack_bitrate_sent_ GUARDED_BY(statistics_crit_); | 455 RateStatistics nack_bitrate_sent_ GUARDED_BY(statistics_crit_); |
(...skipping 25 matching lines...) Expand all Loading... |
497 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); | 481 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); |
498 | 482 |
499 RateLimiter* const retransmission_rate_limiter_; | 483 RateLimiter* const retransmission_rate_limiter_; |
500 | 484 |
501 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); | 485 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); |
502 }; | 486 }; |
503 | 487 |
504 } // namespace webrtc | 488 } // namespace webrtc |
505 | 489 |
506 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 490 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
OLD | NEW |