| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 for (const auto& codec : codecs) { | 94 for (const auto& codec : codecs) { |
| 95 if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) { | 95 if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) { |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 | 101 |
| 102 webrtc::VideoEncoder* CreateVideoEncoder( | 102 webrtc::VideoEncoder* CreateVideoEncoder( |
| 103 const cricket::VideoCodec& codec) override { | 103 const cricket::VideoCodec& codec) override { |
| 104 RTC_DCHECK(factory_ != NULL); | 104 RTC_DCHECK(factory_ != nullptr); |
| 105 // If it's a codec type we can simulcast, create a wrapped encoder. | 105 // If it's a codec type we can simulcast, create a wrapped encoder. |
| 106 if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) { | 106 if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) { |
| 107 return new webrtc::SimulcastEncoderAdapter( | 107 return new webrtc::SimulcastEncoderAdapter( |
| 108 new EncoderFactoryAdapter(factory_)); | 108 new EncoderFactoryAdapter(factory_)); |
| 109 } | 109 } |
| 110 webrtc::VideoEncoder* encoder = factory_->CreateVideoEncoder(codec); | 110 webrtc::VideoEncoder* encoder = factory_->CreateVideoEncoder(codec); |
| 111 if (encoder) { | 111 if (encoder) { |
| 112 non_simulcast_encoders_.push_back(encoder); | 112 non_simulcast_encoders_.push_back(encoder); |
| 113 } | 113 } |
| 114 return encoder; | 114 return encoder; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 // VP9 denoising is disabled by default. | 416 // VP9 denoising is disabled by default. |
| 417 vp9_settings.denoisingOn = codec_default_denoising ? false : denoising; | 417 vp9_settings.denoisingOn = codec_default_denoising ? false : denoising; |
| 418 vp9_settings.frameDroppingOn = frame_dropping; | 418 vp9_settings.frameDroppingOn = frame_dropping; |
| 419 return new rtc::RefCountedObject< | 419 return new rtc::RefCountedObject< |
| 420 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); | 420 webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings); |
| 421 } | 421 } |
| 422 return nullptr; | 422 return nullptr; |
| 423 } | 423 } |
| 424 | 424 |
| 425 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() | 425 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() |
| 426 : default_recv_ssrc_(0), default_sink_(NULL) {} | 426 : default_recv_ssrc_(0), default_sink_(nullptr) {} |
| 427 | 427 |
| 428 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( | 428 UnsignalledSsrcHandler::Action DefaultUnsignalledSsrcHandler::OnUnsignalledSsrc( |
| 429 WebRtcVideoChannel2* channel, | 429 WebRtcVideoChannel2* channel, |
| 430 uint32_t ssrc) { | 430 uint32_t ssrc) { |
| 431 if (default_recv_ssrc_ != 0) { // Already one default stream. | 431 if (default_recv_ssrc_ != 0) { // Already one default stream. |
| 432 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set."; | 432 LOG(LS_WARNING) << "Unknown SSRC, but default receive stream already set."; |
| 433 return kDropPacket; | 433 return kDropPacket; |
| 434 } | 434 } |
| 435 | 435 |
| 436 StreamParams sp; | 436 StreamParams sp; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 454 VideoMediaChannel* channel, | 454 VideoMediaChannel* channel, |
| 455 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 455 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { |
| 456 default_sink_ = sink; | 456 default_sink_ = sink; |
| 457 if (default_recv_ssrc_ != 0) { | 457 if (default_recv_ssrc_ != 0) { |
| 458 channel->SetSink(default_recv_ssrc_, default_sink_); | 458 channel->SetSink(default_recv_ssrc_, default_sink_); |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 WebRtcVideoEngine2::WebRtcVideoEngine2() | 462 WebRtcVideoEngine2::WebRtcVideoEngine2() |
| 463 : initialized_(false), | 463 : initialized_(false), |
| 464 external_decoder_factory_(NULL), | 464 external_decoder_factory_(nullptr), |
| 465 external_encoder_factory_(NULL) { | 465 external_encoder_factory_(nullptr) { |
| 466 LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()"; | 466 LOG(LS_INFO) << "WebRtcVideoEngine2::WebRtcVideoEngine2()"; |
| 467 } | 467 } |
| 468 | 468 |
| 469 WebRtcVideoEngine2::~WebRtcVideoEngine2() { | 469 WebRtcVideoEngine2::~WebRtcVideoEngine2() { |
| 470 LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2"; | 470 LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2"; |
| 471 } | 471 } |
| 472 | 472 |
| 473 void WebRtcVideoEngine2::Init() { | 473 void WebRtcVideoEngine2::Init() { |
| 474 LOG(LS_INFO) << "WebRtcVideoEngine2::Init"; | 474 LOG(LS_INFO) << "WebRtcVideoEngine2::Init"; |
| 475 initialized_ = true; | 475 initialized_ = true; |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 // been moved to VideoBroadcaster. So remove the argument from this | 1010 // been moved to VideoBroadcaster. So remove the argument from this |
| 1011 // method. | 1011 // method. |
| 1012 bool WebRtcVideoChannel2::SetVideoSend( | 1012 bool WebRtcVideoChannel2::SetVideoSend( |
| 1013 uint32_t ssrc, | 1013 uint32_t ssrc, |
| 1014 bool enable, | 1014 bool enable, |
| 1015 const VideoOptions* options, | 1015 const VideoOptions* options, |
| 1016 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { | 1016 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { |
| 1017 TRACE_EVENT0("webrtc", "SetVideoSend"); | 1017 TRACE_EVENT0("webrtc", "SetVideoSend"); |
| 1018 RTC_DCHECK(ssrc != 0); | 1018 RTC_DCHECK(ssrc != 0); |
| 1019 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable | 1019 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable |
| 1020 << ", options: " << (options ? options->ToString() : "nullptr") | 1020 << ", options: " << (options ? options->ToString() : "null") |
| 1021 << ", source = " << (source ? "(source)" : "nullptr") << ")"; | 1021 << ", source = " << (source ? "(source)" : "null") << ")"; |
| 1022 | 1022 |
| 1023 rtc::CritScope stream_lock(&stream_crit_); | 1023 rtc::CritScope stream_lock(&stream_crit_); |
| 1024 const auto& kv = send_streams_.find(ssrc); | 1024 const auto& kv = send_streams_.find(ssrc); |
| 1025 if (kv == send_streams_.end()) { | 1025 if (kv == send_streams_.end()) { |
| 1026 // Allow unknown ssrc only if source is null. | 1026 // Allow unknown ssrc only if source is null. |
| 1027 RTC_CHECK(source == nullptr); | 1027 RTC_CHECK(source == nullptr); |
| 1028 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; | 1028 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
| 1029 return false; | 1029 return false; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 } | 1256 } |
| 1257 DeleteReceiveStream(stream->second); | 1257 DeleteReceiveStream(stream->second); |
| 1258 receive_streams_.erase(stream); | 1258 receive_streams_.erase(stream); |
| 1259 | 1259 |
| 1260 return true; | 1260 return true; |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 bool WebRtcVideoChannel2::SetSink( | 1263 bool WebRtcVideoChannel2::SetSink( |
| 1264 uint32_t ssrc, | 1264 uint32_t ssrc, |
| 1265 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { | 1265 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) { |
| 1266 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " | 1266 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " << (sink ? "(ptr)" : "null"); |
| 1267 << (sink ? "(ptr)" : "nullptr"); | |
| 1268 if (ssrc == 0) { | 1267 if (ssrc == 0) { |
| 1269 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); | 1268 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); |
| 1270 return true; | 1269 return true; |
| 1271 } | 1270 } |
| 1272 | 1271 |
| 1273 rtc::CritScope stream_lock(&stream_crit_); | 1272 rtc::CritScope stream_lock(&stream_crit_); |
| 1274 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | 1273 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = |
| 1275 receive_streams_.find(ssrc); | 1274 receive_streams_.find(ssrc); |
| 1276 if (it == receive_streams_.end()) { | 1275 if (it == receive_streams_.end()) { |
| 1277 return false; | 1276 return false; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 } | 1585 } |
| 1587 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size | 1586 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size |
| 1588 ? webrtc::RtcpMode::kReducedSize | 1587 ? webrtc::RtcpMode::kReducedSize |
| 1589 : webrtc::RtcpMode::kCompound; | 1588 : webrtc::RtcpMode::kCompound; |
| 1590 if (codec_settings) { | 1589 if (codec_settings) { |
| 1591 SetCodec(*codec_settings); | 1590 SetCodec(*codec_settings); |
| 1592 } | 1591 } |
| 1593 } | 1592 } |
| 1594 | 1593 |
| 1595 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { | 1594 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { |
| 1596 if (stream_ != NULL) { | 1595 if (stream_ != nullptr) { |
| 1597 call_->DestroyVideoSendStream(stream_); | 1596 call_->DestroyVideoSendStream(stream_); |
| 1598 } | 1597 } |
| 1599 DestroyVideoEncoder(&allocated_encoder_); | 1598 DestroyVideoEncoder(&allocated_encoder_); |
| 1600 } | 1599 } |
| 1601 | 1600 |
| 1602 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( | 1601 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( |
| 1603 bool enable, | 1602 bool enable, |
| 1604 const VideoOptions* options, | 1603 const VideoOptions* options, |
| 1605 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { | 1604 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { |
| 1606 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); | 1605 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 false /* is_external */); | 1674 false /* is_external */); |
| 1676 } | 1675 } |
| 1677 return AllocatedEncoder( | 1676 return AllocatedEncoder( |
| 1678 internal_encoder_factory_->CreateVideoEncoder(codec), codec, | 1677 internal_encoder_factory_->CreateVideoEncoder(codec), codec, |
| 1679 false /* is_external */); | 1678 false /* is_external */); |
| 1680 } | 1679 } |
| 1681 | 1680 |
| 1682 // This shouldn't happen, we should not be trying to create something we don't | 1681 // This shouldn't happen, we should not be trying to create something we don't |
| 1683 // support. | 1682 // support. |
| 1684 RTC_NOTREACHED(); | 1683 RTC_NOTREACHED(); |
| 1685 return AllocatedEncoder(NULL, cricket::VideoCodec(), false); | 1684 return AllocatedEncoder(nullptr, cricket::VideoCodec(), false); |
| 1686 } | 1685 } |
| 1687 | 1686 |
| 1688 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( | 1687 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( |
| 1689 AllocatedEncoder* encoder) { | 1688 AllocatedEncoder* encoder) { |
| 1690 RTC_DCHECK_RUN_ON(&thread_checker_); | 1689 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 1691 if (encoder->external) { | 1690 if (encoder->external) { |
| 1692 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); | 1691 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); |
| 1693 } | 1692 } |
| 1694 delete encoder->encoder; | 1693 delete encoder->encoder; |
| 1695 } | 1694 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 VideoCodecSettings codec_settings = *parameters_.codec_settings; | 1896 VideoCodecSettings codec_settings = *parameters_.codec_settings; |
| 1898 | 1897 |
| 1899 webrtc::VideoEncoderConfig encoder_config = | 1898 webrtc::VideoEncoderConfig encoder_config = |
| 1900 CreateVideoEncoderConfig(codec_settings.codec); | 1899 CreateVideoEncoderConfig(codec_settings.codec); |
| 1901 | 1900 |
| 1902 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( | 1901 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( |
| 1903 codec_settings.codec); | 1902 codec_settings.codec); |
| 1904 | 1903 |
| 1905 stream_->ReconfigureVideoEncoder(encoder_config.Copy()); | 1904 stream_->ReconfigureVideoEncoder(encoder_config.Copy()); |
| 1906 | 1905 |
| 1907 encoder_config.encoder_specific_settings = NULL; | 1906 encoder_config.encoder_specific_settings = nullptr; |
| 1908 | 1907 |
| 1909 parameters_.encoder_config = std::move(encoder_config); | 1908 parameters_.encoder_config = std::move(encoder_config); |
| 1910 } | 1909 } |
| 1911 | 1910 |
| 1912 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSend(bool send) { | 1911 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSend(bool send) { |
| 1913 RTC_DCHECK_RUN_ON(&thread_checker_); | 1912 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 1914 sending_ = send; | 1913 sending_ = send; |
| 1915 UpdateSendState(); | 1914 UpdateSendState(); |
| 1916 } | 1915 } |
| 1917 | 1916 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 RTC_DCHECK_RUN_ON(&thread_checker_); | 1953 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 1955 for (uint32_t ssrc : parameters_.config.rtp.ssrcs) | 1954 for (uint32_t ssrc : parameters_.config.rtp.ssrcs) |
| 1956 info.add_ssrc(ssrc); | 1955 info.add_ssrc(ssrc); |
| 1957 | 1956 |
| 1958 if (parameters_.codec_settings) { | 1957 if (parameters_.codec_settings) { |
| 1959 info.codec_name = parameters_.codec_settings->codec.name; | 1958 info.codec_name = parameters_.codec_settings->codec.name; |
| 1960 info.codec_payload_type = rtc::Optional<int>( | 1959 info.codec_payload_type = rtc::Optional<int>( |
| 1961 parameters_.codec_settings->codec.id); | 1960 parameters_.codec_settings->codec.id); |
| 1962 } | 1961 } |
| 1963 | 1962 |
| 1964 if (stream_ == NULL) | 1963 if (stream_ == nullptr) |
| 1965 return info; | 1964 return info; |
| 1966 | 1965 |
| 1967 webrtc::VideoSendStream::Stats stats = stream_->GetStats(); | 1966 webrtc::VideoSendStream::Stats stats = stream_->GetStats(); |
| 1968 | 1967 |
| 1969 if (log_stats) | 1968 if (log_stats) |
| 1970 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); | 1969 LOG(LS_INFO) << stats.ToString(rtc::TimeMillis()); |
| 1971 | 1970 |
| 1972 info.adapt_changes = stats.number_of_cpu_adapt_changes; | 1971 info.adapt_changes = stats.number_of_cpu_adapt_changes; |
| 1973 info.adapt_reason = | 1972 info.adapt_reason = |
| 1974 stats.cpu_limited_resolution ? ADAPTREASON_CPU : ADAPTREASON_NONE; | 1973 stats.cpu_limited_resolution ? ADAPTREASON_CPU : ADAPTREASON_NONE; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 static_cast<float>(first_stream_stats.rtcp_stats.fraction_lost) / | 2020 static_cast<float>(first_stream_stats.rtcp_stats.fraction_lost) / |
| 2022 (1 << 8); | 2021 (1 << 8); |
| 2023 } | 2022 } |
| 2024 | 2023 |
| 2025 return info; | 2024 return info; |
| 2026 } | 2025 } |
| 2027 | 2026 |
| 2028 void WebRtcVideoChannel2::WebRtcVideoSendStream::FillBandwidthEstimationInfo( | 2027 void WebRtcVideoChannel2::WebRtcVideoSendStream::FillBandwidthEstimationInfo( |
| 2029 BandwidthEstimationInfo* bwe_info) { | 2028 BandwidthEstimationInfo* bwe_info) { |
| 2030 RTC_DCHECK_RUN_ON(&thread_checker_); | 2029 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 2031 if (stream_ == NULL) { | 2030 if (stream_ == nullptr) { |
| 2032 return; | 2031 return; |
| 2033 } | 2032 } |
| 2034 webrtc::VideoSendStream::Stats stats = stream_->GetStats(); | 2033 webrtc::VideoSendStream::Stats stats = stream_->GetStats(); |
| 2035 for (std::map<uint32_t, webrtc::VideoSendStream::StreamStats>::iterator it = | 2034 for (std::map<uint32_t, webrtc::VideoSendStream::StreamStats>::iterator it = |
| 2036 stats.substreams.begin(); | 2035 stats.substreams.begin(); |
| 2037 it != stats.substreams.end(); ++it) { | 2036 it != stats.substreams.end(); ++it) { |
| 2038 bwe_info->transmit_bitrate += it->second.total_bitrate_bps; | 2037 bwe_info->transmit_bitrate += it->second.total_bitrate_bps; |
| 2039 bwe_info->retransmit_bitrate += it->second.retransmit_bitrate_bps; | 2038 bwe_info->retransmit_bitrate += it->second.retransmit_bitrate_bps; |
| 2040 } | 2039 } |
| 2041 bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps; | 2040 bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps; |
| 2042 bwe_info->actual_enc_bitrate += stats.media_bitrate_bps; | 2041 bwe_info->actual_enc_bitrate += stats.media_bitrate_bps; |
| 2043 } | 2042 } |
| 2044 | 2043 |
| 2045 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { | 2044 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { |
| 2046 RTC_DCHECK_RUN_ON(&thread_checker_); | 2045 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 2047 if (stream_ != NULL) { | 2046 if (stream_ != nullptr) { |
| 2048 call_->DestroyVideoSendStream(stream_); | 2047 call_->DestroyVideoSendStream(stream_); |
| 2049 } | 2048 } |
| 2050 | 2049 |
| 2051 RTC_CHECK(parameters_.codec_settings); | 2050 RTC_CHECK(parameters_.codec_settings); |
| 2052 RTC_DCHECK_EQ((parameters_.encoder_config.content_type == | 2051 RTC_DCHECK_EQ((parameters_.encoder_config.content_type == |
| 2053 webrtc::VideoEncoderConfig::ContentType::kScreen), | 2052 webrtc::VideoEncoderConfig::ContentType::kScreen), |
| 2054 parameters_.options.is_screencast.value_or(false)) | 2053 parameters_.options.is_screencast.value_or(false)) |
| 2055 << "encoder content type inconsistent with screencast option"; | 2054 << "encoder content type inconsistent with screencast option"; |
| 2056 parameters_.encoder_config.encoder_specific_settings = | 2055 parameters_.encoder_config.encoder_specific_settings = |
| 2057 ConfigureVideoEncoderSettings(parameters_.codec_settings->codec); | 2056 ConfigureVideoEncoderSettings(parameters_.codec_settings->codec); |
| 2058 | 2057 |
| 2059 webrtc::VideoSendStream::Config config = parameters_.config.Copy(); | 2058 webrtc::VideoSendStream::Config config = parameters_.config.Copy(); |
| 2060 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { | 2059 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { |
| 2061 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 2060 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
| 2062 "payload type the set codec. Ignoring RTX."; | 2061 "payload type the set codec. Ignoring RTX."; |
| 2063 config.rtp.rtx.ssrcs.clear(); | 2062 config.rtp.rtx.ssrcs.clear(); |
| 2064 } | 2063 } |
| 2065 stream_ = call_->CreateVideoSendStream(std::move(config), | 2064 stream_ = call_->CreateVideoSendStream(std::move(config), |
| 2066 parameters_.encoder_config.Copy()); | 2065 parameters_.encoder_config.Copy()); |
| 2067 | 2066 |
| 2068 parameters_.encoder_config.encoder_specific_settings = NULL; | 2067 parameters_.encoder_config.encoder_specific_settings = nullptr; |
| 2069 | 2068 |
| 2070 if (source_) { | 2069 if (source_) { |
| 2071 // Do not adapt resolution for screen content as this will likely result in | 2070 // Do not adapt resolution for screen content as this will likely result in |
| 2072 // blurry and unreadable text. | 2071 // blurry and unreadable text. |
| 2073 // |this| acts like a VideoSource to make sure SinkWants are handled on the | 2072 // |this| acts like a VideoSource to make sure SinkWants are handled on the |
| 2074 // correct thread. | 2073 // correct thread. |
| 2075 stream_->SetSource( | 2074 stream_->SetSource( |
| 2076 this, enable_cpu_overuse_detection_ && | 2075 this, enable_cpu_overuse_detection_ && |
| 2077 !parameters_.options.is_screencast.value_or(false) | 2076 !parameters_.options.is_screencast.value_or(false) |
| 2078 ? webrtc::VideoSendStream::DegradationPreference::kBalanced | 2077 ? webrtc::VideoSendStream::DegradationPreference::kBalanced |
| 2079 : webrtc::VideoSendStream::DegradationPreference:: | 2078 : webrtc::VideoSendStream::DegradationPreference:: |
| 2080 kMaintainResolution); | 2079 kMaintainResolution); |
| 2081 } | 2080 } |
| 2082 | 2081 |
| 2083 // Call stream_->Start() if necessary conditions are met. | 2082 // Call stream_->Start() if necessary conditions are met. |
| 2084 UpdateSendState(); | 2083 UpdateSendState(); |
| 2085 } | 2084 } |
| 2086 | 2085 |
| 2087 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2086 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
| 2088 webrtc::Call* call, | 2087 webrtc::Call* call, |
| 2089 const StreamParams& sp, | 2088 const StreamParams& sp, |
| 2090 webrtc::VideoReceiveStream::Config config, | 2089 webrtc::VideoReceiveStream::Config config, |
| 2091 WebRtcVideoDecoderFactory* external_decoder_factory, | 2090 WebRtcVideoDecoderFactory* external_decoder_factory, |
| 2092 bool default_stream, | 2091 bool default_stream, |
| 2093 const std::vector<VideoCodecSettings>& recv_codecs, | 2092 const std::vector<VideoCodecSettings>& recv_codecs, |
| 2094 const webrtc::FlexfecReceiveStream::Config& flexfec_config) | 2093 const webrtc::FlexfecReceiveStream::Config& flexfec_config) |
| 2095 : call_(call), | 2094 : call_(call), |
| 2096 stream_params_(sp), | 2095 stream_params_(sp), |
| 2097 stream_(NULL), | 2096 stream_(nullptr), |
| 2098 default_stream_(default_stream), | 2097 default_stream_(default_stream), |
| 2099 config_(std::move(config)), | 2098 config_(std::move(config)), |
| 2100 flexfec_config_(flexfec_config), | 2099 flexfec_config_(flexfec_config), |
| 2101 flexfec_stream_(nullptr), | 2100 flexfec_stream_(nullptr), |
| 2102 external_decoder_factory_(external_decoder_factory), | 2101 external_decoder_factory_(external_decoder_factory), |
| 2103 sink_(NULL), | 2102 sink_(nullptr), |
| 2104 first_frame_timestamp_(-1), | 2103 first_frame_timestamp_(-1), |
| 2105 estimated_remote_start_ntp_time_ms_(0) { | 2104 estimated_remote_start_ntp_time_ms_(0) { |
| 2106 config_.renderer = this; | 2105 config_.renderer = this; |
| 2107 std::vector<AllocatedDecoder> old_decoders; | 2106 std::vector<AllocatedDecoder> old_decoders; |
| 2108 ConfigureCodecs(recv_codecs, &old_decoders); | 2107 ConfigureCodecs(recv_codecs, &old_decoders); |
| 2109 RecreateWebRtcStream(); | 2108 RecreateWebRtcStream(); |
| 2110 RTC_DCHECK(old_decoders.empty()); | 2109 RTC_DCHECK(old_decoders.empty()); |
| 2111 } | 2110 } |
| 2112 | 2111 |
| 2113 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: | 2112 WebRtcVideoChannel2::WebRtcVideoReceiveStream::AllocatedDecoder:: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 | 2159 |
| 2161 for (size_t i = 0; i < old_decoders->size(); ++i) { | 2160 for (size_t i = 0; i < old_decoders->size(); ++i) { |
| 2162 if ((*old_decoders)[i].type == type) { | 2161 if ((*old_decoders)[i].type == type) { |
| 2163 AllocatedDecoder decoder = (*old_decoders)[i]; | 2162 AllocatedDecoder decoder = (*old_decoders)[i]; |
| 2164 (*old_decoders)[i] = old_decoders->back(); | 2163 (*old_decoders)[i] = old_decoders->back(); |
| 2165 old_decoders->pop_back(); | 2164 old_decoders->pop_back(); |
| 2166 return decoder; | 2165 return decoder; |
| 2167 } | 2166 } |
| 2168 } | 2167 } |
| 2169 | 2168 |
| 2170 if (external_decoder_factory_ != NULL) { | 2169 if (external_decoder_factory_ != nullptr) { |
| 2171 webrtc::VideoDecoder* decoder = | 2170 webrtc::VideoDecoder* decoder = |
| 2172 external_decoder_factory_->CreateVideoDecoderWithParams( | 2171 external_decoder_factory_->CreateVideoDecoderWithParams( |
| 2173 type, {stream_params_.id}); | 2172 type, {stream_params_.id}); |
| 2174 if (decoder != NULL) { | 2173 if (decoder != nullptr) { |
| 2175 return AllocatedDecoder(decoder, type, true /* is_external */); | 2174 return AllocatedDecoder(decoder, type, true /* is_external */); |
| 2176 } | 2175 } |
| 2177 } | 2176 } |
| 2178 | 2177 |
| 2179 InternalDecoderFactory internal_decoder_factory; | 2178 InternalDecoderFactory internal_decoder_factory; |
| 2180 return AllocatedDecoder(internal_decoder_factory.CreateVideoDecoderWithParams( | 2179 return AllocatedDecoder(internal_decoder_factory.CreateVideoDecoderWithParams( |
| 2181 type, {stream_params_.id}), | 2180 type, {stream_params_.id}), |
| 2182 type, false /* is_external */); | 2181 type, false /* is_external */); |
| 2183 } | 2182 } |
| 2184 | 2183 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 if (first_frame_timestamp_ < 0) | 2321 if (first_frame_timestamp_ < 0) |
| 2323 first_frame_timestamp_ = frame.timestamp(); | 2322 first_frame_timestamp_ = frame.timestamp(); |
| 2324 int64_t rtp_time_elapsed_since_first_frame = | 2323 int64_t rtp_time_elapsed_since_first_frame = |
| 2325 (timestamp_wraparound_handler_.Unwrap(frame.timestamp()) - | 2324 (timestamp_wraparound_handler_.Unwrap(frame.timestamp()) - |
| 2326 first_frame_timestamp_); | 2325 first_frame_timestamp_); |
| 2327 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / | 2326 int64_t elapsed_time_ms = rtp_time_elapsed_since_first_frame / |
| 2328 (cricket::kVideoCodecClockrate / 1000); | 2327 (cricket::kVideoCodecClockrate / 1000); |
| 2329 if (frame.ntp_time_ms() > 0) | 2328 if (frame.ntp_time_ms() > 0) |
| 2330 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; | 2329 estimated_remote_start_ntp_time_ms_ = frame.ntp_time_ms() - elapsed_time_ms; |
| 2331 | 2330 |
| 2332 if (sink_ == NULL) { | 2331 if (sink_ == nullptr) { |
| 2333 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink."; | 2332 LOG(LS_WARNING) << "VideoReceiveStream not connected to a VideoSink."; |
| 2334 return; | 2333 return; |
| 2335 } | 2334 } |
| 2336 | 2335 |
| 2337 sink_->OnFrame(frame); | 2336 sink_->OnFrame(frame); |
| 2338 } | 2337 } |
| 2339 | 2338 |
| 2340 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { | 2339 bool WebRtcVideoChannel2::WebRtcVideoReceiveStream::IsDefaultStream() const { |
| 2341 return default_stream_; | 2340 return default_stream_; |
| 2342 } | 2341 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2527 rtx_mapping[video_codecs[i].codec.id] != | 2526 rtx_mapping[video_codecs[i].codec.id] != |
| 2528 ulpfec_config.red_payload_type) { | 2527 ulpfec_config.red_payload_type) { |
| 2529 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2528 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2530 } | 2529 } |
| 2531 } | 2530 } |
| 2532 | 2531 |
| 2533 return video_codecs; | 2532 return video_codecs; |
| 2534 } | 2533 } |
| 2535 | 2534 |
| 2536 } // namespace cricket | 2535 } // namespace cricket |
| OLD | NEW |