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