| 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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 rtc::CritScope stream_lock(&stream_crit_); | 1041 rtc::CritScope stream_lock(&stream_crit_); |
| 1042 for (const auto& kv : send_streams_) { | 1042 for (const auto& kv : send_streams_) { |
| 1043 kv.second->SetSend(send); | 1043 kv.second->SetSend(send); |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 sending_ = send; | 1046 sending_ = send; |
| 1047 return true; | 1047 return true; |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 // TODO(nisse): The enable argument was used for mute logic which has | 1050 // TODO(nisse): The enable argument was used for mute logic which has |
| 1051 // been moved to VideoBroadcaster. So delete this method, and use | 1051 // been moved to VideoBroadcaster. So remove the argument from this |
| 1052 // SetOptions instead. | 1052 // method. |
| 1053 bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable, | 1053 bool WebRtcVideoChannel2::SetVideoSend( |
| 1054 const VideoOptions* options) { | 1054 uint32_t ssrc, |
| 1055 bool enable, |
| 1056 const VideoOptions* options, |
| 1057 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
| 1055 TRACE_EVENT0("webrtc", "SetVideoSend"); | 1058 TRACE_EVENT0("webrtc", "SetVideoSend"); |
| 1059 RTC_DCHECK(ssrc != 0); |
| 1056 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable | 1060 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable |
| 1057 << "options: " << (options ? options->ToString() : "nullptr") | 1061 << ", options: " << (options ? options->ToString() : "nullptr") |
| 1058 << ")."; | 1062 << ", source = " << (source ? "(source)" : "nullptr") << ")"; |
| 1059 | 1063 |
| 1060 if (enable && options) { | 1064 rtc::CritScope stream_lock(&stream_crit_); |
| 1061 SetOptions(ssrc, *options); | 1065 const auto& kv = send_streams_.find(ssrc); |
| 1066 if (kv == send_streams_.end()) { |
| 1067 // Allow unknown ssrc only if source is null. |
| 1068 RTC_CHECK(source == nullptr); |
| 1069 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
| 1070 return false; |
| 1062 } | 1071 } |
| 1063 return true; | 1072 |
| 1073 return kv->second->SetVideoSend(enable, options, source); |
| 1064 } | 1074 } |
| 1065 | 1075 |
| 1066 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( | 1076 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( |
| 1067 const StreamParams& sp) const { | 1077 const StreamParams& sp) const { |
| 1068 for (uint32_t ssrc : sp.ssrcs) { | 1078 for (uint32_t ssrc : sp.ssrcs) { |
| 1069 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { | 1079 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { |
| 1070 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; | 1080 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; |
| 1071 return false; | 1081 return false; |
| 1072 } | 1082 } |
| 1073 } | 1083 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 return false; | 1290 return false; |
| 1281 } | 1291 } |
| 1282 DeleteReceiveStream(stream->second); | 1292 DeleteReceiveStream(stream->second); |
| 1283 receive_streams_.erase(stream); | 1293 receive_streams_.erase(stream); |
| 1284 | 1294 |
| 1285 return true; | 1295 return true; |
| 1286 } | 1296 } |
| 1287 | 1297 |
| 1288 bool WebRtcVideoChannel2::SetSink(uint32_t ssrc, | 1298 bool WebRtcVideoChannel2::SetSink(uint32_t ssrc, |
| 1289 rtc::VideoSinkInterface<VideoFrame>* sink) { | 1299 rtc::VideoSinkInterface<VideoFrame>* sink) { |
| 1290 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " << (sink ? "(ptr)" : "NULL"); | 1300 LOG(LS_INFO) << "SetSink: ssrc:" << ssrc << " " |
| 1301 << (sink ? "(ptr)" : "nullptr"); |
| 1291 if (ssrc == 0) { | 1302 if (ssrc == 0) { |
| 1292 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); | 1303 default_unsignalled_ssrc_handler_.SetDefaultSink(this, sink); |
| 1293 return true; | 1304 return true; |
| 1294 } | 1305 } |
| 1295 | 1306 |
| 1296 rtc::CritScope stream_lock(&stream_crit_); | 1307 rtc::CritScope stream_lock(&stream_crit_); |
| 1297 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = | 1308 std::map<uint32_t, WebRtcVideoReceiveStream*>::iterator it = |
| 1298 receive_streams_.find(ssrc); | 1309 receive_streams_.find(ssrc); |
| 1299 if (it == receive_streams_.end()) { | 1310 if (it == receive_streams_.end()) { |
| 1300 return false; | 1311 return false; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 // Get send stream bitrate stats. | 1359 // Get send stream bitrate stats. |
| 1349 rtc::CritScope stream_lock(&stream_crit_); | 1360 rtc::CritScope stream_lock(&stream_crit_); |
| 1350 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator stream = | 1361 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator stream = |
| 1351 send_streams_.begin(); | 1362 send_streams_.begin(); |
| 1352 stream != send_streams_.end(); ++stream) { | 1363 stream != send_streams_.end(); ++stream) { |
| 1353 stream->second->FillBandwidthEstimationInfo(&bwe_info); | 1364 stream->second->FillBandwidthEstimationInfo(&bwe_info); |
| 1354 } | 1365 } |
| 1355 video_media_info->bw_estimations.push_back(bwe_info); | 1366 video_media_info->bw_estimations.push_back(bwe_info); |
| 1356 } | 1367 } |
| 1357 | 1368 |
| 1358 void WebRtcVideoChannel2::SetSource( | |
| 1359 uint32_t ssrc, | |
| 1360 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { | |
| 1361 LOG(LS_INFO) << "SetSource: " << ssrc << " -> " | |
| 1362 << (source ? "(source)" : "NULL"); | |
| 1363 RTC_DCHECK(ssrc != 0); | |
| 1364 | |
| 1365 rtc::CritScope stream_lock(&stream_crit_); | |
| 1366 const auto& kv = send_streams_.find(ssrc); | |
| 1367 if (kv == send_streams_.end()) { | |
| 1368 // Allow unknown ssrc only if source is null. | |
| 1369 RTC_CHECK(source == nullptr); | |
| 1370 } else { | |
| 1371 kv->second->SetSource(source); | |
| 1372 } | |
| 1373 } | |
| 1374 | |
| 1375 void WebRtcVideoChannel2::OnPacketReceived( | 1369 void WebRtcVideoChannel2::OnPacketReceived( |
| 1376 rtc::CopyOnWriteBuffer* packet, | 1370 rtc::CopyOnWriteBuffer* packet, |
| 1377 const rtc::PacketTime& packet_time) { | 1371 const rtc::PacketTime& packet_time) { |
| 1378 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 1372 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
| 1379 packet_time.not_before); | 1373 packet_time.not_before); |
| 1380 const webrtc::PacketReceiver::DeliveryStatus delivery_result = | 1374 const webrtc::PacketReceiver::DeliveryStatus delivery_result = |
| 1381 call_->Receiver()->DeliverPacket( | 1375 call_->Receiver()->DeliverPacket( |
| 1382 webrtc::MediaType::VIDEO, | 1376 webrtc::MediaType::VIDEO, |
| 1383 packet->cdata(), packet->size(), | 1377 packet->cdata(), packet->size(), |
| 1384 webrtc_packet_time); | 1378 webrtc_packet_time); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 webrtc::MediaType::VIDEO, | 1445 webrtc::MediaType::VIDEO, |
| 1452 ready ? webrtc::kNetworkUp : webrtc::kNetworkDown); | 1446 ready ? webrtc::kNetworkUp : webrtc::kNetworkDown); |
| 1453 } | 1447 } |
| 1454 | 1448 |
| 1455 void WebRtcVideoChannel2::OnNetworkRouteChanged( | 1449 void WebRtcVideoChannel2::OnNetworkRouteChanged( |
| 1456 const std::string& transport_name, | 1450 const std::string& transport_name, |
| 1457 const rtc::NetworkRoute& network_route) { | 1451 const rtc::NetworkRoute& network_route) { |
| 1458 call_->OnNetworkRouteChanged(transport_name, network_route); | 1452 call_->OnNetworkRouteChanged(transport_name, network_route); |
| 1459 } | 1453 } |
| 1460 | 1454 |
| 1461 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. | |
| 1462 void WebRtcVideoChannel2::SetOptions(uint32_t ssrc, | |
| 1463 const VideoOptions& options) { | |
| 1464 LOG(LS_INFO) << "SetOptions: ssrc " << ssrc << ": " << options.ToString(); | |
| 1465 | |
| 1466 rtc::CritScope stream_lock(&stream_crit_); | |
| 1467 const auto& kv = send_streams_.find(ssrc); | |
| 1468 if (kv == send_streams_.end()) { | |
| 1469 return; | |
| 1470 } | |
| 1471 kv->second->SetOptions(options); | |
| 1472 } | |
| 1473 | |
| 1474 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { | 1455 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
| 1475 MediaChannel::SetInterface(iface); | 1456 MediaChannel::SetInterface(iface); |
| 1476 // Set the RTP recv/send buffer to a bigger size | 1457 // Set the RTP recv/send buffer to a bigger size |
| 1477 MediaChannel::SetOption(NetworkInterface::ST_RTP, | 1458 MediaChannel::SetOption(NetworkInterface::ST_RTP, |
| 1478 rtc::Socket::OPT_RCVBUF, | 1459 rtc::Socket::OPT_RCVBUF, |
| 1479 kVideoRtpBufferSize); | 1460 kVideoRtpBufferSize); |
| 1480 | 1461 |
| 1481 // Speculative change to increase the outbound socket buffer size. | 1462 // Speculative change to increase the outbound socket buffer size. |
| 1482 // In b/15152257, we are seeing a significant number of packets discarded | 1463 // In b/15152257, we are seeing a significant number of packets discarded |
| 1483 // due to lack of socket buffer space, although it's not yet clear what the | 1464 // due to lack of socket buffer space, although it's not yet clear what the |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 // Not sending, abort after reconfiguration. Reconfiguration should still | 1613 // Not sending, abort after reconfiguration. Reconfiguration should still |
| 1633 // occur to permit sending this input as quickly as possible once we start | 1614 // occur to permit sending this input as quickly as possible once we start |
| 1634 // sending (without having to reconfigure then). | 1615 // sending (without having to reconfigure then). |
| 1635 if (!sending_) { | 1616 if (!sending_) { |
| 1636 return; | 1617 return; |
| 1637 } | 1618 } |
| 1638 | 1619 |
| 1639 stream_->Input()->IncomingCapturedFrame(video_frame); | 1620 stream_->Input()->IncomingCapturedFrame(video_frame); |
| 1640 } | 1621 } |
| 1641 | 1622 |
| 1642 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( | 1623 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( |
| 1624 bool enable, |
| 1625 const VideoOptions* options, |
| 1643 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { | 1626 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
| 1644 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); | 1627 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); |
| 1645 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1628 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1646 | 1629 |
| 1647 if (!source && !source_) | 1630 // Ignore |options| pointer if |enable| is false. |
| 1648 return; | 1631 bool options_present = enable && options; |
| 1649 DisconnectSource(); | 1632 bool source_changing = source_ != source; |
| 1633 if (source_changing) { |
| 1634 DisconnectSource(); |
| 1635 } |
| 1650 | 1636 |
| 1651 { | 1637 if (options_present || source_changing) { |
| 1652 rtc::CritScope cs(&lock_); | 1638 rtc::CritScope cs(&lock_); |
| 1653 | 1639 |
| 1654 // Reset timestamps to realign new incoming frames to a webrtc timestamp. A | 1640 if (options_present) { |
| 1655 // new capturer may have a different timestamp delta than the previous one. | 1641 VideoOptions old_options = parameters_.options; |
| 1656 first_frame_timestamp_ms_ = rtc::Optional<int64_t>(); | 1642 parameters_.options.SetAll(*options); |
| 1643 // Reconfigure encoder settings on the naext frame or stream |
| 1644 // recreation if the options changed. |
| 1645 if (parameters_.options != old_options) { |
| 1646 pending_encoder_reconfiguration_ = true; |
| 1647 } |
| 1648 } |
| 1657 | 1649 |
| 1658 if (source == NULL) { | 1650 if (source_changing) { |
| 1659 if (stream_ != NULL) { | 1651 // Reset timestamps to realign new incoming frames to a webrtc timestamp. |
| 1652 // A new source may have a different timestamp delta than the previous |
| 1653 // one. |
| 1654 first_frame_timestamp_ms_ = rtc::Optional<int64_t>(); |
| 1655 |
| 1656 if (source == nullptr && stream_ != nullptr) { |
| 1660 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; | 1657 LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; |
| 1661 // Force this black frame not to be dropped due to timestamp order | 1658 // Force this black frame not to be dropped due to timestamp order |
| 1662 // check. As IncomingCapturedFrame will drop the frame if this frame's | 1659 // check. As IncomingCapturedFrame will drop the frame if this frame's |
| 1663 // timestamp is less than or equal to last frame's timestamp, it is | 1660 // timestamp is less than or equal to last frame's timestamp, it is |
| 1664 // necessary to give this black frame a larger timestamp than the | 1661 // necessary to give this black frame a larger timestamp than the |
| 1665 // previous one. | 1662 // previous one. |
| 1666 last_frame_timestamp_ms_ += 1; | 1663 last_frame_timestamp_ms_ += 1; |
| 1667 stream_->Input()->IncomingCapturedFrame( | 1664 stream_->Input()->IncomingCapturedFrame( |
| 1668 CreateBlackFrame(last_dimensions_.width, last_dimensions_.height, | 1665 CreateBlackFrame(last_dimensions_.width, last_dimensions_.height, |
| 1669 last_frame_timestamp_ms_, last_rotation_)); | 1666 last_frame_timestamp_ms_, last_rotation_)); |
| 1670 } | 1667 } |
| 1668 source_ = source; |
| 1671 } | 1669 } |
| 1672 } | 1670 } |
| 1673 source_ = source; | 1671 |
| 1674 // |source_->AddOrUpdateSink| may not be called while holding |lock_| since | 1672 // |source_->AddOrUpdateSink| may not be called while holding |lock_| since |
| 1675 // that might cause a lock order inversion. | 1673 // that might cause a lock order inversion. |
| 1676 if (source_) { | 1674 if (source_changing && source_) { |
| 1677 source_->AddOrUpdateSink(this, sink_wants_); | 1675 source_->AddOrUpdateSink(this, sink_wants_); |
| 1678 } | 1676 } |
| 1677 return true; |
| 1679 } | 1678 } |
| 1680 | 1679 |
| 1681 void WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectSource() { | 1680 void WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectSource() { |
| 1682 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1681 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1683 if (source_ == NULL) { | 1682 if (source_ == NULL) { |
| 1684 return; | 1683 return; |
| 1685 } | 1684 } |
| 1686 | 1685 |
| 1687 // |source_->RemoveSink| may not be called while holding |lock_| since | 1686 // |source_->RemoveSink| may not be called while holding |lock_| since |
| 1688 // that might cause a lock order inversion. | 1687 // that might cause a lock order inversion. |
| 1689 source_->RemoveSink(this); | 1688 source_->RemoveSink(this); |
| 1690 source_ = nullptr; | 1689 source_ = nullptr; |
| 1691 // Reset |cpu_restricted_counter_| if the capturer is changed. It is not | 1690 // Reset |cpu_restricted_counter_| if the source is changed. It is not |
| 1692 // possible to know if the video resolution is restricted by CPU usage after | 1691 // possible to know if the video resolution is restricted by CPU usage after |
| 1693 // the capturer is changed since the next capturer might be screen capture | 1692 // the source is changed since the next source might be screen capture |
| 1694 // with another resolution and frame rate. | 1693 // with another resolution and frame rate. |
| 1695 cpu_restricted_counter_ = 0; | 1694 cpu_restricted_counter_ = 0; |
| 1696 } | 1695 } |
| 1697 | 1696 |
| 1698 const std::vector<uint32_t>& | 1697 const std::vector<uint32_t>& |
| 1699 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { | 1698 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { |
| 1700 return ssrcs_; | 1699 return ssrcs_; |
| 1701 } | 1700 } |
| 1702 | 1701 |
| 1703 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( | |
| 1704 const VideoOptions& options) { | |
| 1705 rtc::CritScope cs(&lock_); | |
| 1706 | |
| 1707 VideoOptions old_options = parameters_.options; | |
| 1708 parameters_.options.SetAll(options); | |
| 1709 // Reconfigure encoder settings on the next frame or stream | |
| 1710 // recreation if the options changed. | |
| 1711 if (parameters_.options != old_options) { | |
| 1712 pending_encoder_reconfiguration_ = true; | |
| 1713 } | |
| 1714 } | |
| 1715 | |
| 1716 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { | 1702 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { |
| 1717 if (CodecNamesEq(name, kVp8CodecName)) { | 1703 if (CodecNamesEq(name, kVp8CodecName)) { |
| 1718 return webrtc::kVideoCodecVP8; | 1704 return webrtc::kVideoCodecVP8; |
| 1719 } else if (CodecNamesEq(name, kVp9CodecName)) { | 1705 } else if (CodecNamesEq(name, kVp9CodecName)) { |
| 1720 return webrtc::kVideoCodecVP9; | 1706 return webrtc::kVideoCodecVP9; |
| 1721 } else if (CodecNamesEq(name, kH264CodecName)) { | 1707 } else if (CodecNamesEq(name, kH264CodecName)) { |
| 1722 return webrtc::kVideoCodecH264; | 1708 return webrtc::kVideoCodecH264; |
| 1723 } | 1709 } |
| 1724 return webrtc::kVideoCodecUnknown; | 1710 return webrtc::kVideoCodecUnknown; |
| 1725 } | 1711 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 SetCodec(*parameters_.codec_settings); | 1827 SetCodec(*parameters_.codec_settings); |
| 1842 recreate_stream = false; // SetCodec has already recreated the stream. | 1828 recreate_stream = false; // SetCodec has already recreated the stream. |
| 1843 } | 1829 } |
| 1844 if (recreate_stream) { | 1830 if (recreate_stream) { |
| 1845 LOG(LS_INFO) | 1831 LOG(LS_INFO) |
| 1846 << "RecreateWebRtcStream (send) because of SetSendParameters"; | 1832 << "RecreateWebRtcStream (send) because of SetSendParameters"; |
| 1847 RecreateWebRtcStream(); | 1833 RecreateWebRtcStream(); |
| 1848 } | 1834 } |
| 1849 } // release |lock_| | 1835 } // release |lock_| |
| 1850 | 1836 |
| 1851 // |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since | 1837 // |source_->AddOrUpdateSink| may not be called while holding |lock_| since |
| 1852 // that might cause a lock order inversion. | 1838 // that might cause a lock order inversion. |
| 1853 if (params.rtp_header_extensions) { | 1839 if (params.rtp_header_extensions) { |
| 1854 sink_wants_.rotation_applied = !ContainsHeaderExtension( | 1840 sink_wants_.rotation_applied = !ContainsHeaderExtension( |
| 1855 *params.rtp_header_extensions, webrtc::RtpExtension::kVideoRotationUri); | 1841 *params.rtp_header_extensions, webrtc::RtpExtension::kVideoRotationUri); |
| 1856 if (source_) { | 1842 if (source_) { |
| 1857 source_->AddOrUpdateSink(this, sink_wants_); | 1843 source_->AddOrUpdateSink(this, sink_wants_); |
| 1858 } | 1844 } |
| 1859 } | 1845 } |
| 1860 } | 1846 } |
| 1861 | 1847 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 if (parameters_.options.is_screencast.value_or(false)) | 2022 if (parameters_.options.is_screencast.value_or(false)) |
| 2037 return; | 2023 return; |
| 2038 | 2024 |
| 2039 rtc::Optional<int> max_pixel_count; | 2025 rtc::Optional<int> max_pixel_count; |
| 2040 rtc::Optional<int> max_pixel_count_step_up; | 2026 rtc::Optional<int> max_pixel_count_step_up; |
| 2041 if (load == kOveruse) { | 2027 if (load == kOveruse) { |
| 2042 if (cpu_restricted_counter_ >= kMaxCpuDowngrades) { | 2028 if (cpu_restricted_counter_ >= kMaxCpuDowngrades) { |
| 2043 return; | 2029 return; |
| 2044 } | 2030 } |
| 2045 // The input video frame size will have a resolution with less than or | 2031 // The input video frame size will have a resolution with less than or |
| 2046 // equal to |max_pixel_count| depending on how the capturer can scale the | 2032 // equal to |max_pixel_count| depending on how the source can scale the |
| 2047 // input frame size. | 2033 // input frame size. |
| 2048 max_pixel_count = rtc::Optional<int>( | 2034 max_pixel_count = rtc::Optional<int>( |
| 2049 (last_dimensions_.height * last_dimensions_.width * 3) / 5); | 2035 (last_dimensions_.height * last_dimensions_.width * 3) / 5); |
| 2050 // Increase |number_of_cpu_adapt_changes_| if | 2036 // Increase |number_of_cpu_adapt_changes_| if |
| 2051 // sink_wants_.max_pixel_count will be changed since | 2037 // sink_wants_.max_pixel_count will be changed since |
| 2052 // last time |capturer_->AddOrUpdateSink| was called. That is, this will | 2038 // last time |source_->AddOrUpdateSink| was called. That is, this will |
| 2053 // result in a new request for the capturer to change resolution. | 2039 // result in a new request for the source to change resolution. |
| 2054 if (!sink_wants_.max_pixel_count || | 2040 if (!sink_wants_.max_pixel_count || |
| 2055 *sink_wants_.max_pixel_count > *max_pixel_count) { | 2041 *sink_wants_.max_pixel_count > *max_pixel_count) { |
| 2056 ++number_of_cpu_adapt_changes_; | 2042 ++number_of_cpu_adapt_changes_; |
| 2057 ++cpu_restricted_counter_; | 2043 ++cpu_restricted_counter_; |
| 2058 } | 2044 } |
| 2059 } else { | 2045 } else { |
| 2060 RTC_DCHECK(load == kUnderuse); | 2046 RTC_DCHECK(load == kUnderuse); |
| 2061 // The input video frame size will have a resolution with "one step up" | 2047 // The input video frame size will have a resolution with "one step up" |
| 2062 // pixels than |max_pixel_count_step_up| where "one step up" depends on | 2048 // pixels than |max_pixel_count_step_up| where "one step up" depends on |
| 2063 // how the capturer can scale the input frame size. | 2049 // how the source can scale the input frame size. |
| 2064 max_pixel_count_step_up = rtc::Optional<int>(last_dimensions_.height * | 2050 max_pixel_count_step_up = rtc::Optional<int>(last_dimensions_.height * |
| 2065 last_dimensions_.width); | 2051 last_dimensions_.width); |
| 2066 // Increase |number_of_cpu_adapt_changes_| if | 2052 // Increase |number_of_cpu_adapt_changes_| if |
| 2067 // sink_wants_.max_pixel_count_step_up will be changed since | 2053 // sink_wants_.max_pixel_count_step_up will be changed since |
| 2068 // last time |capturer_->AddOrUpdateSink| was called. That is, this will | 2054 // last time |source_->AddOrUpdateSink| was called. That is, this will |
| 2069 // result in a new request for the capturer to change resolution. | 2055 // result in a new request for the source to change resolution. |
| 2070 if (sink_wants_.max_pixel_count || | 2056 if (sink_wants_.max_pixel_count || |
| 2071 (sink_wants_.max_pixel_count_step_up && | 2057 (sink_wants_.max_pixel_count_step_up && |
| 2072 *sink_wants_.max_pixel_count_step_up < *max_pixel_count_step_up)) { | 2058 *sink_wants_.max_pixel_count_step_up < *max_pixel_count_step_up)) { |
| 2073 ++number_of_cpu_adapt_changes_; | 2059 ++number_of_cpu_adapt_changes_; |
| 2074 --cpu_restricted_counter_; | 2060 --cpu_restricted_counter_; |
| 2075 } | 2061 } |
| 2076 } | 2062 } |
| 2077 sink_wants_.max_pixel_count = max_pixel_count; | 2063 sink_wants_.max_pixel_count = max_pixel_count; |
| 2078 sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up; | 2064 sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up; |
| 2079 } | 2065 } |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2624 rtx_mapping[video_codecs[i].codec.id] != | 2610 rtx_mapping[video_codecs[i].codec.id] != |
| 2625 fec_settings.red_payload_type) { | 2611 fec_settings.red_payload_type) { |
| 2626 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2612 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2627 } | 2613 } |
| 2628 } | 2614 } |
| 2629 | 2615 |
| 2630 return video_codecs; | 2616 return video_codecs; |
| 2631 } | 2617 } |
| 2632 | 2618 |
| 2633 } // namespace cricket | 2619 } // namespace cricket |
| OLD | NEW |