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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 BitrateSent(&state.send_bitrate, &tmp, &tmp, &tmp); | 342 BitrateSent(&state.send_bitrate, &tmp, &tmp, &tmp); |
349 return state; | 343 return state; |
350 } | 344 } |
351 | 345 |
352 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { | 346 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { |
353 if (rtcp_sender_.Sending() != sending) { | 347 if (rtcp_sender_.Sending() != sending) { |
354 // Sends RTCP BYE when going from true to false | 348 // Sends RTCP BYE when going from true to false |
355 if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { | 349 if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { |
356 LOG(LS_WARNING) << "Failed to send RTCP BYE"; | 350 LOG(LS_WARNING) << "Failed to send RTCP BYE"; |
357 } | 351 } |
358 | |
359 collision_detected_ = false; | |
360 | |
361 // Generate a new SSRC for the next "call" if false | |
362 rtp_sender_.SetSendingStatus(sending); | |
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 } | 352 } |
372 return 0; | 353 return 0; |
373 } | 354 } |
374 | 355 |
375 bool ModuleRtpRtcpImpl::Sending() const { | 356 bool ModuleRtpRtcpImpl::Sending() const { |
376 return rtcp_sender_.Sending(); | 357 return rtcp_sender_.Sending(); |
377 } | 358 } |
378 | 359 |
379 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { | 360 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { |
380 rtp_sender_.SetSendingMediaStatus(sending); | 361 rtp_sender_.SetSendingMediaStatus(sending); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 bool ModuleRtpRtcpImpl::SetFecParameters( | 766 bool ModuleRtpRtcpImpl::SetFecParameters( |
786 const FecProtectionParams& delta_params, | 767 const FecProtectionParams& delta_params, |
787 const FecProtectionParams& key_params) { | 768 const FecProtectionParams& key_params) { |
788 return rtp_sender_.SetFecParameters(delta_params, key_params); | 769 return rtp_sender_.SetFecParameters(delta_params, key_params); |
789 } | 770 } |
790 | 771 |
791 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { | 772 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { |
792 // Inform about the incoming SSRC. | 773 // Inform about the incoming SSRC. |
793 rtcp_sender_.SetRemoteSSRC(ssrc); | 774 rtcp_sender_.SetRemoteSSRC(ssrc); |
794 rtcp_receiver_.SetRemoteSSRC(ssrc); | 775 rtcp_receiver_.SetRemoteSSRC(ssrc); |
795 | |
796 // Check for a SSRC collision. | |
797 if (rtp_sender_.SSRC() == ssrc && !collision_detected_) { | |
798 // If we detect a collision change the SSRC but only once. | |
799 collision_detected_ = true; | |
800 uint32_t new_ssrc = rtp_sender_.GenerateNewSSRC(); | |
801 if (new_ssrc == 0) { | |
802 // Configured via API ignore. | |
803 return; | |
804 } | |
805 if (RtcpMode::kOff != rtcp_sender_.Status()) { | |
806 // Send RTCP bye on the current SSRC. | |
807 SendRTCP(kRtcpBye); | |
808 } | |
809 // Change local SSRC and inform all objects about the new SSRC. | |
810 rtcp_sender_.SetSSRC(new_ssrc); | |
811 SetRtcpReceiverSsrcs(new_ssrc); | |
812 } | |
813 } | 776 } |
814 | 777 |
815 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, | 778 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, |
816 uint32_t* video_rate, | 779 uint32_t* video_rate, |
817 uint32_t* fec_rate, | 780 uint32_t* fec_rate, |
818 uint32_t* nack_rate) const { | 781 uint32_t* nack_rate) const { |
819 *total_rate = rtp_sender_.BitrateSent(); | 782 *total_rate = rtp_sender_.BitrateSent(); |
820 *video_rate = rtp_sender_.VideoBitrateSent(); | 783 *video_rate = rtp_sender_.VideoBitrateSent(); |
821 *fec_rate = rtp_sender_.FecOverheadRate(); | 784 *fec_rate = rtp_sender_.FecOverheadRate(); |
822 *nack_rate = rtp_sender_.NackOverheadRate(); | 785 *nack_rate = rtp_sender_.NackOverheadRate(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 StreamDataCountersCallback* | 874 StreamDataCountersCallback* |
912 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 875 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { |
913 return rtp_sender_.GetRtpStatisticsCallback(); | 876 return rtp_sender_.GetRtpStatisticsCallback(); |
914 } | 877 } |
915 | 878 |
916 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( | 879 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( |
917 const BitrateAllocation& bitrate) { | 880 const BitrateAllocation& bitrate) { |
918 rtcp_sender_.SetVideoBitrateAllocation(bitrate); | 881 rtcp_sender_.SetVideoBitrateAllocation(bitrate); |
919 } | 882 } |
920 } // namespace webrtc | 883 } // namespace webrtc |
OLD | NEW |