| 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 <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/call/congestion_controller.h" |
| 18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 19 #include "webrtc/system_wrappers/interface/clock.h" | 20 #include "webrtc/system_wrappers/interface/clock.h" |
| 20 #include "webrtc/system_wrappers/interface/logging.h" | 21 #include "webrtc/system_wrappers/interface/logging.h" |
| 21 #include "webrtc/video/receive_statistics_proxy.h" | 22 #include "webrtc/video/receive_statistics_proxy.h" |
| 22 #include "webrtc/video_engine/call_stats.h" | 23 #include "webrtc/video_engine/call_stats.h" |
| 23 #include "webrtc/video_receive_stream.h" | 24 #include "webrtc/video_receive_stream.h" |
| 24 | 25 |
| 25 namespace webrtc { | 26 namespace webrtc { |
| 26 | 27 |
| 27 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { | 28 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 codec.width = 320; | 132 codec.width = 320; |
| 132 codec.height = 180; | 133 codec.height = 180; |
| 133 codec.startBitrate = codec.minBitrate = codec.maxBitrate = | 134 codec.startBitrate = codec.minBitrate = codec.maxBitrate = |
| 134 Call::Config::kDefaultStartBitrateBps / 1000; | 135 Call::Config::kDefaultStartBitrateBps / 1000; |
| 135 | 136 |
| 136 return codec; | 137 return codec; |
| 137 } | 138 } |
| 138 } // namespace | 139 } // namespace |
| 139 | 140 |
| 140 VideoReceiveStream::VideoReceiveStream(int num_cpu_cores, | 141 VideoReceiveStream::VideoReceiveStream( |
| 141 ChannelGroup* channel_group, | 142 int num_cpu_cores, |
| 142 const VideoReceiveStream::Config& config, | 143 CongestionController* congestion_controller, |
| 143 webrtc::VoiceEngine* voice_engine, | 144 const VideoReceiveStream::Config& config, |
| 144 ProcessThread* process_thread, | 145 webrtc::VoiceEngine* voice_engine, |
| 145 CallStats* call_stats) | 146 ProcessThread* process_thread, |
| 147 CallStats* call_stats) |
| 146 : transport_adapter_(config.rtcp_send_transport), | 148 : transport_adapter_(config.rtcp_send_transport), |
| 147 encoded_frame_proxy_(config.pre_decode_callback), | 149 encoded_frame_proxy_(config.pre_decode_callback), |
| 148 config_(config), | 150 config_(config), |
| 149 clock_(Clock::GetRealTimeClock()), | 151 clock_(Clock::GetRealTimeClock()), |
| 150 channel_group_(channel_group), | 152 congestion_controller_(congestion_controller), |
| 151 call_stats_(call_stats) { | 153 call_stats_(call_stats) { |
| 152 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 154 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
| 153 | 155 |
| 154 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 156 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); |
| 155 | 157 |
| 156 RemoteBitrateEstimator* bitrate_estimator = | 158 RemoteBitrateEstimator* bitrate_estimator = |
| 157 channel_group_->GetRemoteBitrateEstimator(send_side_bwe); | 159 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe); |
| 158 | 160 |
| 159 vie_channel_.reset(new ViEChannel( | 161 vie_channel_.reset(new ViEChannel( |
| 160 num_cpu_cores, &transport_adapter_, process_thread, nullptr, | 162 num_cpu_cores, &transport_adapter_, process_thread, nullptr, |
| 161 channel_group_->GetBitrateController()->CreateRtcpBandwidthObserver(), | 163 congestion_controller_->GetBitrateController()-> |
| 164 CreateRtcpBandwidthObserver(), |
| 162 nullptr, bitrate_estimator, call_stats_->rtcp_rtt_stats(), | 165 nullptr, bitrate_estimator, call_stats_->rtcp_rtt_stats(), |
| 163 channel_group_->pacer(), channel_group_->packet_router(), 1, false)); | 166 congestion_controller_->pacer(), congestion_controller_->packet_router(), |
| 167 1, false)); |
| 164 | 168 |
| 165 RTC_CHECK(vie_channel_->Init() == 0); | 169 RTC_CHECK(vie_channel_->Init() == 0); |
| 166 | 170 |
| 167 // Register the channel to receive stats updates. | 171 // Register the channel to receive stats updates. |
| 168 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); | 172 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); |
| 169 | 173 |
| 170 // TODO(pbos): This is not fine grained enough... | 174 // TODO(pbos): This is not fine grained enough... |
| 171 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, | 175 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, |
| 172 -1, -1); | 176 -1, -1); |
| 173 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 177 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 188 RTC_DCHECK(it->second.payload_type != 0); | 192 RTC_DCHECK(it->second.payload_type != 0); |
| 189 | 193 |
| 190 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); | 194 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); |
| 191 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); | 195 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); |
| 192 } | 196 } |
| 193 // TODO(holmer): When Chrome no longer depends on this being false by default, | 197 // TODO(holmer): When Chrome no longer depends on this being false by default, |
| 194 // always use the mapping and remove this whole codepath. | 198 // always use the mapping and remove this whole codepath. |
| 195 vie_channel_->SetUseRtxPayloadMappingOnRestore( | 199 vie_channel_->SetUseRtxPayloadMappingOnRestore( |
| 196 config_.rtp.use_rtx_payload_mapping_on_restore); | 200 config_.rtp.use_rtx_payload_mapping_on_restore); |
| 197 | 201 |
| 198 channel_group_->SetChannelRembStatus(false, config_.rtp.remb, | 202 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, |
| 199 vie_channel_->rtp_rtcp()); | 203 vie_channel_->rtp_rtcp()); |
| 200 | 204 |
| 201 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { | 205 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { |
| 202 const std::string& extension = config_.rtp.extensions[i].name; | 206 const std::string& extension = config_.rtp.extensions[i].name; |
| 203 int id = config_.rtp.extensions[i].id; | 207 int id = config_.rtp.extensions[i].id; |
| 204 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 208 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
| 205 RTC_DCHECK_GE(id, 1); | 209 RTC_DCHECK_GE(id, 1); |
| 206 RTC_DCHECK_LE(id, 14); | 210 RTC_DCHECK_LE(id, 14); |
| 207 if (extension == RtpExtension::kTOffset) { | 211 if (extension == RtpExtension::kTOffset) { |
| 208 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); | 212 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); |
| 209 } else if (extension == RtpExtension::kAbsSendTime) { | 213 } else if (extension == RtpExtension::kAbsSendTime) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 VideoReceiveStream::~VideoReceiveStream() { | 284 VideoReceiveStream::~VideoReceiveStream() { |
| 281 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 285 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
| 282 incoming_video_stream_->Stop(); | 286 incoming_video_stream_->Stop(); |
| 283 vie_channel_->RegisterPreRenderCallback(nullptr); | 287 vie_channel_->RegisterPreRenderCallback(nullptr); |
| 284 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 288 vie_channel_->RegisterPreDecodeImageCallback(nullptr); |
| 285 | 289 |
| 286 for (size_t i = 0; i < config_.decoders.size(); ++i) | 290 for (size_t i = 0; i < config_.decoders.size(); ++i) |
| 287 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); | 291 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); |
| 288 | 292 |
| 289 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); | 293 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); |
| 290 channel_group_->SetChannelRembStatus(false, false, vie_channel_->rtp_rtcp()); | 294 congestion_controller_->SetChannelRembStatus(false, false, |
| 295 vie_channel_->rtp_rtcp()); |
| 291 | 296 |
| 292 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 297 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); |
| 293 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 298 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); |
| 294 channel_group_->GetRemoteBitrateEstimator(send_side_bwe)->RemoveStream( | 299 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe)-> |
| 295 remote_ssrc); | 300 RemoveStream(remote_ssrc); |
| 296 } | 301 } |
| 297 | 302 |
| 298 void VideoReceiveStream::Start() { | 303 void VideoReceiveStream::Start() { |
| 299 transport_adapter_.Enable(); | 304 transport_adapter_.Enable(); |
| 300 incoming_video_stream_->Start(); | 305 incoming_video_stream_->Start(); |
| 301 vie_channel_->StartReceive(); | 306 vie_channel_->StartReceive(); |
| 302 } | 307 } |
| 303 | 308 |
| 304 void VideoReceiveStream::Stop() { | 309 void VideoReceiveStream::Stop() { |
| 305 incoming_video_stream_->Stop(); | 310 incoming_video_stream_->Stop(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 return 0; | 378 return 0; |
| 374 } | 379 } |
| 375 | 380 |
| 376 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 381 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
| 377 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode | 382 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode |
| 378 : RtcpMode::kOff); | 383 : RtcpMode::kOff); |
| 379 } | 384 } |
| 380 | 385 |
| 381 } // namespace internal | 386 } // namespace internal |
| 382 } // namespace webrtc | 387 } // namespace webrtc |
| OLD | NEW |