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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc

Issue 2702203002: Reland of Delete class SSRCDatabase, and its global ssrc registry. (Closed)
Patch Set: Move SetRtcpReceiverSsrcs call to ModuleRtpRtcpImpl::SetSendingStatus. Update tests to set SSRC ear… Created 3 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
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
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 rtcp_receiver_(configuration.clock, 93 rtcp_receiver_(configuration.clock,
94 configuration.receiver_only, 94 configuration.receiver_only,
95 configuration.rtcp_packet_type_counter_observer, 95 configuration.rtcp_packet_type_counter_observer,
96 configuration.bandwidth_callback, 96 configuration.bandwidth_callback,
97 configuration.intra_frame_callback, 97 configuration.intra_frame_callback,
98 configuration.transport_feedback_callback, 98 configuration.transport_feedback_callback,
99 configuration.bitrate_allocation_observer, 99 configuration.bitrate_allocation_observer,
100 this), 100 this),
101 clock_(configuration.clock), 101 clock_(configuration.clock),
102 audio_(configuration.audio), 102 audio_(configuration.audio),
103 collision_detected_(false),
104 last_process_time_(configuration.clock->TimeInMilliseconds()), 103 last_process_time_(configuration.clock->TimeInMilliseconds()),
105 last_bitrate_process_time_(configuration.clock->TimeInMilliseconds()), 104 last_bitrate_process_time_(configuration.clock->TimeInMilliseconds()),
106 last_rtt_process_time_(configuration.clock->TimeInMilliseconds()), 105 last_rtt_process_time_(configuration.clock->TimeInMilliseconds()),
107 packet_overhead_(28), // IPV4 UDP. 106 packet_overhead_(28), // IPV4 UDP.
108 nack_last_time_sent_full_(0), 107 nack_last_time_sent_full_(0),
109 nack_last_time_sent_full_prev_(0), 108 nack_last_time_sent_full_prev_(0),
110 nack_last_seq_number_sent_(0), 109 nack_last_seq_number_sent_(0),
111 key_frame_req_method_(kKeyFrameReqPliRtcp), 110 key_frame_req_method_(kKeyFrameReqPliRtcp),
112 remote_bitrate_(configuration.remote_bitrate_estimator), 111 remote_bitrate_(configuration.remote_bitrate_estimator),
113 rtt_stats_(configuration.rtt_stats), 112 rtt_stats_(configuration.rtt_stats),
114 rtt_ms_(0) { 113 rtt_ms_(0) {
115 // Make sure that RTCP objects are aware of our SSRC.
116 uint32_t SSRC = rtp_sender_.SSRC();
117 rtcp_sender_.SetSSRC(SSRC);
118 SetRtcpReceiverSsrcs(SSRC);
119
120 // Make sure rtcp sender use same timestamp offset as rtp sender. 114 // Make sure rtcp sender use same timestamp offset as rtp sender.
121 rtcp_sender_.SetTimestampOffset(rtp_sender_.TimestampOffset()); 115 rtcp_sender_.SetTimestampOffset(rtp_sender_.TimestampOffset());
122 116
123 // Set default packet size limit. 117 // Set default packet size limit.
124 // TODO(nisse): Kind-of duplicates 118 // TODO(nisse): Kind-of duplicates
125 // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize. 119 // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize.
126 const size_t kTcpOverIpv4HeaderSize = 40; 120 const size_t kTcpOverIpv4HeaderSize = 40;
127 SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize); 121 SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize);
128 } 122 }
129 123
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 297 }
304 298
305 RtpState ModuleRtpRtcpImpl::GetRtxState() const { 299 RtpState ModuleRtpRtcpImpl::GetRtxState() const {
306 return rtp_sender_.GetRtxRtpState(); 300 return rtp_sender_.GetRtxRtpState();
307 } 301 }
308 302
309 uint32_t ModuleRtpRtcpImpl::SSRC() const { 303 uint32_t ModuleRtpRtcpImpl::SSRC() const {
310 return rtp_sender_.SSRC(); 304 return rtp_sender_.SSRC();
311 } 305 }
312 306
313 // Configure SSRC, default is a random number.
314 void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) { 307 void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) {
315 rtp_sender_.SetSSRC(ssrc); 308 rtp_sender_.SetSSRC(ssrc);
316 rtcp_sender_.SetSSRC(ssrc); 309 rtcp_sender_.SetSSRC(ssrc);
317 SetRtcpReceiverSsrcs(ssrc); 310 SetRtcpReceiverSsrcs(ssrc);
318 } 311 }
319 312
320 void ModuleRtpRtcpImpl::SetCsrcs(const std::vector<uint32_t>& csrcs) { 313 void ModuleRtpRtcpImpl::SetCsrcs(const std::vector<uint32_t>& csrcs) {
321 rtcp_sender_.SetCsrcs(csrcs); 314 rtcp_sender_.SetCsrcs(csrcs);
322 rtp_sender_.SetCsrcs(csrcs); 315 rtp_sender_.SetCsrcs(csrcs);
323 } 316 }
(...skipping 24 matching lines...) Expand all
348 BitrateSent(&state.send_bitrate, &tmp, &tmp, &tmp); 341 BitrateSent(&state.send_bitrate, &tmp, &tmp, &tmp);
349 return state; 342 return state;
350 } 343 }
351 344
352 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { 345 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) {
353 if (rtcp_sender_.Sending() != sending) { 346 if (rtcp_sender_.Sending() != sending) {
354 // Sends RTCP BYE when going from true to false 347 // Sends RTCP BYE when going from true to false
355 if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { 348 if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) {
356 LOG(LS_WARNING) << "Failed to send RTCP BYE"; 349 LOG(LS_WARNING) << "Failed to send RTCP BYE";
357 } 350 }
358 351 if (sending) {
359 collision_detected_ = false; 352 // Update Rtcp receiver config, to track Rtx config changes from
360 353 // the SetRtxStatus and SetRtxSsrc methods.
361 // Generate a new SSRC for the next "call" if false 354 SetRtcpReceiverSsrcs(rtp_sender_.SSRC());
362 rtp_sender_.SetSendingStatus(sending); 355 }
363
364 // Make sure that RTCP objects are aware of our SSRC (it could have changed
365 // Due to collision)
366 uint32_t SSRC = rtp_sender_.SSRC();
367 rtcp_sender_.SetSSRC(SSRC);
368 SetRtcpReceiverSsrcs(SSRC);
369
370 return 0;
371 } 356 }
372 return 0; 357 return 0;
373 } 358 }
374 359
375 bool ModuleRtpRtcpImpl::Sending() const { 360 bool ModuleRtpRtcpImpl::Sending() const {
376 return rtcp_sender_.Sending(); 361 return rtcp_sender_.Sending();
377 } 362 }
378 363
379 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { 364 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) {
380 rtp_sender_.SetSendingMediaStatus(sending); 365 rtp_sender_.SetSendingMediaStatus(sending);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 bool ModuleRtpRtcpImpl::SetFecParameters( 772 bool ModuleRtpRtcpImpl::SetFecParameters(
788 const FecProtectionParams& delta_params, 773 const FecProtectionParams& delta_params,
789 const FecProtectionParams& key_params) { 774 const FecProtectionParams& key_params) {
790 return rtp_sender_.SetFecParameters(delta_params, key_params); 775 return rtp_sender_.SetFecParameters(delta_params, key_params);
791 } 776 }
792 777
793 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { 778 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) {
794 // Inform about the incoming SSRC. 779 // Inform about the incoming SSRC.
795 rtcp_sender_.SetRemoteSSRC(ssrc); 780 rtcp_sender_.SetRemoteSSRC(ssrc);
796 rtcp_receiver_.SetRemoteSSRC(ssrc); 781 rtcp_receiver_.SetRemoteSSRC(ssrc);
797
798 // Check for a SSRC collision.
799 if (rtp_sender_.SSRC() == ssrc && !collision_detected_) {
800 // If we detect a collision change the SSRC but only once.
801 collision_detected_ = true;
802 uint32_t new_ssrc = rtp_sender_.GenerateNewSSRC();
803 if (new_ssrc == 0) {
804 // Configured via API ignore.
805 return;
806 }
807 if (RtcpMode::kOff != rtcp_sender_.Status()) {
808 // Send RTCP bye on the current SSRC.
809 SendRTCP(kRtcpBye);
810 }
811 // Change local SSRC and inform all objects about the new SSRC.
812 rtcp_sender_.SetSSRC(new_ssrc);
813 SetRtcpReceiverSsrcs(new_ssrc);
814 }
815 } 782 }
816 783
817 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, 784 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate,
818 uint32_t* video_rate, 785 uint32_t* video_rate,
819 uint32_t* fec_rate, 786 uint32_t* fec_rate,
820 uint32_t* nack_rate) const { 787 uint32_t* nack_rate) const {
821 *total_rate = rtp_sender_.BitrateSent(); 788 *total_rate = rtp_sender_.BitrateSent();
822 *video_rate = rtp_sender_.VideoBitrateSent(); 789 *video_rate = rtp_sender_.VideoBitrateSent();
823 *fec_rate = rtp_sender_.FecOverheadRate(); 790 *fec_rate = rtp_sender_.FecOverheadRate();
824 *nack_rate = rtp_sender_.NackOverheadRate(); 791 *nack_rate = rtp_sender_.NackOverheadRate();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 StreamDataCountersCallback* 880 StreamDataCountersCallback*
914 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { 881 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const {
915 return rtp_sender_.GetRtpStatisticsCallback(); 882 return rtp_sender_.GetRtpStatisticsCallback();
916 } 883 }
917 884
918 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( 885 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation(
919 const BitrateAllocation& bitrate) { 886 const BitrateAllocation& bitrate) {
920 rtcp_sender_.SetVideoBitrateAllocation(bitrate); 887 rtcp_sender_.SetVideoBitrateAllocation(bitrate);
921 } 888 }
922 } // namespace webrtc 889 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698