| 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 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 for (size_t i = 0; i < extensions.size(); ++i) { | 99 for (size_t i = 0; i < extensions.size(); ++i) { |
| 100 ss << extensions[i].ToString(); | 100 ss << extensions[i].ToString(); |
| 101 if (i != extensions.size() - 1) | 101 if (i != extensions.size() - 1) |
| 102 ss << ", "; | 102 ss << ", "; |
| 103 } | 103 } |
| 104 ss << ']'; | 104 ss << ']'; |
| 105 ss << '}'; | 105 ss << '}'; |
| 106 return ss.str(); | 106 return ss.str(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 namespace internal { | |
| 110 namespace { | 109 namespace { |
| 111 | |
| 112 VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) { | 110 VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) { |
| 113 VideoCodec codec; | 111 VideoCodec codec; |
| 114 memset(&codec, 0, sizeof(codec)); | 112 memset(&codec, 0, sizeof(codec)); |
| 115 | 113 |
| 116 codec.plType = decoder.payload_type; | 114 codec.plType = decoder.payload_type; |
| 117 strncpy(codec.plName, decoder.payload_name.c_str(), sizeof(codec.plName)); | 115 strncpy(codec.plName, decoder.payload_name.c_str(), sizeof(codec.plName)); |
| 118 if (decoder.payload_name == "VP8") { | 116 if (decoder.payload_name == "VP8") { |
| 119 codec.codecType = kVideoCodecVP8; | 117 codec.codecType = kVideoCodecVP8; |
| 120 } else if (decoder.payload_name == "VP9") { | 118 } else if (decoder.payload_name == "VP9") { |
| 121 codec.codecType = kVideoCodecVP9; | 119 codec.codecType = kVideoCodecVP9; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 135 | 133 |
| 136 codec.width = 320; | 134 codec.width = 320; |
| 137 codec.height = 180; | 135 codec.height = 180; |
| 138 codec.startBitrate = codec.minBitrate = codec.maxBitrate = | 136 codec.startBitrate = codec.minBitrate = codec.maxBitrate = |
| 139 Call::Config::kDefaultStartBitrateBps / 1000; | 137 Call::Config::kDefaultStartBitrateBps / 1000; |
| 140 | 138 |
| 141 return codec; | 139 return codec; |
| 142 } | 140 } |
| 143 } // namespace | 141 } // namespace |
| 144 | 142 |
| 143 namespace internal { |
| 145 VideoReceiveStream::VideoReceiveStream( | 144 VideoReceiveStream::VideoReceiveStream( |
| 146 int num_cpu_cores, | 145 int num_cpu_cores, |
| 147 CongestionController* congestion_controller, | 146 CongestionController* congestion_controller, |
| 148 const VideoReceiveStream::Config& config, | 147 const VideoReceiveStream::Config& config, |
| 149 webrtc::VoiceEngine* voice_engine, | 148 webrtc::VoiceEngine* voice_engine, |
| 150 ProcessThread* process_thread, | 149 ProcessThread* process_thread, |
| 151 CallStats* call_stats, | 150 CallStats* call_stats, |
| 152 VieRemb* remb) | 151 VieRemb* remb) |
| 153 : transport_adapter_(config.rtcp_send_transport), | 152 : transport_adapter_(config.rtcp_send_transport), |
| 154 encoded_frame_proxy_(config.pre_decode_callback), | 153 encoded_frame_proxy_(config.pre_decode_callback), |
| 155 config_(config), | 154 config_(config), |
| 156 process_thread_(process_thread), | 155 process_thread_(process_thread), |
| 157 clock_(Clock::GetRealTimeClock()), | 156 clock_(Clock::GetRealTimeClock()), |
| 157 decode_thread_(DecodeThreadFunction, this, "DecodingThread"), |
| 158 congestion_controller_(congestion_controller), | 158 congestion_controller_(congestion_controller), |
| 159 call_stats_(call_stats), | 159 call_stats_(call_stats), |
| 160 remb_(remb), | 160 remb_(remb), |
| 161 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)), | 161 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)), |
| 162 incoming_video_stream_( | 162 incoming_video_stream_( |
| 163 0, | 163 0, |
| 164 config.renderer ? config.renderer->SmoothsRenderedFrames() : false), | 164 config.renderer ? config.renderer->SmoothsRenderedFrames() : false), |
| 165 stats_proxy_(config_.rtp.remote_ssrc, clock_), | 165 stats_proxy_(config_.rtp.remote_ssrc, clock_), |
| 166 vie_channel_(&transport_adapter_, | 166 vie_channel_(&transport_adapter_, |
| 167 process_thread, | 167 process_thread, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 vcm_->RegisterPreDecodeImageCallback(this); | 300 vcm_->RegisterPreDecodeImageCallback(this); |
| 301 incoming_video_stream_.SetExternalCallback(this); | 301 incoming_video_stream_.SetExternalCallback(this); |
| 302 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); | 302 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); |
| 303 vie_channel_.RegisterPreRenderCallback(this); | 303 vie_channel_.RegisterPreRenderCallback(this); |
| 304 | 304 |
| 305 process_thread_->RegisterModule(vcm_.get()); | 305 process_thread_->RegisterModule(vcm_.get()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 VideoReceiveStream::~VideoReceiveStream() { | 308 VideoReceiveStream::~VideoReceiveStream() { |
| 309 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 309 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
| 310 incoming_video_stream_.Stop(); | 310 Stop(); |
| 311 |
| 311 process_thread_->DeRegisterModule(vcm_.get()); | 312 process_thread_->DeRegisterModule(vcm_.get()); |
| 312 vie_channel_.RegisterPreRenderCallback(nullptr); | 313 vie_channel_.RegisterPreRenderCallback(nullptr); |
| 313 vcm_->RegisterPreDecodeImageCallback(nullptr); | 314 vcm_->RegisterPreDecodeImageCallback(nullptr); |
| 314 | 315 |
| 315 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); | 316 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); |
| 316 rtp_rtcp_->SetREMBStatus(false); | 317 rtp_rtcp_->SetREMBStatus(false); |
| 317 remb_->RemoveReceiveChannel(rtp_rtcp_); | 318 remb_->RemoveReceiveChannel(rtp_rtcp_); |
| 318 | 319 |
| 319 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) | 320 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
| 320 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); | 321 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void VideoReceiveStream::Start() { | 324 void VideoReceiveStream::Start() { |
| 325 if (decode_thread_.IsRunning()) |
| 326 return; |
| 324 transport_adapter_.Enable(); | 327 transport_adapter_.Enable(); |
| 325 incoming_video_stream_.Start(); | 328 incoming_video_stream_.Start(); |
| 326 vie_channel_.StartReceive(); | 329 // Start the decode thread |
| 330 decode_thread_.Start(); |
| 331 decode_thread_.SetPriority(rtc::kHighestPriority); |
| 332 vie_receiver_->StartReceive(); |
| 327 } | 333 } |
| 328 | 334 |
| 329 void VideoReceiveStream::Stop() { | 335 void VideoReceiveStream::Stop() { |
| 330 incoming_video_stream_.Stop(); | 336 incoming_video_stream_.Stop(); |
| 331 vie_channel_.StopReceive(); | 337 vie_receiver_->StopReceive(); |
| 338 vcm_->TriggerDecoderShutdown(); |
| 339 decode_thread_.Stop(); |
| 332 transport_adapter_.Disable(); | 340 transport_adapter_.Disable(); |
| 333 } | 341 } |
| 334 | 342 |
| 335 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, | 343 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, |
| 336 int audio_channel_id) { | 344 int audio_channel_id) { |
| 337 if (voice_engine != nullptr && audio_channel_id != -1) { | 345 if (voice_engine != nullptr && audio_channel_id != -1) { |
| 338 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); | 346 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); |
| 339 vie_channel_.SetVoiceChannel(audio_channel_id, voe_sync_interface); | 347 vie_channel_.SetVoiceChannel(audio_channel_id, voe_sync_interface); |
| 340 voe_sync_interface->Release(); | 348 voe_sync_interface->Release(); |
| 341 } else { | 349 } else { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 encoded_image, codec_specific_info, fragmentation); | 404 encoded_image, codec_specific_info, fragmentation); |
| 397 } | 405 } |
| 398 return 0; | 406 return 0; |
| 399 } | 407 } |
| 400 | 408 |
| 401 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 409 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
| 402 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode | 410 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode |
| 403 : RtcpMode::kOff); | 411 : RtcpMode::kOff); |
| 404 } | 412 } |
| 405 | 413 |
| 414 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) { |
| 415 static_cast<VideoReceiveStream*>(ptr)->Decode(); |
| 416 return true; |
| 417 } |
| 418 |
| 419 void VideoReceiveStream::Decode() { |
| 420 static const int kMaxDecodeWaitTimeMs = 50; |
| 421 vcm_->Decode(kMaxDecodeWaitTimeMs); |
| 422 } |
| 423 |
| 406 } // namespace internal | 424 } // namespace internal |
| 407 } // namespace webrtc | 425 } // namespace webrtc |
| OLD | NEW |