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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 class RtpPacketSenderProxy : public RtpPacketSender { | 117 class RtpPacketSenderProxy : public RtpPacketSender { |
118 public: | 118 public: |
119 RtpPacketSenderProxy() : rtp_packet_sender_(nullptr) {} | 119 RtpPacketSenderProxy() : rtp_packet_sender_(nullptr) {} |
120 | 120 |
121 void SetPacketSender(RtpPacketSender* rtp_packet_sender) { | 121 void SetPacketSender(RtpPacketSender* rtp_packet_sender) { |
122 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 122 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
123 rtc::CritScope lock(&crit_); | 123 rtc::CritScope lock(&crit_); |
124 rtp_packet_sender_ = rtp_packet_sender; | 124 rtp_packet_sender_ = rtp_packet_sender; |
125 } | 125 } |
126 | 126 |
127 bool HasPacketSender() const { | |
128 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
129 rtc::CritScope lock(&crit_); | |
130 return rtp_packet_sender_ != nullptr; | |
131 } | |
132 | |
133 // Implements RtpPacketSender. | 127 // Implements RtpPacketSender. |
134 void InsertPacket(Priority priority, | 128 void InsertPacket(Priority priority, |
135 uint32_t ssrc, | 129 uint32_t ssrc, |
136 uint16_t sequence_number, | 130 uint16_t sequence_number, |
137 int64_t capture_time_ms, | 131 int64_t capture_time_ms, |
138 size_t bytes, | 132 size_t bytes, |
139 bool retransmission) override { | 133 bool retransmission) override { |
140 rtc::CritScope lock(&crit_); | 134 rtc::CritScope lock(&crit_); |
141 if (rtp_packet_sender_) { | 135 if (rtp_packet_sender_) { |
142 rtp_packet_sender_->InsertPacket(priority, ssrc, sequence_number, | 136 rtp_packet_sender_->InsertPacket(priority, ssrc, sequence_number, |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 configuration.bandwidth_callback = rtcp_observer_.get(); | 842 configuration.bandwidth_callback = rtcp_observer_.get(); |
849 if (pacing_enabled_) { | 843 if (pacing_enabled_) { |
850 configuration.paced_sender = rtp_packet_sender_proxy_.get(); | 844 configuration.paced_sender = rtp_packet_sender_proxy_.get(); |
851 configuration.transport_sequence_number_allocator = | 845 configuration.transport_sequence_number_allocator = |
852 seq_num_allocator_proxy_.get(); | 846 seq_num_allocator_proxy_.get(); |
853 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); | 847 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); |
854 } | 848 } |
855 configuration.event_log = event_log; | 849 configuration.event_log = event_log; |
856 | 850 |
857 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 851 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
| 852 _rtpRtcpModule->SetSendingMediaStatus(false); |
858 | 853 |
859 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); | 854 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); |
860 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( | 855 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( |
861 statistics_proxy_.get()); | 856 statistics_proxy_.get()); |
862 | 857 |
863 Config audioproc_config; | 858 Config audioproc_config; |
864 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | 859 audioproc_config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); |
865 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); | 860 rx_audioproc_.reset(AudioProcessing::Create(audioproc_config)); |
866 } | 861 } |
867 | 862 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 // Resume the previous sequence number which was reset by StopSend(). | 1124 // Resume the previous sequence number which was reset by StopSend(). |
1130 // This needs to be done before |sending| is set to true. | 1125 // This needs to be done before |sending| is set to true. |
1131 if (send_sequence_number_) | 1126 if (send_sequence_number_) |
1132 SetInitSequenceNumber(send_sequence_number_); | 1127 SetInitSequenceNumber(send_sequence_number_); |
1133 | 1128 |
1134 if (channel_state_.Get().sending) { | 1129 if (channel_state_.Get().sending) { |
1135 return 0; | 1130 return 0; |
1136 } | 1131 } |
1137 channel_state_.SetSending(true); | 1132 channel_state_.SetSending(true); |
1138 | 1133 |
| 1134 _rtpRtcpModule->SetSendingMediaStatus(true); |
1139 if (_rtpRtcpModule->SetSendingStatus(true) != 0) { | 1135 if (_rtpRtcpModule->SetSendingStatus(true) != 0) { |
1140 _engineStatisticsPtr->SetLastError( | 1136 _engineStatisticsPtr->SetLastError( |
1141 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 1137 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
1142 "StartSend() RTP/RTCP failed to start sending"); | 1138 "StartSend() RTP/RTCP failed to start sending"); |
| 1139 _rtpRtcpModule->SetSendingMediaStatus(false); |
1143 rtc::CritScope cs(&_callbackCritSect); | 1140 rtc::CritScope cs(&_callbackCritSect); |
1144 channel_state_.SetSending(false); | 1141 channel_state_.SetSending(false); |
1145 return -1; | 1142 return -1; |
1146 } | 1143 } |
1147 | 1144 |
1148 return 0; | 1145 return 0; |
1149 } | 1146 } |
1150 | 1147 |
1151 int32_t Channel::StopSend() { | 1148 int32_t Channel::StopSend() { |
1152 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1149 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
(...skipping 11 matching lines...) Expand all Loading... |
1164 // https://code.google.com/p/webrtc/issues/detail?id=2111 . | 1161 // https://code.google.com/p/webrtc/issues/detail?id=2111 . |
1165 send_sequence_number_ = _rtpRtcpModule->SequenceNumber(); | 1162 send_sequence_number_ = _rtpRtcpModule->SequenceNumber(); |
1166 | 1163 |
1167 // Reset sending SSRC and sequence number and triggers direct transmission | 1164 // Reset sending SSRC and sequence number and triggers direct transmission |
1168 // of RTCP BYE | 1165 // of RTCP BYE |
1169 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { | 1166 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { |
1170 _engineStatisticsPtr->SetLastError( | 1167 _engineStatisticsPtr->SetLastError( |
1171 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, | 1168 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, |
1172 "StartSend() RTP/RTCP failed to stop sending"); | 1169 "StartSend() RTP/RTCP failed to stop sending"); |
1173 } | 1170 } |
| 1171 _rtpRtcpModule->SetSendingMediaStatus(false); |
1174 | 1172 |
1175 return 0; | 1173 return 0; |
1176 } | 1174 } |
1177 | 1175 |
1178 int32_t Channel::StartReceiving() { | 1176 int32_t Channel::StartReceiving() { |
1179 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1177 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1180 "Channel::StartReceiving()"); | 1178 "Channel::StartReceiving()"); |
1181 if (channel_state_.Get().receiving) { | 1179 if (channel_state_.Get().receiving) { |
1182 return 0; | 1180 return 0; |
1183 } | 1181 } |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 TransportFeedbackObserver* transport_feedback_observer, | 2590 TransportFeedbackObserver* transport_feedback_observer, |
2593 PacketRouter* packet_router) { | 2591 PacketRouter* packet_router) { |
2594 RTC_DCHECK(rtp_packet_sender); | 2592 RTC_DCHECK(rtp_packet_sender); |
2595 RTC_DCHECK(transport_feedback_observer); | 2593 RTC_DCHECK(transport_feedback_observer); |
2596 RTC_DCHECK(packet_router && !packet_router_); | 2594 RTC_DCHECK(packet_router && !packet_router_); |
2597 feedback_observer_proxy_->SetTransportFeedbackObserver( | 2595 feedback_observer_proxy_->SetTransportFeedbackObserver( |
2598 transport_feedback_observer); | 2596 transport_feedback_observer); |
2599 seq_num_allocator_proxy_->SetSequenceNumberAllocator(packet_router); | 2597 seq_num_allocator_proxy_->SetSequenceNumberAllocator(packet_router); |
2600 rtp_packet_sender_proxy_->SetPacketSender(rtp_packet_sender); | 2598 rtp_packet_sender_proxy_->SetPacketSender(rtp_packet_sender); |
2601 _rtpRtcpModule->SetStorePacketsStatus(true, 600); | 2599 _rtpRtcpModule->SetStorePacketsStatus(true, 600); |
2602 packet_router->AddRtpModule(_rtpRtcpModule.get(), true); | 2600 packet_router->AddRtpModule(_rtpRtcpModule.get()); |
2603 packet_router_ = packet_router; | 2601 packet_router_ = packet_router; |
2604 } | 2602 } |
2605 | 2603 |
2606 void Channel::RegisterReceiverCongestionControlObjects( | 2604 void Channel::RegisterReceiverCongestionControlObjects( |
2607 PacketRouter* packet_router) { | 2605 PacketRouter* packet_router) { |
2608 RTC_DCHECK(packet_router && !packet_router_); | 2606 RTC_DCHECK(packet_router && !packet_router_); |
2609 packet_router->AddRtpModule(_rtpRtcpModule.get(), false); | 2607 packet_router->AddRtpModule(_rtpRtcpModule.get()); |
2610 packet_router_ = packet_router; | 2608 packet_router_ = packet_router; |
2611 } | 2609 } |
2612 | 2610 |
2613 void Channel::ResetCongestionControlObjects() { | 2611 void Channel::ResetCongestionControlObjects() { |
2614 RTC_DCHECK(packet_router_); | 2612 RTC_DCHECK(packet_router_); |
2615 _rtpRtcpModule->SetStorePacketsStatus(false, 600); | 2613 _rtpRtcpModule->SetStorePacketsStatus(false, 600); |
2616 feedback_observer_proxy_->SetTransportFeedbackObserver(nullptr); | 2614 feedback_observer_proxy_->SetTransportFeedbackObserver(nullptr); |
2617 seq_num_allocator_proxy_->SetSequenceNumberAllocator(nullptr); | 2615 seq_num_allocator_proxy_->SetSequenceNumberAllocator(nullptr); |
2618 const bool sender = rtp_packet_sender_proxy_->HasPacketSender(); | 2616 packet_router_->RemoveRtpModule(_rtpRtcpModule.get()); |
2619 packet_router_->RemoveRtpModule(_rtpRtcpModule.get(), sender); | |
2620 packet_router_ = nullptr; | 2617 packet_router_ = nullptr; |
2621 rtp_packet_sender_proxy_->SetPacketSender(nullptr); | 2618 rtp_packet_sender_proxy_->SetPacketSender(nullptr); |
2622 } | 2619 } |
2623 | 2620 |
2624 void Channel::SetRTCPStatus(bool enable) { | 2621 void Channel::SetRTCPStatus(bool enable) { |
2625 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2622 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2626 "Channel::SetRTCPStatus()"); | 2623 "Channel::SetRTCPStatus()"); |
2627 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); | 2624 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); |
2628 } | 2625 } |
2629 | 2626 |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 int64_t min_rtt = 0; | 3647 int64_t min_rtt = 0; |
3651 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3648 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3652 0) { | 3649 0) { |
3653 return 0; | 3650 return 0; |
3654 } | 3651 } |
3655 return rtt; | 3652 return rtt; |
3656 } | 3653 } |
3657 | 3654 |
3658 } // namespace voe | 3655 } // namespace voe |
3659 } // namespace webrtc | 3656 } // namespace webrtc |
OLD | NEW |