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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 // Mark screenshare parameter as being updated, then test for any other | 1620 // Mark screenshare parameter as being updated, then test for any other |
1620 // changes that may require codec reconfiguration. | 1621 // changes that may require codec reconfiguration. |
1621 old_options.is_screencast = options->is_screencast; | 1622 old_options.is_screencast = options->is_screencast; |
1622 } | 1623 } |
1623 if (parameters_.options != old_options) { | 1624 if (parameters_.options != old_options) { |
1624 ReconfigureEncoder(); | 1625 ReconfigureEncoder(); |
1625 } | 1626 } |
1626 } | 1627 } |
1627 | 1628 |
1628 if (source_ && stream_) { | 1629 if (source_ && stream_) { |
1629 stream_->SetSource( | 1630 stream_->SetSource(nullptr, DegradationPreference::kDegradationDisabled); |
1630 nullptr, webrtc::VideoSendStream::DegradationPreference::kBalanced); | |
1631 } | 1631 } |
1632 // Switch to the new source. | 1632 // Switch to the new source. |
1633 source_ = source; | 1633 source_ = source; |
1634 if (source && stream_) { | 1634 if (source && stream_) { |
1635 // Do not adapt resolution for screen content as this will likely | 1635 stream_->SetSource(this, GetDegradationPreference()); |
1636 // result in blurry and unreadable text. | |
1637 // |this| acts like a VideoSource to make sure SinkWants are handled on the | |
1638 // correct thread. | |
1639 stream_->SetSource( | |
1640 this, enable_cpu_overuse_detection_ && | |
1641 !parameters_.options.is_screencast.value_or(false) | |
1642 ? webrtc::VideoSendStream::DegradationPreference::kBalanced | |
1643 : webrtc::VideoSendStream::DegradationPreference:: | |
1644 kMaintainResolution); | |
1645 } | 1636 } |
1646 return true; | 1637 return true; |
1647 } | 1638 } |
1648 | 1639 |
| 1640 webrtc::VideoSendStream::DegradationPreference |
| 1641 WebRtcVideoChannel2::WebRtcVideoSendStream::GetDegradationPreference() const { |
| 1642 // Do not adapt resolution for screen content as this will likely |
| 1643 // result in blurry and unreadable text. |
| 1644 // |this| acts like a VideoSource to make sure SinkWants are handled on the |
| 1645 // correct thread. |
| 1646 DegradationPreference degradation_preference; |
| 1647 if (!enable_cpu_overuse_detection_) { |
| 1648 degradation_preference = DegradationPreference::kDegradationDisabled; |
| 1649 } else { |
| 1650 if (parameters_.options.is_screencast.value_or(false)) { |
| 1651 degradation_preference = DegradationPreference::kMaintainResolution; |
| 1652 } else { |
| 1653 degradation_preference = DegradationPreference::kMaintainFramerate; |
| 1654 } |
| 1655 } |
| 1656 return degradation_preference; |
| 1657 } |
| 1658 |
1649 const std::vector<uint32_t>& | 1659 const std::vector<uint32_t>& |
1650 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { | 1660 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { |
1651 return ssrcs_; | 1661 return ssrcs_; |
1652 } | 1662 } |
1653 | 1663 |
1654 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder | 1664 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder |
1655 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder( | 1665 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder( |
1656 const VideoCodec& codec, | 1666 const VideoCodec& codec, |
1657 bool force_encoder_allocation) { | 1667 bool force_encoder_allocation) { |
1658 RTC_DCHECK_RUN_ON(&thread_checker_); | 1668 RTC_DCHECK_RUN_ON(&thread_checker_); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 2086 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
2077 "payload type the set codec. Ignoring RTX."; | 2087 "payload type the set codec. Ignoring RTX."; |
2078 config.rtp.rtx.ssrcs.clear(); | 2088 config.rtp.rtx.ssrcs.clear(); |
2079 } | 2089 } |
2080 stream_ = call_->CreateVideoSendStream(std::move(config), | 2090 stream_ = call_->CreateVideoSendStream(std::move(config), |
2081 parameters_.encoder_config.Copy()); | 2091 parameters_.encoder_config.Copy()); |
2082 | 2092 |
2083 parameters_.encoder_config.encoder_specific_settings = NULL; | 2093 parameters_.encoder_config.encoder_specific_settings = NULL; |
2084 | 2094 |
2085 if (source_) { | 2095 if (source_) { |
2086 // Do not adapt resolution for screen content as this will likely result in | 2096 stream_->SetSource(this, GetDegradationPreference()); |
2087 // blurry and unreadable text. | |
2088 // |this| acts like a VideoSource to make sure SinkWants are handled on the | |
2089 // correct thread. | |
2090 stream_->SetSource( | |
2091 this, enable_cpu_overuse_detection_ && | |
2092 !parameters_.options.is_screencast.value_or(false) | |
2093 ? webrtc::VideoSendStream::DegradationPreference::kBalanced | |
2094 : webrtc::VideoSendStream::DegradationPreference:: | |
2095 kMaintainResolution); | |
2096 } | 2097 } |
2097 | 2098 |
2098 // Call stream_->Start() if necessary conditions are met. | 2099 // Call stream_->Start() if necessary conditions are met. |
2099 UpdateSendState(); | 2100 UpdateSendState(); |
2100 } | 2101 } |
2101 | 2102 |
2102 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( | 2103 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( |
2103 webrtc::Call* call, | 2104 webrtc::Call* call, |
2104 const StreamParams& sp, | 2105 const StreamParams& sp, |
2105 webrtc::VideoReceiveStream::Config config, | 2106 webrtc::VideoReceiveStream::Config config, |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 rtx_mapping[video_codecs[i].codec.id] != | 2543 rtx_mapping[video_codecs[i].codec.id] != |
2543 ulpfec_config.red_payload_type) { | 2544 ulpfec_config.red_payload_type) { |
2544 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2545 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2545 } | 2546 } |
2546 } | 2547 } |
2547 | 2548 |
2548 return video_codecs; | 2549 return video_codecs; |
2549 } | 2550 } |
2550 | 2551 |
2551 } // namespace cricket | 2552 } // namespace cricket |
OLD | NEW |