Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.h

Issue 1623543002: Refactor RtpSender and SSRCDatabase a bit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Update comment and remove the one from ssrc_database.cc Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/random.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
39 class RTPSenderInterface { 38 class RTPSenderInterface {
40 public: 39 public:
41 RTPSenderInterface() {} 40 RTPSenderInterface() {}
42 virtual ~RTPSenderInterface() {} 41 virtual ~RTPSenderInterface() {}
43 42
44 enum CVOMode { 43 enum CVOMode {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 kNotRegistered, 188 kNotRegistered,
190 kOk, 189 kOk,
191 kError, 190 kError,
192 }; 191 };
193 ExtensionStatus VerifyExtension(RTPExtensionType extension_type, 192 ExtensionStatus VerifyExtension(RTPExtensionType extension_type,
194 uint8_t* rtp_packet, 193 uint8_t* rtp_packet,
195 size_t rtp_packet_length, 194 size_t rtp_packet_length,
196 const RTPHeader& rtp_header, 195 const RTPHeader& rtp_header,
197 size_t extension_length_bytes, 196 size_t extension_length_bytes,
198 size_t* extension_offset) const 197 size_t* extension_offset) const
199 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_.get()); 198 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_);
200 199
201 bool UpdateAudioLevel(uint8_t* rtp_packet, 200 bool UpdateAudioLevel(uint8_t* rtp_packet,
202 size_t rtp_packet_length, 201 size_t rtp_packet_length,
203 const RTPHeader& rtp_header, 202 const RTPHeader& rtp_header,
204 bool is_voiced, 203 bool is_voiced,
205 uint8_t dBov) const; 204 uint8_t dBov) const;
206 205
207 bool UpdateVideoRotation(uint8_t* rtp_packet, 206 bool UpdateVideoRotation(uint8_t* rtp_packet,
208 size_t rtp_packet_length, 207 size_t rtp_packet_length,
209 const RTPHeader& rtp_header, 208 const RTPHeader& rtp_header,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 size_t rtp_packet_length, 378 size_t rtp_packet_length,
380 const RTPHeader& rtp_header) const; 379 const RTPHeader& rtp_header) const;
381 380
382 void UpdateRtpStats(const uint8_t* buffer, 381 void UpdateRtpStats(const uint8_t* buffer,
383 size_t packet_length, 382 size_t packet_length,
384 const RTPHeader& header, 383 const RTPHeader& header,
385 bool is_rtx, 384 bool is_rtx,
386 bool is_retransmit); 385 bool is_retransmit);
387 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; 386 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const;
388 387
389 Clock* clock_; 388 class BitrateAggregator {
390 int64_t clock_delta_ms_; 389 public:
390 explicit BitrateAggregator(BitrateStatisticsObserver* bitrate_callback);
391
392 void OnStatsUpdated() const;
393
394 Bitrate::Observer* total_bitrate_observer();
395 Bitrate::Observer* retransmit_bitrate_observer();
396 void set_ssrc(uint32_t ssrc);
397
398 private:
399 // We assume that these observers are called on the same thread, which is
400 // true for RtpSender as they are called on the Process thread.
401 class BitrateObserver : public Bitrate::Observer {
402 public:
403 explicit BitrateObserver(const BitrateAggregator& aggregator);
404
405 // Implements Bitrate::Observer.
406 void BitrateUpdated(const BitrateStatistics& stats) override;
407 const BitrateStatistics& statistics() const;
408
409 private:
410 BitrateStatistics statistics_;
411 const BitrateAggregator& aggregator_;
412 };
413
414 BitrateStatisticsObserver* const callback_;
415 BitrateObserver total_bitrate_observer_;
416 BitrateObserver retransmit_bitrate_observer_;
417 uint32_t ssrc_;
418 };
419
420 Clock* const clock_;
421 const int64_t clock_delta_ms_;
391 Random random_ GUARDED_BY(send_critsect_); 422 Random random_ GUARDED_BY(send_critsect_);
392 423
393 rtc::scoped_ptr<BitrateAggregator> bitrates_; 424 BitrateAggregator bitrates_;
394 Bitrate total_bitrate_sent_; 425 Bitrate total_bitrate_sent_;
395 426
396 const bool audio_configured_; 427 const bool audio_configured_;
397 rtc::scoped_ptr<RTPSenderAudio> audio_; 428 const rtc::scoped_ptr<RTPSenderAudio> audio_;
398 rtc::scoped_ptr<RTPSenderVideo> video_; 429 const rtc::scoped_ptr<RTPSenderVideo> video_;
399 430
400 RtpPacketSender* const paced_sender_; 431 RtpPacketSender* const paced_sender_;
401 TransportSequenceNumberAllocator* const transport_sequence_number_allocator_; 432 TransportSequenceNumberAllocator* const transport_sequence_number_allocator_;
402 TransportFeedbackObserver* const transport_feedback_observer_; 433 TransportFeedbackObserver* const transport_feedback_observer_;
403 int64_t last_capture_time_ms_sent_; 434 int64_t last_capture_time_ms_sent_;
404 rtc::scoped_ptr<CriticalSectionWrapper> send_critsect_; 435 rtc::CriticalSection send_critsect_;
405 436
406 Transport *transport_; 437 Transport *transport_;
407 bool sending_media_ GUARDED_BY(send_critsect_); 438 bool sending_media_ GUARDED_BY(send_critsect_);
408 439
409 size_t max_payload_length_; 440 size_t max_payload_length_;
410 uint16_t packet_over_head_; 441 uint16_t packet_over_head_;
411 442
412 int8_t payload_type_ GUARDED_BY(send_critsect_); 443 int8_t payload_type_ GUARDED_BY(send_critsect_);
413 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; 444 std::map<int8_t, RtpUtility::Payload*> payload_type_map_;
414 445
(...skipping 18 matching lines...) Expand all
433 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); 464 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_);
434 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); 465 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_);
435 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); 466 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_);
436 FrameCountObserver* const frame_count_observer_; 467 FrameCountObserver* const frame_count_observer_;
437 SendSideDelayObserver* const send_side_delay_observer_; 468 SendSideDelayObserver* const send_side_delay_observer_;
438 RtcEventLog* const event_log_; 469 RtcEventLog* const event_log_;
439 470
440 // RTP variables 471 // RTP variables
441 bool start_timestamp_forced_ GUARDED_BY(send_critsect_); 472 bool start_timestamp_forced_ GUARDED_BY(send_critsect_);
442 uint32_t start_timestamp_ GUARDED_BY(send_critsect_); 473 uint32_t start_timestamp_ GUARDED_BY(send_critsect_);
443 SSRCDatabase& ssrc_db_ GUARDED_BY(send_critsect_); 474 SSRCDatabase* const ssrc_db_;
444 uint32_t remote_ssrc_ GUARDED_BY(send_critsect_); 475 uint32_t remote_ssrc_ GUARDED_BY(send_critsect_);
445 bool sequence_number_forced_ GUARDED_BY(send_critsect_); 476 bool sequence_number_forced_ GUARDED_BY(send_critsect_);
446 uint16_t sequence_number_ GUARDED_BY(send_critsect_); 477 uint16_t sequence_number_ GUARDED_BY(send_critsect_);
447 uint16_t sequence_number_rtx_ GUARDED_BY(send_critsect_); 478 uint16_t sequence_number_rtx_ GUARDED_BY(send_critsect_);
448 bool ssrc_forced_ GUARDED_BY(send_critsect_); 479 bool ssrc_forced_ GUARDED_BY(send_critsect_);
449 uint32_t ssrc_ GUARDED_BY(send_critsect_); 480 uint32_t ssrc_ GUARDED_BY(send_critsect_);
450 uint32_t timestamp_ GUARDED_BY(send_critsect_); 481 uint32_t timestamp_ GUARDED_BY(send_critsect_);
451 int64_t capture_time_ms_ GUARDED_BY(send_critsect_); 482 int64_t capture_time_ms_ GUARDED_BY(send_critsect_);
452 int64_t last_timestamp_time_ms_ GUARDED_BY(send_critsect_); 483 int64_t last_timestamp_time_ms_ GUARDED_BY(send_critsect_);
453 bool media_has_been_sent_ GUARDED_BY(send_critsect_); 484 bool media_has_been_sent_ GUARDED_BY(send_critsect_);
(...skipping 13 matching lines...) Expand all
467 // that the target bitrate is still valid. 498 // that the target bitrate is still valid.
468 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_; 499 rtc::scoped_ptr<CriticalSectionWrapper> target_bitrate_critsect_;
469 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_); 500 uint32_t target_bitrate_ GUARDED_BY(target_bitrate_critsect_);
470 501
471 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); 502 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender);
472 }; 503 };
473 504
474 } // namespace webrtc 505 } // namespace webrtc
475 506
476 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ 507 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_
OLDNEW
« no previous file with comments | « webrtc/base/random.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698