Chromium Code Reviews| 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 |
| 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <utility> | 16 #include <utility> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/base/criticalsection.h" | |
| 19 #include "webrtc/base/random.h" | 20 #include "webrtc/base/random.h" |
| 20 #include "webrtc/base/thread_annotations.h" | 21 #include "webrtc/base/thread_annotations.h" |
| 21 #include "webrtc/common_types.h" | 22 #include "webrtc/common_types.h" |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" | 24 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
| 25 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" |
| 26 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
| 27 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 28 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" | 29 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" |
| 29 #include "webrtc/transport.h" | 30 #include "webrtc/transport.h" |
| 30 | 31 |
| 31 namespace webrtc { | 32 namespace webrtc { |
| 32 | 33 |
| 33 class BitrateAggregator; | |
| 34 class CriticalSectionWrapper; | |
| 35 class RTPSenderAudio; | 34 class RTPSenderAudio; |
| 36 class RTPSenderVideo; | 35 class RTPSenderVideo; |
| 37 class RtcEventLog; | 36 class RtcEventLog; |
| 38 | 37 |
| 38 class BitrateAggregator { | |
|
the sun
2016/01/25 11:24:57
Make internal to RTPSender or put in its own .h/.c
tommi
2016/01/25 12:28:33
Made internal to RTPSender.
| |
| 39 public: | |
| 40 explicit BitrateAggregator(BitrateStatisticsObserver* bitrate_callback); | |
| 41 | |
| 42 void OnStatsUpdated() const; | |
| 43 | |
| 44 Bitrate::Observer* total_bitrate_observer(); | |
| 45 Bitrate::Observer* retransmit_bitrate_observer(); | |
| 46 void set_ssrc(uint32_t ssrc); | |
| 47 | |
| 48 private: | |
| 49 // We assume that these observers are called on the same thread, which is | |
| 50 // true for RtpSender as they are called on the Process thread. | |
| 51 class BitrateObserver : public Bitrate::Observer { | |
| 52 public: | |
| 53 explicit BitrateObserver(const BitrateAggregator& aggregator); | |
| 54 | |
| 55 // Implements Bitrate::Observer. | |
| 56 void BitrateUpdated(const BitrateStatistics& stats) override; | |
| 57 BitrateStatistics statistics() const; | |
| 58 | |
| 59 private: | |
| 60 BitrateStatistics statistics_; | |
| 61 const BitrateAggregator& aggregator_; | |
| 62 }; | |
| 63 | |
| 64 BitrateStatisticsObserver* const callback_; | |
| 65 BitrateObserver total_bitrate_observer_; | |
| 66 BitrateObserver retransmit_bitrate_observer_; | |
| 67 uint32_t ssrc_; | |
| 68 }; | |
| 69 | |
| 39 class RTPSenderInterface { | 70 class RTPSenderInterface { |
| 40 public: | 71 public: |
| 41 RTPSenderInterface() {} | 72 RTPSenderInterface() {} |
| 42 virtual ~RTPSenderInterface() {} | 73 virtual ~RTPSenderInterface() {} |
| 43 | 74 |
| 44 enum CVOMode { | 75 enum CVOMode { |
| 45 kCVONone, | 76 kCVONone, |
| 46 kCVOInactive, // CVO rtp header extension is registered but haven't | 77 kCVOInactive, // CVO rtp header extension is registered but haven't |
| 47 // received any frame with rotation pending. | 78 // received any frame with rotation pending. |
| 48 kCVOActivated, // CVO rtp header extension will be present in the rtp | 79 kCVOActivated, // CVO rtp header extension will be present in the rtp |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 RTPSender(bool audio, | 122 RTPSender(bool audio, |
| 92 Clock* clock, | 123 Clock* clock, |
| 93 Transport* transport, | 124 Transport* transport, |
| 94 RtpAudioFeedback* audio_feedback, | 125 RtpAudioFeedback* audio_feedback, |
| 95 RtpPacketSender* paced_sender, | 126 RtpPacketSender* paced_sender, |
| 96 TransportSequenceNumberAllocator* sequence_number_allocator, | 127 TransportSequenceNumberAllocator* sequence_number_allocator, |
| 97 TransportFeedbackObserver* transport_feedback_callback, | 128 TransportFeedbackObserver* transport_feedback_callback, |
| 98 BitrateStatisticsObserver* bitrate_callback, | 129 BitrateStatisticsObserver* bitrate_callback, |
| 99 FrameCountObserver* frame_count_observer, | 130 FrameCountObserver* frame_count_observer, |
| 100 SendSideDelayObserver* send_side_delay_observer, | 131 SendSideDelayObserver* send_side_delay_observer, |
| 101 RtcEventLog* event_log); | 132 RtcEventLog* event_log, |
| 133 SSRCDatabase* ssrc_database); | |
| 102 virtual ~RTPSender(); | 134 virtual ~RTPSender(); |
| 103 | 135 |
| 104 void ProcessBitrate(); | 136 void ProcessBitrate(); |
| 105 | 137 |
| 106 uint16_t ActualSendBitrateKbit() const override; | 138 uint16_t ActualSendBitrateKbit() const override; |
| 107 | 139 |
| 108 uint32_t VideoBitrateSent() const; | 140 uint32_t VideoBitrateSent() const; |
| 109 uint32_t FecOverheadRate() const; | 141 uint32_t FecOverheadRate() const; |
| 110 uint32_t NackOverheadRate() const; | 142 uint32_t NackOverheadRate() const; |
| 111 | 143 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 kNotRegistered, | 221 kNotRegistered, |
| 190 kOk, | 222 kOk, |
| 191 kError, | 223 kError, |
| 192 }; | 224 }; |
| 193 ExtensionStatus VerifyExtension(RTPExtensionType extension_type, | 225 ExtensionStatus VerifyExtension(RTPExtensionType extension_type, |
| 194 uint8_t* rtp_packet, | 226 uint8_t* rtp_packet, |
| 195 size_t rtp_packet_length, | 227 size_t rtp_packet_length, |
| 196 const RTPHeader& rtp_header, | 228 const RTPHeader& rtp_header, |
| 197 size_t extension_length_bytes, | 229 size_t extension_length_bytes, |
| 198 size_t* extension_offset) const | 230 size_t* extension_offset) const |
| 199 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_.get()); | 231 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); |
| 200 | 232 |
| 201 bool UpdateAudioLevel(uint8_t* rtp_packet, | 233 bool UpdateAudioLevel(uint8_t* rtp_packet, |
| 202 size_t rtp_packet_length, | 234 size_t rtp_packet_length, |
| 203 const RTPHeader& rtp_header, | 235 const RTPHeader& rtp_header, |
| 204 bool is_voiced, | 236 bool is_voiced, |
| 205 uint8_t dBov) const; | 237 uint8_t dBov) const; |
| 206 | 238 |
| 207 bool UpdateVideoRotation(uint8_t* rtp_packet, | 239 bool UpdateVideoRotation(uint8_t* rtp_packet, |
| 208 size_t rtp_packet_length, | 240 size_t rtp_packet_length, |
| 209 const RTPHeader& rtp_header, | 241 const RTPHeader& rtp_header, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 size_t rtp_packet_length, | 411 size_t rtp_packet_length, |
| 380 const RTPHeader& rtp_header) const; | 412 const RTPHeader& rtp_header) const; |
| 381 | 413 |
| 382 void UpdateRtpStats(const uint8_t* buffer, | 414 void UpdateRtpStats(const uint8_t* buffer, |
| 383 size_t packet_length, | 415 size_t packet_length, |
| 384 const RTPHeader& header, | 416 const RTPHeader& header, |
| 385 bool is_rtx, | 417 bool is_rtx, |
| 386 bool is_retransmit); | 418 bool is_retransmit); |
| 387 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; | 419 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; |
| 388 | 420 |
| 389 Clock* clock_; | 421 Clock* const clock_; |
| 390 int64_t clock_delta_ms_; | 422 const int64_t clock_delta_ms_; |
| 391 Random random_ GUARDED_BY(send_critsect_); | 423 Random random_ GUARDED_BY(send_critsect_); |
| 392 | 424 |
| 393 rtc::scoped_ptr<BitrateAggregator> bitrates_; | 425 BitrateAggregator bitrates_; |
| 394 Bitrate total_bitrate_sent_; | 426 Bitrate total_bitrate_sent_; |
| 395 | 427 |
| 396 const bool audio_configured_; | 428 const bool audio_configured_; |
| 397 rtc::scoped_ptr<RTPSenderAudio> audio_; | 429 const rtc::scoped_ptr<RTPSenderAudio> audio_; |
| 398 rtc::scoped_ptr<RTPSenderVideo> video_; | 430 const rtc::scoped_ptr<RTPSenderVideo> video_; |
| 399 | 431 |
| 400 RtpPacketSender* const paced_sender_; | 432 RtpPacketSender* const paced_sender_; |
| 401 TransportSequenceNumberAllocator* const transport_sequence_number_allocator_; | 433 TransportSequenceNumberAllocator* const transport_sequence_number_allocator_; |
| 402 TransportFeedbackObserver* const transport_feedback_observer_; | 434 TransportFeedbackObserver* const transport_feedback_observer_; |
| 403 int64_t last_capture_time_ms_sent_; | 435 int64_t last_capture_time_ms_sent_; |
| 404 rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_; | 436 rtc::CriticalSection send_critsect_; |
| 405 | 437 |
| 406 Transport *transport_; | 438 Transport *transport_; |
| 407 bool sending_media_ GUARDED_BY(send_critsect_); | 439 bool sending_media_ GUARDED_BY(send_critsect_); |
| 408 | 440 |
| 409 size_t max_payload_length_; | 441 size_t max_payload_length_; |
| 410 uint16_t packet_over_head_; | 442 uint16_t packet_over_head_; |
| 411 | 443 |
| 412 int8_t payload_type_ GUARDED_BY(send_critsect_); | 444 int8_t payload_type_ GUARDED_BY(send_critsect_); |
| 413 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; | 445 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; |
| 414 | 446 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 433 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); | 465 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); |
| 434 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); | 466 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); |
| 435 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); | 467 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); |
| 436 FrameCountObserver* const frame_count_observer_; | 468 FrameCountObserver* const frame_count_observer_; |
| 437 SendSideDelayObserver* const send_side_delay_observer_; | 469 SendSideDelayObserver* const send_side_delay_observer_; |
| 438 RtcEventLog* const event_log_; | 470 RtcEventLog* const event_log_; |
| 439 | 471 |
| 440 // RTP variables | 472 // RTP variables |
| 441 bool start_timestamp_forced_ GUARDED_BY(send_critsect_); | 473 bool start_timestamp_forced_ GUARDED_BY(send_critsect_); |
| 442 uint32_t start_timestamp_ GUARDED_BY(send_critsect_); | 474 uint32_t start_timestamp_ GUARDED_BY(send_critsect_); |
| 443 SSRCDatabase& ssrc_db_ GUARDED_BY(send_critsect_); | 475 SSRCDatabase* const ssrc_db_; |
|
the sun
2016/01/25 11:24:57
Add GUARDED_BY
tommi
2016/01/25 12:28:33
I don't think we need or should do that actually.
| |
| 444 uint32_t remote_ssrc_ GUARDED_BY(send_critsect_); | 476 uint32_t remote_ssrc_ GUARDED_BY(send_critsect_); |
| 445 bool sequence_number_forced_ GUARDED_BY(send_critsect_); | 477 bool sequence_number_forced_ GUARDED_BY(send_critsect_); |
| 446 uint16_t sequence_number_ GUARDED_BY(send_critsect_); | 478 uint16_t sequence_number_ GUARDED_BY(send_critsect_); |
| 447 uint16_t sequence_number_rtx_ GUARDED_BY(send_critsect_); | 479 uint16_t sequence_number_rtx_ GUARDED_BY(send_critsect_); |
| 448 bool ssrc_forced_ GUARDED_BY(send_critsect_); | 480 bool ssrc_forced_ GUARDED_BY(send_critsect_); |
| 449 uint32_t ssrc_ GUARDED_BY(send_critsect_); | 481 uint32_t ssrc_ GUARDED_BY(send_critsect_); |
| 450 uint32_t timestamp_ GUARDED_BY(send_critsect_); | 482 uint32_t timestamp_ GUARDED_BY(send_critsect_); |
| 451 int64_t capture_time_ms_ GUARDED_BY(send_critsect_); | 483 int64_t capture_time_ms_ GUARDED_BY(send_critsect_); |
| 452 int64_t last_timestamp_time_ms_ GUARDED_BY(send_critsect_); | 484 int64_t last_timestamp_time_ms_ GUARDED_BY(send_critsect_); |
| 453 bool media_has_been_sent_ GUARDED_BY(send_critsect_); | 485 bool media_has_been_sent_ GUARDED_BY(send_critsect_); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 467 // that the target bitrate is still valid. | 499 // that the target bitrate is still valid. |
| 468 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_; | 500 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_; |
| 469 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_); | 501 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_); |
| 470 | 502 |
| 471 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); | 503 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); |
| 472 }; | 504 }; |
| 473 | 505 |
| 474 } // namespace webrtc | 506 } // namespace webrtc |
| 475 | 507 |
| 476 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 508 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| OLD | NEW |