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

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

Issue 1695263002: Move direct use of VideoCapturer::VideoAdapter to VideoSinkWants. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebased Created 4 years, 10 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
11 #include "webrtc/media/engine/webrtcvideoengine2.h" 11 #include "webrtc/media/engine/webrtcvideoengine2.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 16
17 #include "webrtc/base/asyncinvoker.h"
17 #include "webrtc/base/buffer.h" 18 #include "webrtc/base/buffer.h"
18 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
19 #include "webrtc/base/stringutils.h" 20 #include "webrtc/base/stringutils.h"
20 #include "webrtc/base/timeutils.h" 21 #include "webrtc/base/timeutils.h"
21 #include "webrtc/base/trace_event.h" 22 #include "webrtc/base/trace_event.h"
22 #include "webrtc/call.h" 23 #include "webrtc/call.h"
23 #include "webrtc/media/base/videocapturer.h" 24 #include "webrtc/media/base/videocapturer.h"
24 #include "webrtc/media/base/videorenderer.h" 25 #include "webrtc/media/base/videorenderer.h"
25 #include "webrtc/media/engine/constants.h" 26 #include "webrtc/media/engine/constants.h"
26 #include "webrtc/media/engine/simulcast.h" 27 #include "webrtc/media/engine/simulcast.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (width * height <= 320 * 240) { 308 if (width * height <= 320 * 240) {
308 return 600; 309 return 600;
309 } else if (width * height <= 640 * 480) { 310 } else if (width * height <= 640 * 480) {
310 return 1700; 311 return 1700;
311 } else if (width * height <= 960 * 540) { 312 } else if (width * height <= 960 * 540) {
312 return 2000; 313 return 2000;
313 } else { 314 } else {
314 return 2500; 315 return 2500;
315 } 316 }
316 } 317 }
318
317 } // namespace 319 } // namespace
318 320
319 // Constants defined in webrtc/media/engine/constants.h 321 // Constants defined in webrtc/media/engine/constants.h
320 // TODO(pbos): Move these to a separate constants.cc file. 322 // TODO(pbos): Move these to a separate constants.cc file.
321 const int kMinVideoBitrate = 30; 323 const int kMinVideoBitrate = 30;
322 const int kStartVideoBitrate = 300; 324 const int kStartVideoBitrate = 300;
323 325
324 const int kVideoMtu = 1200; 326 const int kVideoMtu = 1200;
325 const int kVideoRtpBufferSize = 65536; 327 const int kVideoRtpBufferSize = 65536;
326 328
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 995
994 rtc::CritScope stream_lock(&stream_crit_); 996 rtc::CritScope stream_lock(&stream_crit_);
995 997
996 if (!ValidateSendSsrcAvailability(sp)) 998 if (!ValidateSendSsrcAvailability(sp))
997 return false; 999 return false;
998 1000
999 for (uint32_t used_ssrc : sp.ssrcs) 1001 for (uint32_t used_ssrc : sp.ssrcs)
1000 send_ssrcs_.insert(used_ssrc); 1002 send_ssrcs_.insert(used_ssrc);
1001 1003
1002 webrtc::VideoSendStream::Config config(this); 1004 webrtc::VideoSendStream::Config config(this);
1003 config.overuse_callback = this; 1005 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream(
1004 1006 call_, sp, config, external_encoder_factory_, signal_cpu_adaptation_,
1005 WebRtcVideoSendStream* stream = 1007 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_,
1006 new WebRtcVideoSendStream(call_, sp, config, external_encoder_factory_, 1008 send_params_);
1007 bitrate_config_.max_bitrate_bps, send_codec_,
1008 send_rtp_extensions_, send_params_);
1009 1009
1010 uint32_t ssrc = sp.first_ssrc(); 1010 uint32_t ssrc = sp.first_ssrc();
1011 RTC_DCHECK(ssrc != 0); 1011 RTC_DCHECK(ssrc != 0);
1012 send_streams_[ssrc] = stream; 1012 send_streams_[ssrc] = stream;
1013 1013
1014 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { 1014 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) {
1015 rtcp_receiver_report_ssrc_ = ssrc; 1015 rtcp_receiver_report_ssrc_ = ssrc;
1016 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " 1016 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added "
1017 "a send stream."; 1017 "a send stream.";
1018 for (auto& kv : receive_streams_) 1018 for (auto& kv : receive_streams_)
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 1405
1406 // Speculative change to increase the outbound socket buffer size. 1406 // Speculative change to increase the outbound socket buffer size.
1407 // In b/15152257, we are seeing a significant number of packets discarded 1407 // In b/15152257, we are seeing a significant number of packets discarded
1408 // due to lack of socket buffer space, although it's not yet clear what the 1408 // due to lack of socket buffer space, although it's not yet clear what the
1409 // ideal value should be. 1409 // ideal value should be.
1410 MediaChannel::SetOption(NetworkInterface::ST_RTP, 1410 MediaChannel::SetOption(NetworkInterface::ST_RTP,
1411 rtc::Socket::OPT_SNDBUF, 1411 rtc::Socket::OPT_SNDBUF,
1412 kVideoRtpBufferSize); 1412 kVideoRtpBufferSize);
1413 } 1413 }
1414 1414
1415 void WebRtcVideoChannel2::OnLoadUpdate(Load load) {
1416 // OnLoadUpdate can not take any locks that are held while creating streams
1417 // etc. Doing so establishes lock-order inversions between the webrtc process
1418 // thread on stream creation and locks such as stream_crit_ while calling out.
1419 rtc::CritScope stream_lock(&capturer_crit_);
1420 if (!signal_cpu_adaptation_)
1421 return;
1422 // Do not adapt resolution for screen content as this will likely result in
1423 // blurry and unreadable text.
1424 for (auto& kv : capturers_) {
1425 if (kv.second != nullptr
1426 && !kv.second->IsScreencast()
1427 && kv.second->video_adapter() != nullptr) {
1428 kv.second->video_adapter()->OnCpuResolutionRequest(
1429 load == kOveruse ? CoordinatedVideoAdapter::DOWNGRADE
1430 : CoordinatedVideoAdapter::UPGRADE);
1431 }
1432 }
1433 }
1434
1435 bool WebRtcVideoChannel2::SendRtp(const uint8_t* data, 1415 bool WebRtcVideoChannel2::SendRtp(const uint8_t* data,
1436 size_t len, 1416 size_t len,
1437 const webrtc::PacketOptions& options) { 1417 const webrtc::PacketOptions& options) {
1438 rtc::Buffer packet(data, len, kMaxRtpPacketLen); 1418 rtc::Buffer packet(data, len, kMaxRtpPacketLen);
1439 rtc::PacketOptions rtc_options; 1419 rtc::PacketOptions rtc_options;
1440 rtc_options.packet_id = options.packet_id; 1420 rtc_options.packet_id = options.packet_id;
1441 return MediaChannel::SendPacket(&packet, rtc_options); 1421 return MediaChannel::SendPacket(&packet, rtc_options);
1442 } 1422 }
1443 1423
1444 bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) { 1424 bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 external_encoder(nullptr), 1463 external_encoder(nullptr),
1484 type(type), 1464 type(type),
1485 external(external) { 1465 external(external) {
1486 if (external) { 1466 if (external) {
1487 external_encoder = encoder; 1467 external_encoder = encoder;
1488 this->encoder = 1468 this->encoder =
1489 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); 1469 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder);
1490 } 1470 }
1491 } 1471 }
1492 1472
1473 // Proxy class used for marshalling calls to webrtc::LoadObserver::OnLoadUpdate
1474 // from a media engine thread to the worker thread.
1475 class WebRtcVideoChannel2::WebRtcVideoSendStream::LoadObserverProxy {
pthatcher1 2016/02/25 07:40:30 This still looks too complex to me, but maybe I'm
perkj_webrtc 2016/02/25 13:57:07 I am sure that is not true. But I am not sure how
1476 public:
1477 explicit LoadObserverProxy(webrtc::LoadObserver* observer) {
1478 helper_ = new rtc::RefCountedObject<Helper>(observer);
1479 }
1480 ~LoadObserverProxy() { helper_->Detach(); }
1481
1482 webrtc::LoadObserver* proxy() { return helper_; }
1483
1484 private:
1485 class Helper : public webrtc::LoadObserver, public rtc::RefCountInterface {
1486 public:
1487 explicit Helper(webrtc::LoadObserver* observer)
1488 : thread_(rtc::Thread::Current()), observer_(observer) {}
1489 void Detach() {
1490 RTC_DCHECK(thread_checker_.CalledOnValidThread());
1491 observer_ = nullptr;
1492 }
1493 void OnLoadUpdate(webrtc::LoadObserver::Load load) override {
1494 if (rtc::Thread::Current() == thread_) {
1495 observer_->OnLoadUpdate(load);
1496 return;
1497 }
1498 invoker_.AsyncInvoke<void>(
1499 thread_, rtc::Bind(&Helper::OnLoadUpdateOnCorrectThread, this, load));
1500 }
1501 void OnLoadUpdateOnCorrectThread(webrtc::LoadObserver::Load load) {
1502 RTC_DCHECK(thread_checker_.CalledOnValidThread());
1503 if (observer_) {
1504 observer_->OnLoadUpdate(load);
1505 }
1506 }
1507
1508 private:
1509 rtc::ThreadChecker thread_checker_;
1510 rtc::AsyncInvoker invoker_;
1511 rtc::Thread* thread_;
1512 webrtc::LoadObserver* observer_;
1513 };
1514
1515 rtc::scoped_refptr<Helper> helper_;
1516 };
1517
1493 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( 1518 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
1494 webrtc::Call* call, 1519 webrtc::Call* call,
1495 const StreamParams& sp, 1520 const StreamParams& sp,
1496 const webrtc::VideoSendStream::Config& config, 1521 const webrtc::VideoSendStream::Config& config,
1497 WebRtcVideoEncoderFactory* external_encoder_factory, 1522 WebRtcVideoEncoderFactory* external_encoder_factory,
1523 bool enable_cpu_overuse_detection,
1498 int max_bitrate_bps, 1524 int max_bitrate_bps,
1499 const rtc::Optional<VideoCodecSettings>& codec_settings, 1525 const rtc::Optional<VideoCodecSettings>& codec_settings,
1500 const std::vector<webrtc::RtpExtension>& rtp_extensions, 1526 const std::vector<webrtc::RtpExtension>& rtp_extensions,
1501 // TODO(deadbeef): Don't duplicate information between send_params, 1527 // TODO(deadbeef): Don't duplicate information between send_params,
1502 // rtp_extensions, options, etc. 1528 // rtp_extensions, options, etc.
1503 const VideoSendParameters& send_params) 1529 const VideoSendParameters& send_params)
1504 : ssrcs_(sp.ssrcs), 1530 : ssrcs_(sp.ssrcs),
1505 ssrc_groups_(sp.ssrc_groups), 1531 ssrc_groups_(sp.ssrc_groups),
1506 call_(call), 1532 call_(call),
1533 cpu_adapted_(false),
1534 number_of_cpu_adapt_changes_(0),
1535 load_proxy_(new LoadObserverProxy(this)),
1507 external_encoder_factory_(external_encoder_factory), 1536 external_encoder_factory_(external_encoder_factory),
1508 stream_(NULL), 1537 stream_(NULL),
1509 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), 1538 parameters_(config, send_params.options, max_bitrate_bps, codec_settings),
1510 pending_encoder_reconfiguration_(false), 1539 pending_encoder_reconfiguration_(false),
1511 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), 1540 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false),
1512 capturer_(NULL), 1541 capturer_(NULL),
1513 sending_(false), 1542 sending_(false),
1514 muted_(false), 1543 muted_(false),
1515 old_adapt_changes_(0),
1516 first_frame_timestamp_ms_(0), 1544 first_frame_timestamp_ms_(0),
1517 last_frame_timestamp_ms_(0) { 1545 last_frame_timestamp_ms_(0) {
1518 parameters_.config.rtp.max_packet_size = kVideoMtu; 1546 parameters_.config.rtp.max_packet_size = kVideoMtu;
1519 parameters_.conference_mode = send_params.conference_mode; 1547 parameters_.conference_mode = send_params.conference_mode;
1520 1548
1521 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1549 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1522 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1550 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1523 &parameters_.config.rtp.rtx.ssrcs); 1551 &parameters_.config.rtp.rtx.ssrcs);
1524 parameters_.config.rtp.c_name = sp.cname; 1552 parameters_.config.rtp.c_name = sp.cname;
1525 parameters_.config.rtp.extensions = rtp_extensions; 1553 parameters_.config.rtp.extensions = rtp_extensions;
1526 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size 1554 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size
1527 ? webrtc::RtcpMode::kReducedSize 1555 ? webrtc::RtcpMode::kReducedSize
1528 : webrtc::RtcpMode::kCompound; 1556 : webrtc::RtcpMode::kCompound;
1557 parameters_.config.overuse_callback =
1558 enable_cpu_overuse_detection ? load_proxy_->proxy() : nullptr;
1529 1559
1530 if (codec_settings) { 1560 if (codec_settings) {
1531 SetCodecAndOptions(*codec_settings, parameters_.options); 1561 SetCodecAndOptions(*codec_settings, parameters_.options);
1532 } 1562 }
1533 } 1563 }
1534 1564
1535 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { 1565 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
1536 DisconnectCapturer(); 1566 DisconnectCapturer();
1537 if (stream_ != NULL) { 1567 if (stream_ != NULL) {
1538 call_->DestroyVideoSendStream(stream_); 1568 call_->DestroyVideoSendStream(stream_);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 muted_ = mute; 1672 muted_ = mute;
1643 } 1673 }
1644 1674
1645 bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { 1675 bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() {
1646 cricket::VideoCapturer* capturer; 1676 cricket::VideoCapturer* capturer;
1647 { 1677 {
1648 rtc::CritScope cs(&lock_); 1678 rtc::CritScope cs(&lock_);
1649 if (capturer_ == NULL) 1679 if (capturer_ == NULL)
1650 return false; 1680 return false;
1651 1681
1652 if (capturer_->video_adapter() != nullptr)
1653 old_adapt_changes_ += capturer_->video_adapter()->adaptation_changes();
1654
1655 capturer = capturer_; 1682 capturer = capturer_;
1656 capturer_ = NULL; 1683 capturer_ = NULL;
1657 } 1684 }
1658 capturer->RemoveSink(this); 1685 capturer->RemoveSink(this);
1659 1686
1660 return true; 1687 return true;
1661 } 1688 }
1662 1689
1663 const std::vector<uint32_t>& 1690 const std::vector<uint32_t>&
1664 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { 1691 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 params.options ? *params.options : parameters_.options); 1842 params.options ? *params.options : parameters_.options);
1816 return; 1843 return;
1817 } else if (params.options) { 1844 } else if (params.options) {
1818 // Reconfigure if codecs are already set. 1845 // Reconfigure if codecs are already set.
1819 if (parameters_.codec_settings) { 1846 if (parameters_.codec_settings) {
1820 SetCodecAndOptions(*parameters_.codec_settings, *params.options); 1847 SetCodecAndOptions(*parameters_.codec_settings, *params.options);
1821 return; 1848 return;
1822 } else { 1849 } else {
1823 parameters_.options = *params.options; 1850 parameters_.options = *params.options;
1824 } 1851 }
1825 } 1852 } else if (params.conference_mode && parameters_.codec_settings) {
1826 else if (params.conference_mode && parameters_.codec_settings) {
1827 SetCodecAndOptions(*parameters_.codec_settings, parameters_.options); 1853 SetCodecAndOptions(*parameters_.codec_settings, parameters_.options);
1828 return; 1854 return;
1829 } 1855 }
1830 if (recreate_stream) { 1856 if (recreate_stream) {
1831 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; 1857 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters";
1832 RecreateWebRtcStream(); 1858 RecreateWebRtcStream();
1833 } 1859 }
1834 } 1860 }
1835 1861
1836 webrtc::VideoEncoderConfig 1862 webrtc::VideoEncoderConfig
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 } 1969 }
1944 1970
1945 void WebRtcVideoChannel2::WebRtcVideoSendStream::Stop() { 1971 void WebRtcVideoChannel2::WebRtcVideoSendStream::Stop() {
1946 rtc::CritScope cs(&lock_); 1972 rtc::CritScope cs(&lock_);
1947 if (stream_ != NULL) { 1973 if (stream_ != NULL) {
1948 stream_->Stop(); 1974 stream_->Stop();
1949 } 1975 }
1950 sending_ = false; 1976 sending_ = false;
1951 } 1977 }
1952 1978
1979 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) {
1980 RTC_DCHECK(thread_checker_.CalledOnValidThread());
1981 LOG(LS_INFO) << "OnLoadUpdate " << load;
1982 rtc::CritScope cs(&lock_);
1983 if (!capturer_) {
1984 return;
1985 }
1986
1987 if (load == kOveruse) {
1988 rtc::Optional<int> max_pixel_count(
1989 (last_dimensions_.height * last_dimensions_.width) / 2);
1990 if (!sink_wants_.max_pixel_count ||
1991 *sink_wants_.max_pixel_count != *max_pixel_count) {
1992 ++number_of_cpu_adapt_changes_;
1993 cpu_adapted_ = true;
1994 }
1995 sink_wants_.max_pixel_count = rtc::Optional<int>(
1996 last_dimensions_.height * last_dimensions_.width / 2);
pthatcher1 2016/02/25 07:40:30 Why can't use you just do: sink_wants_.max_pixel_
pthatcher1 2016/02/25 07:40:30 Shouldn't we clear the sink_wants_.max_pixel_count
perkj_webrtc 2016/02/25 13:57:07 Done.
1997 } else {
1998 RTC_DCHECK(load == kUnderuse);
1999 cpu_adapted_ = false;
pthatcher1 2016/02/25 07:40:30 It's still cpu_adapted sometimes, right? Just sli
perkj_webrtc 2016/02/25 13:57:07 Yes. This is just used for the info.adapt_reason s
pthatcher1 2016/02/25 20:20:05 It seems tricky. Only the Source really knows if
perkj_webrtc 2016/02/26 14:08:25 Can't the source just ignore max_pixel_value_count
2000 rtc::Optional<int> pixel_count_next_step_larger_than(
2001 last_dimensions_.height * last_dimensions_.width);
pthatcher1 2016/02/25 07:40:30 Why not just call this max_pixel_count_step_up?
perkj_webrtc 2016/02/25 13:57:07 Done.
2002 if (sink_wants_.max_pixel_count ||
2003 (sink_wants_.max_pixel_count_step_up &&
2004 *sink_wants_.max_pixel_count_step_up !=
2005 *pixel_count_next_step_larger_than)) {
2006 ++number_of_cpu_adapt_changes_;
2007 }
2008
2009 sink_wants_.max_pixel_count_step_up =
2010 pixel_count_next_step_larger_than;
2011 sink_wants_.max_pixel_count = rtc::Optional<int>();
2012 }
2013 capturer_->AddOrUpdateSink(this, sink_wants_);
2014 }
2015
1953 VideoSenderInfo 2016 VideoSenderInfo
1954 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { 2017 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() {
1955 VideoSenderInfo info; 2018 VideoSenderInfo info;
1956 webrtc::VideoSendStream::Stats stats; 2019 webrtc::VideoSendStream::Stats stats;
1957 { 2020 {
1958 rtc::CritScope cs(&lock_); 2021 rtc::CritScope cs(&lock_);
1959 for (uint32_t ssrc : parameters_.config.rtp.ssrcs) 2022 for (uint32_t ssrc : parameters_.config.rtp.ssrcs)
1960 info.add_ssrc(ssrc); 2023 info.add_ssrc(ssrc);
1961 2024
1962 if (parameters_.codec_settings) 2025 if (parameters_.codec_settings)
1963 info.codec_name = parameters_.codec_settings->codec.name; 2026 info.codec_name = parameters_.codec_settings->codec.name;
1964 for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) { 2027 for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) {
1965 if (i == parameters_.encoder_config.streams.size() - 1) { 2028 if (i == parameters_.encoder_config.streams.size() - 1) {
1966 info.preferred_bitrate += 2029 info.preferred_bitrate +=
1967 parameters_.encoder_config.streams[i].max_bitrate_bps; 2030 parameters_.encoder_config.streams[i].max_bitrate_bps;
1968 } else { 2031 } else {
1969 info.preferred_bitrate += 2032 info.preferred_bitrate +=
1970 parameters_.encoder_config.streams[i].target_bitrate_bps; 2033 parameters_.encoder_config.streams[i].target_bitrate_bps;
1971 } 2034 }
1972 } 2035 }
1973 2036
1974 if (stream_ == NULL) 2037 if (stream_ == NULL)
1975 return info; 2038 return info;
1976 2039
1977 stats = stream_->GetStats(); 2040 stats = stream_->GetStats();
1978 2041 info.adapt_changes = number_of_cpu_adapt_changes_;
1979 info.adapt_changes = old_adapt_changes_; 2042 info.adapt_reason = cpu_adapted_
1980 info.adapt_reason = CoordinatedVideoAdapter::ADAPTREASON_NONE; 2043 ? CoordinatedVideoAdapter::ADAPTREASON_CPU
2044 : CoordinatedVideoAdapter::ADAPTREASON_NONE;
1981 2045
1982 if (capturer_ != NULL) { 2046 if (capturer_ != NULL) {
1983 if (!capturer_->IsMuted()) { 2047 if (!capturer_->IsMuted()) {
1984 VideoFormat last_captured_frame_format; 2048 VideoFormat last_captured_frame_format;
1985 capturer_->GetStats(&info.adapt_frame_drops, &info.effects_frame_drops, 2049 capturer_->GetStats(&info.adapt_frame_drops, &info.effects_frame_drops,
1986 &info.capturer_frame_time, 2050 &info.capturer_frame_time,
1987 &last_captured_frame_format); 2051 &last_captured_frame_format);
1988 info.input_frame_width = last_captured_frame_format.width; 2052 info.input_frame_width = last_captured_frame_format.width;
1989 info.input_frame_height = last_captured_frame_format.height; 2053 info.input_frame_height = last_captured_frame_format.height;
1990 } 2054 }
1991 if (capturer_->video_adapter() != nullptr) {
1992 info.adapt_changes += capturer_->video_adapter()->adaptation_changes();
1993 info.adapt_reason = capturer_->video_adapter()->adapt_reason();
1994 }
1995 } 2055 }
1996 } 2056 }
1997 2057
1998 // Get bandwidth limitation info from stream_->GetStats(). 2058 // Get bandwidth limitation info from stream_->GetStats().
1999 // Input resolution (output from video_adapter) can be further scaled down or 2059 // Input resolution (output from video_adapter) can be further scaled down or
2000 // higher video layer(s) can be dropped due to bitrate constraints. 2060 // higher video layer(s) can be dropped due to bitrate constraints.
2001 // Note, adapt_changes only include changes from the video_adapter. 2061 // Note, adapt_changes only include changes from the video_adapter.
2002 if (stats.bw_limited_resolution) 2062 if (stats.bw_limited_resolution)
2003 info.adapt_reason |= CoordinatedVideoAdapter::ADAPTREASON_BANDWIDTH; 2063 info.adapt_reason |= CoordinatedVideoAdapter::ADAPTREASON_BANDWIDTH;
2004 2064
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 rtx_mapping[video_codecs[i].codec.id] != 2564 rtx_mapping[video_codecs[i].codec.id] !=
2505 fec_settings.red_payload_type) { 2565 fec_settings.red_payload_type) {
2506 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2566 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2507 } 2567 }
2508 } 2568 }
2509 2569
2510 return video_codecs; 2570 return video_codecs;
2511 } 2571 }
2512 2572
2513 } // namespace cricket 2573 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698