OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #include "webrtc/video/video_receive_stream.h" | 11 #include "webrtc/video/video_receive_stream.h" |
12 | 12 |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 | 14 |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
20 #include "webrtc/call/congestion_controller.h" | 20 #include "webrtc/call/congestion_controller.h" |
21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
22 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
23 #include "webrtc/video/call_stats.h" | 23 #include "webrtc/video/call_stats.h" |
24 #include "webrtc/video/receive_statistics_proxy.h" | 24 #include "webrtc/video/receive_statistics_proxy.h" |
25 #include "webrtc/video/vie_remb.h" | |
25 #include "webrtc/video_receive_stream.h" | 26 #include "webrtc/video_receive_stream.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 | 29 |
29 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { | 30 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { |
30 for (const auto& extension : extensions) { | 31 for (const auto& extension : extensions) { |
31 if (extension.name == RtpExtension::kTransportSequenceNumber) | 32 if (extension.name == RtpExtension::kTransportSequenceNumber) |
32 return true; | 33 return true; |
33 } | 34 } |
34 return false; | 35 return false; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 return codec; | 138 return codec; |
138 } | 139 } |
139 } // namespace | 140 } // namespace |
140 | 141 |
141 VideoReceiveStream::VideoReceiveStream( | 142 VideoReceiveStream::VideoReceiveStream( |
142 int num_cpu_cores, | 143 int num_cpu_cores, |
143 CongestionController* congestion_controller, | 144 CongestionController* congestion_controller, |
144 const VideoReceiveStream::Config& config, | 145 const VideoReceiveStream::Config& config, |
145 webrtc::VoiceEngine* voice_engine, | 146 webrtc::VoiceEngine* voice_engine, |
146 ProcessThread* process_thread, | 147 ProcessThread* process_thread, |
147 CallStats* call_stats) | 148 CallStats* call_stats, |
149 VieRemb* remb) | |
148 : transport_adapter_(config.rtcp_send_transport), | 150 : transport_adapter_(config.rtcp_send_transport), |
149 encoded_frame_proxy_(config.pre_decode_callback), | 151 encoded_frame_proxy_(config.pre_decode_callback), |
150 config_(config), | 152 config_(config), |
151 clock_(Clock::GetRealTimeClock()), | 153 clock_(Clock::GetRealTimeClock()), |
152 congestion_controller_(congestion_controller), | 154 congestion_controller_(congestion_controller), |
153 call_stats_(call_stats) { | 155 call_stats_(call_stats), |
156 remb_(remb) { | |
the sun
2016/02/05 15:12:37
RTC_DCHECK(remb);
wouldn't hurt to be paranoid abo
stefan-webrtc
2016/02/07 18:29:27
Done.
| |
154 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 157 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
155 | 158 |
156 bool send_side_bwe = | 159 bool send_side_bwe = |
157 config.rtp.transport_cc && UseSendSideBwe(config_.rtp.extensions); | 160 config.rtp.transport_cc && UseSendSideBwe(config_.rtp.extensions); |
158 | 161 |
159 RemoteBitrateEstimator* bitrate_estimator = | 162 RemoteBitrateEstimator* bitrate_estimator = |
160 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe); | 163 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe); |
161 | 164 |
162 vie_channel_.reset(new ViEChannel( | 165 vie_channel_.reset(new ViEChannel( |
163 num_cpu_cores, &transport_adapter_, process_thread, nullptr, | 166 num_cpu_cores, &transport_adapter_, process_thread, nullptr, |
(...skipping 27 matching lines...) Expand all Loading... | |
191 RTC_DCHECK(it->second.payload_type != 0); | 194 RTC_DCHECK(it->second.payload_type != 0); |
192 | 195 |
193 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); | 196 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); |
194 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); | 197 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); |
195 } | 198 } |
196 // TODO(holmer): When Chrome no longer depends on this being false by default, | 199 // TODO(holmer): When Chrome no longer depends on this being false by default, |
197 // always use the mapping and remove this whole codepath. | 200 // always use the mapping and remove this whole codepath. |
198 vie_channel_->SetUseRtxPayloadMappingOnRestore( | 201 vie_channel_->SetUseRtxPayloadMappingOnRestore( |
199 config_.rtp.use_rtx_payload_mapping_on_restore); | 202 config_.rtp.use_rtx_payload_mapping_on_restore); |
200 | 203 |
201 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, | 204 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
202 vie_channel_->rtp_rtcp()); | 205 if (config_.rtp.remb) { |
206 rtp_module->SetREMBStatus(true); | |
207 remb_->AddReceiveChannel(rtp_module); | |
208 } | |
203 | 209 |
204 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { | 210 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { |
205 const std::string& extension = config_.rtp.extensions[i].name; | 211 const std::string& extension = config_.rtp.extensions[i].name; |
206 int id = config_.rtp.extensions[i].id; | 212 int id = config_.rtp.extensions[i].id; |
207 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 213 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
208 RTC_DCHECK_GE(id, 1); | 214 RTC_DCHECK_GE(id, 1); |
209 RTC_DCHECK_LE(id, 14); | 215 RTC_DCHECK_LE(id, 14); |
210 if (extension == RtpExtension::kTOffset) { | 216 if (extension == RtpExtension::kTOffset) { |
211 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); | 217 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); |
212 } else if (extension == RtpExtension::kAbsSendTime) { | 218 } else if (extension == RtpExtension::kAbsSendTime) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 vie_channel_->RegisterPreRenderCallback(this); | 292 vie_channel_->RegisterPreRenderCallback(this); |
287 } | 293 } |
288 | 294 |
289 VideoReceiveStream::~VideoReceiveStream() { | 295 VideoReceiveStream::~VideoReceiveStream() { |
290 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 296 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
291 incoming_video_stream_->Stop(); | 297 incoming_video_stream_->Stop(); |
292 vie_channel_->RegisterPreRenderCallback(nullptr); | 298 vie_channel_->RegisterPreRenderCallback(nullptr); |
293 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 299 vie_channel_->RegisterPreDecodeImageCallback(nullptr); |
294 | 300 |
295 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); | 301 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); |
296 congestion_controller_->SetChannelRembStatus(false, false, | 302 |
297 vie_channel_->rtp_rtcp()); | 303 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
304 rtp_module->SetREMBStatus(false); | |
305 remb_->RemoveReceiveChannel(rtp_module); | |
298 | 306 |
299 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 307 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); |
300 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 308 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); |
301 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe)-> | 309 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe)-> |
302 RemoveStream(remote_ssrc); | 310 RemoveStream(remote_ssrc); |
303 } | 311 } |
304 | 312 |
305 void VideoReceiveStream::Start() { | 313 void VideoReceiveStream::Start() { |
306 transport_adapter_.Enable(); | 314 transport_adapter_.Enable(); |
307 incoming_video_stream_->Start(); | 315 incoming_video_stream_->Start(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 return 0; | 388 return 0; |
381 } | 389 } |
382 | 390 |
383 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 391 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
384 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode | 392 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode |
385 : RtcpMode::kOff); | 393 : RtcpMode::kOff); |
386 } | 394 } |
387 | 395 |
388 } // namespace internal | 396 } // namespace internal |
389 } // namespace webrtc | 397 } // namespace webrtc |
OLD | NEW |