Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(942)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 2716643002: Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " 2097 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX "
2088 "payload type the set codec. Ignoring RTX."; 2098 "payload type the set codec. Ignoring RTX.";
2089 config.rtp.rtx.ssrcs.clear(); 2099 config.rtp.rtx.ssrcs.clear();
2090 } 2100 }
2091 stream_ = call_->CreateVideoSendStream(std::move(config), 2101 stream_ = call_->CreateVideoSendStream(std::move(config),
2092 parameters_.encoder_config.Copy()); 2102 parameters_.encoder_config.Copy());
2093 2103
2094 parameters_.encoder_config.encoder_specific_settings = NULL; 2104 parameters_.encoder_config.encoder_specific_settings = NULL;
2095 2105
2096 if (source_) { 2106 if (source_) {
2097 // Do not adapt resolution for screen content as this will likely result in 2107 stream_->SetSource(this, GetDegradationPreference());
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);
2107 } 2108 }
2108 2109
2109 // Call stream_->Start() if necessary conditions are met. 2110 // Call stream_->Start() if necessary conditions are met.
2110 UpdateSendState(); 2111 UpdateSendState();
2111 } 2112 }
2112 2113
2113 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( 2114 WebRtcVideoChannel2::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream(
2114 webrtc::Call* call, 2115 webrtc::Call* call,
2115 const StreamParams& sp, 2116 const StreamParams& sp,
2116 webrtc::VideoReceiveStream::Config config, 2117 webrtc::VideoReceiveStream::Config config,
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 rtx_mapping[video_codecs[i].codec.id] != 2560 rtx_mapping[video_codecs[i].codec.id] !=
2560 ulpfec_config.red_payload_type) { 2561 ulpfec_config.red_payload_type) {
2561 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2562 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2562 } 2563 }
2563 } 2564 }
2564 2565
2565 return video_codecs; 2566 return video_codecs;
2566 } 2567 }
2567 2568
2568 } // namespace cricket 2569 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698