| 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 20 matching lines...) Expand all Loading... |
| 31 #include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h" | 31 #include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h" |
| 32 #include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h" | 32 #include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h" |
| 33 #include "webrtc/media/engine/webrtcmediaengine.h" | 33 #include "webrtc/media/engine/webrtcmediaengine.h" |
| 34 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 34 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 35 #include "webrtc/media/engine/webrtcvoiceengine.h" | 35 #include "webrtc/media/engine/webrtcvoiceengine.h" |
| 36 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" | 36 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" |
| 37 #include "webrtc/system_wrappers/include/field_trial.h" | 37 #include "webrtc/system_wrappers/include/field_trial.h" |
| 38 #include "webrtc/video_decoder.h" | 38 #include "webrtc/video_decoder.h" |
| 39 #include "webrtc/video_encoder.h" | 39 #include "webrtc/video_encoder.h" |
| 40 | 40 |
| 41 using DegradationPreference = webrtc::VideoSendStream::DegradationPreference; | |
| 42 | |
| 43 namespace cricket { | 41 namespace cricket { |
| 44 namespace { | 42 namespace { |
| 43 |
| 45 // If this field trial is enabled, we will enable sending FlexFEC and disable | 44 // If this field trial is enabled, we will enable sending FlexFEC and disable |
| 46 // sending ULPFEC whenever the former has been negotiated. Receiving FlexFEC | 45 // sending ULPFEC whenever the former has been negotiated. Receiving FlexFEC |
| 47 // is enabled whenever FlexFEC has been negotiated. | 46 // is enabled whenever FlexFEC has been negotiated. |
| 48 bool IsFlexfecFieldTrialEnabled() { | 47 bool IsFlexfecFieldTrialEnabled() { |
| 49 return webrtc::field_trial::FindFullName("WebRTC-FlexFEC-03") == "Enabled"; | 48 return webrtc::field_trial::FindFullName("WebRTC-FlexFEC-03") == "Enabled"; |
| 50 } | 49 } |
| 51 | 50 |
| 52 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. | 51 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. |
| 53 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { | 52 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { |
| 54 public: | 53 public: |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 // Mark screenshare parameter as being updated, then test for any other | 1630 // Mark screenshare parameter as being updated, then test for any other |
| 1632 // changes that may require codec reconfiguration. | 1631 // changes that may require codec reconfiguration. |
| 1633 old_options.is_screencast = options->is_screencast; | 1632 old_options.is_screencast = options->is_screencast; |
| 1634 } | 1633 } |
| 1635 if (parameters_.options != old_options) { | 1634 if (parameters_.options != old_options) { |
| 1636 ReconfigureEncoder(); | 1635 ReconfigureEncoder(); |
| 1637 } | 1636 } |
| 1638 } | 1637 } |
| 1639 | 1638 |
| 1640 if (source_ && stream_) { | 1639 if (source_ && stream_) { |
| 1641 stream_->SetSource(nullptr, DegradationPreference::kDegradationDisabled); | 1640 stream_->SetSource( |
| 1641 nullptr, webrtc::VideoSendStream::DegradationPreference::kBalanced); |
| 1642 } | 1642 } |
| 1643 // Switch to the new source. | 1643 // Switch to the new source. |
| 1644 source_ = source; | 1644 source_ = source; |
| 1645 if (source && stream_) { | 1645 if (source && stream_) { |
| 1646 stream_->SetSource(this, GetDegradationPreference()); | 1646 // Do not adapt resolution for screen content as this will likely |
| 1647 // result in blurry and unreadable text. |
| 1648 // |this| acts like a VideoSource to make sure SinkWants are handled on the |
| 1649 // correct thread. |
| 1650 stream_->SetSource( |
| 1651 this, enable_cpu_overuse_detection_ && |
| 1652 !parameters_.options.is_screencast.value_or(false) |
| 1653 ? webrtc::VideoSendStream::DegradationPreference::kBalanced |
| 1654 : webrtc::VideoSendStream::DegradationPreference:: |
| 1655 kMaintainResolution); |
| 1647 } | 1656 } |
| 1648 return true; | 1657 return true; |
| 1649 } | 1658 } |
| 1650 | 1659 |
| 1651 webrtc::VideoSendStream::DegradationPreference | |
| 1652 WebRtcVideoChannel2::WebRtcVideoSendStream::GetDegradationPreference() const { | |
| 1653 // Do not adapt resolution for screen content as this will likely | |
| 1654 // result in blurry and unreadable text. | |
| 1655 // |this| acts like a VideoSource to make sure SinkWants are handled on the | |
| 1656 // correct thread. | |
| 1657 DegradationPreference degradation_preference; | |
| 1658 if (!enable_cpu_overuse_detection_) { | |
| 1659 degradation_preference = DegradationPreference::kDegradationDisabled; | |
| 1660 } else { | |
| 1661 if (parameters_.options.is_screencast.value_or(false)) { | |
| 1662 degradation_preference = DegradationPreference::kMaintainResolution; | |
| 1663 } else { | |
| 1664 degradation_preference = DegradationPreference::kMaintainFramerate; | |
| 1665 } | |
| 1666 } | |
| 1667 return degradation_preference; | |
| 1668 } | |
| 1669 | |
| 1670 const std::vector<uint32_t>& | 1660 const std::vector<uint32_t>& |
| 1671 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { | 1661 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { |
| 1672 return ssrcs_; | 1662 return ssrcs_; |
| 1673 } | 1663 } |
| 1674 | 1664 |
| 1675 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder | 1665 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder |
| 1676 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder( | 1666 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder( |
| 1677 const VideoCodec& codec, | 1667 const VideoCodec& codec, |
| 1678 bool force_encoder_allocation) { | 1668 bool force_encoder_allocation) { |
| 1679 RTC_DCHECK_RUN_ON(&thread_checker_); | 1669 RTC_DCHECK_RUN_ON(&thread_checker_); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 2087 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
| 2098 "payload type the set codec. Ignoring RTX."; | 2088 "payload type the set codec. Ignoring RTX."; |
| 2099 config.rtp.rtx.ssrcs.clear(); | 2089 config.rtp.rtx.ssrcs.clear(); |
| 2100 } | 2090 } |
| 2101 stream_ = call_->CreateVideoSendStream(std::move(config), | 2091 stream_ = call_->CreateVideoSendStream(std::move(config), |
| 2102 parameters_.encoder_config.Copy()); | 2092 parameters_.encoder_config.Copy()); |
| 2103 | 2093 |
| 2104 parameters_.encoder_config.encoder_specific_settings = NULL; | 2094 parameters_.encoder_config.encoder_specific_settings = NULL; |
| 2105 | 2095 |
| 2106 if (source_) { | 2096 if (source_) { |
| 2107 stream_->SetSource(this, GetDegradationPreference()); | 2097 // Do not adapt resolution for screen content as this will likely result in |
| 2098 // blurry and unreadable text. |
| 2099 // |this| acts like a VideoSource to make sure SinkWants are handled on the |
| 2100 // correct thread. |
| 2101 stream_->SetSource( |
| 2102 this, enable_cpu_overuse_detection_ && |
| 2103 !parameters_.options.is_screencast.value_or(false) |
| 2104 ? webrtc::VideoSendStream::DegradationPreference::kBalanced |
| 2105 : webrtc::VideoSendStream::DegradationPreference:: |
| 2106 kMaintainResolution); |
| 2108 } | 2107 } |
| 2109 | 2108 |
| 2110 // Call stream_->Start() if necessary conditions are met. | 2109 // Call stream_->Start() if necessary conditions are met. |
| 2111 UpdateSendState(); | 2110 UpdateSendState(); |
| 2112 } | 2111 } |
| 2113 | 2112 |
| 2114 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2113 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
| 2115 webrtc::Call* call, | 2114 webrtc::Call* call, |
| 2116 const StreamParams& sp, | 2115 const StreamParams& sp, |
| 2117 webrtc::VideoReceiveStream::Config config, | 2116 webrtc::VideoReceiveStream::Config config, |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 rtx_mapping[video_codecs[i].codec.id] != | 2559 rtx_mapping[video_codecs[i].codec.id] != |
| 2561 ulpfec_config.red_payload_type) { | 2560 ulpfec_config.red_payload_type) { |
| 2562 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2561 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2563 } | 2562 } |
| 2564 } | 2563 } |
| 2565 | 2564 |
| 2566 return video_codecs; | 2565 return video_codecs; |
| 2567 } | 2566 } |
| 2568 | 2567 |
| 2569 } // namespace cricket | 2568 } // namespace cricket |
| OLD | NEW |