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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 404 |
405 int max_qp = kDefaultQpMax; | 405 int max_qp = kDefaultQpMax; |
406 codec.GetParam(kCodecParamMaxQuantization, &max_qp); | 406 codec.GetParam(kCodecParamMaxQuantization, &max_qp); |
407 stream.max_qp = max_qp; | 407 stream.max_qp = max_qp; |
408 std::vector<webrtc::VideoStream> streams; | 408 std::vector<webrtc::VideoStream> streams; |
409 streams.push_back(stream); | 409 streams.push_back(stream); |
410 return streams; | 410 return streams; |
411 } | 411 } |
412 | 412 |
413 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( | 413 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( |
414 const VideoCodec& codec, | 414 const VideoCodec& codec) { |
415 const VideoOptions& options, | 415 bool is_screencast = parameters_.options.is_screencast.value_or(false); |
416 bool is_screencast) { | |
417 // No automatic resizing when using simulcast or screencast. | 416 // No automatic resizing when using simulcast or screencast. |
418 bool automatic_resize = | 417 bool automatic_resize = |
419 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; | 418 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; |
420 bool frame_dropping = !is_screencast; | 419 bool frame_dropping = !is_screencast; |
421 bool denoising; | 420 bool denoising; |
422 bool codec_default_denoising = false; | 421 bool codec_default_denoising = false; |
423 if (is_screencast) { | 422 if (is_screencast) { |
424 denoising = false; | 423 denoising = false; |
425 } else { | 424 } else { |
426 // Use codec default if video_noise_reduction is unset. | 425 // Use codec default if video_noise_reduction is unset. |
427 codec_default_denoising = !options.video_noise_reduction; | 426 codec_default_denoising = !parameters_.options.video_noise_reduction; |
428 denoising = options.video_noise_reduction.value_or(false); | 427 denoising = parameters_.options.video_noise_reduction.value_or(false); |
429 } | 428 } |
430 | 429 |
431 if (CodecNamesEq(codec.name, kH264CodecName)) { | 430 if (CodecNamesEq(codec.name, kH264CodecName)) { |
432 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); | 431 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); |
433 encoder_settings_.h264.frameDroppingOn = frame_dropping; | 432 encoder_settings_.h264.frameDroppingOn = frame_dropping; |
434 return &encoder_settings_.h264; | 433 return &encoder_settings_.h264; |
435 } | 434 } |
436 if (CodecNamesEq(codec.name, kVp8CodecName)) { | 435 if (CodecNamesEq(codec.name, kVp8CodecName)) { |
437 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); | 436 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); |
438 encoder_settings_.vp8.automaticResizeOn = automatic_resize; | 437 encoder_settings_.vp8.automaticResizeOn = automatic_resize; |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 ssrc_groups_(sp.ssrc_groups), | 1482 ssrc_groups_(sp.ssrc_groups), |
1484 call_(call), | 1483 call_(call), |
1485 cpu_restricted_counter_(0), | 1484 cpu_restricted_counter_(0), |
1486 number_of_cpu_adapt_changes_(0), | 1485 number_of_cpu_adapt_changes_(0), |
1487 capturer_(nullptr), | 1486 capturer_(nullptr), |
1488 external_encoder_factory_(external_encoder_factory), | 1487 external_encoder_factory_(external_encoder_factory), |
1489 stream_(nullptr), | 1488 stream_(nullptr), |
1490 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), | 1489 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), |
1491 pending_encoder_reconfiguration_(false), | 1490 pending_encoder_reconfiguration_(false), |
1492 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), | 1491 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
1493 capturer_is_screencast_(false), | |
1494 sending_(false), | 1492 sending_(false), |
1495 muted_(false), | 1493 muted_(false), |
1496 first_frame_timestamp_ms_(0), | 1494 first_frame_timestamp_ms_(0), |
1497 last_frame_timestamp_ms_(0) { | 1495 last_frame_timestamp_ms_(0) { |
1498 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1496 parameters_.config.rtp.max_packet_size = kVideoMtu; |
1499 parameters_.conference_mode = send_params.conference_mode; | 1497 parameters_.conference_mode = send_params.conference_mode; |
1500 | 1498 |
1501 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); | 1499 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
1502 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1500 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1503 ¶meters_.config.rtp.rtx.ssrcs); | 1501 ¶meters_.config.rtp.rtx.ssrcs); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 | 1561 |
1564 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; | 1562 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
1565 // frame->GetTimeStamp() is essentially a delta, align to webrtc time | 1563 // frame->GetTimeStamp() is essentially a delta, align to webrtc time |
1566 if (first_frame_timestamp_ms_ == 0) { | 1564 if (first_frame_timestamp_ms_ == 0) { |
1567 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; | 1565 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; |
1568 } | 1566 } |
1569 | 1567 |
1570 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; | 1568 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; |
1571 video_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1569 video_frame.set_render_time_ms(last_frame_timestamp_ms_); |
1572 // Reconfigure codec if necessary. | 1570 // Reconfigure codec if necessary. |
1573 SetDimensions(video_frame.width(), video_frame.height(), | 1571 SetDimensions(video_frame.width(), video_frame.height()); |
1574 capturer_is_screencast_); | |
1575 last_rotation_ = video_frame.rotation(); | 1572 last_rotation_ = video_frame.rotation(); |
1576 | 1573 |
1577 stream_->Input()->IncomingCapturedFrame(video_frame); | 1574 stream_->Input()->IncomingCapturedFrame(video_frame); |
1578 } | 1575 } |
1579 | 1576 |
1580 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( | 1577 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( |
1581 VideoCapturer* capturer) { | 1578 VideoCapturer* capturer) { |
1582 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer"); | 1579 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer"); |
1583 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1580 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1584 if (!DisconnectCapturer() && capturer == NULL) { | 1581 if (!DisconnectCapturer() && capturer == NULL) { |
(...skipping 21 matching lines...) Expand all Loading... |
1606 // necessary to give this black frame a larger timestamp than the | 1603 // necessary to give this black frame a larger timestamp than the |
1607 // previous one. | 1604 // previous one. |
1608 last_frame_timestamp_ms_ += 1; | 1605 last_frame_timestamp_ms_ += 1; |
1609 black_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1606 black_frame.set_render_time_ms(last_frame_timestamp_ms_); |
1610 stream_->Input()->IncomingCapturedFrame(black_frame); | 1607 stream_->Input()->IncomingCapturedFrame(black_frame); |
1611 } | 1608 } |
1612 | 1609 |
1613 capturer_ = NULL; | 1610 capturer_ = NULL; |
1614 return true; | 1611 return true; |
1615 } | 1612 } |
1616 capturer_is_screencast_ = capturer->IsScreencast(); | |
1617 } | 1613 } |
1618 capturer_ = capturer; | 1614 capturer_ = capturer; |
1619 capturer_->AddOrUpdateSink(this, sink_wants_); | 1615 capturer_->AddOrUpdateSink(this, sink_wants_); |
1620 return true; | 1616 return true; |
1621 } | 1617 } |
1622 | 1618 |
1623 void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { | 1619 void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { |
1624 rtc::CritScope cs(&lock_); | 1620 rtc::CritScope cs(&lock_); |
1625 muted_ = mute; | 1621 muted_ = mute; |
1626 } | 1622 } |
(...skipping 15 matching lines...) Expand all Loading... |
1642 } | 1638 } |
1643 | 1639 |
1644 const std::vector<uint32_t>& | 1640 const std::vector<uint32_t>& |
1645 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { | 1641 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { |
1646 return ssrcs_; | 1642 return ssrcs_; |
1647 } | 1643 } |
1648 | 1644 |
1649 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( | 1645 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( |
1650 const VideoOptions& options) { | 1646 const VideoOptions& options) { |
1651 rtc::CritScope cs(&lock_); | 1647 rtc::CritScope cs(&lock_); |
| 1648 |
1652 parameters_.options.SetAll(options); | 1649 parameters_.options.SetAll(options); |
1653 // Reconfigure encoder settings on the next frame or stream | 1650 // Reconfigure encoder settings on the next frame or stream |
1654 // recreation. | 1651 // recreation. |
1655 pending_encoder_reconfiguration_ = true; | 1652 pending_encoder_reconfiguration_ = true; |
1656 } | 1653 } |
1657 | 1654 |
1658 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { | 1655 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { |
1659 if (CodecNamesEq(name, kVp8CodecName)) { | 1656 if (CodecNamesEq(name, kVp8CodecName)) { |
1660 return webrtc::kVideoCodecVP8; | 1657 return webrtc::kVideoCodecVP8; |
1661 } else if (CodecNamesEq(name, kVp9CodecName)) { | 1658 } else if (CodecNamesEq(name, kVp9CodecName)) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 } else { | 1733 } else { |
1737 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1734 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
1738 } | 1735 } |
1739 } | 1736 } |
1740 | 1737 |
1741 parameters_.config.rtp.nack.rtp_history_ms = | 1738 parameters_.config.rtp.nack.rtp_history_ms = |
1742 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 1739 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; |
1743 | 1740 |
1744 parameters_.codec_settings = | 1741 parameters_.codec_settings = |
1745 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); | 1742 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); |
| 1743 |
| 1744 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetCodec."; |
1746 RecreateWebRtcStream(); | 1745 RecreateWebRtcStream(); |
1747 if (allocated_encoder_.encoder != new_encoder.encoder) { | 1746 if (allocated_encoder_.encoder != new_encoder.encoder) { |
1748 DestroyVideoEncoder(&allocated_encoder_); | 1747 DestroyVideoEncoder(&allocated_encoder_); |
1749 allocated_encoder_ = new_encoder; | 1748 allocated_encoder_ = new_encoder; |
1750 } | 1749 } |
1751 } | 1750 } |
1752 | 1751 |
1753 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( | 1752 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( |
1754 const ChangedSendParameters& params) { | 1753 const ChangedSendParameters& params) { |
1755 rtc::CritScope cs(&lock_); | 1754 rtc::CritScope cs(&lock_); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; | 1792 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; |
1794 RecreateWebRtcStream(); | 1793 RecreateWebRtcStream(); |
1795 } | 1794 } |
1796 } | 1795 } |
1797 | 1796 |
1798 webrtc::VideoEncoderConfig | 1797 webrtc::VideoEncoderConfig |
1799 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 1798 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
1800 const Dimensions& dimensions, | 1799 const Dimensions& dimensions, |
1801 const VideoCodec& codec) const { | 1800 const VideoCodec& codec) const { |
1802 webrtc::VideoEncoderConfig encoder_config; | 1801 webrtc::VideoEncoderConfig encoder_config; |
1803 if (dimensions.is_screencast) { | 1802 bool is_screencast = parameters_.options.is_screencast.value_or(false); |
| 1803 if (is_screencast) { |
1804 encoder_config.min_transmit_bitrate_bps = | 1804 encoder_config.min_transmit_bitrate_bps = |
1805 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); | 1805 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); |
1806 encoder_config.content_type = | 1806 encoder_config.content_type = |
1807 webrtc::VideoEncoderConfig::ContentType::kScreen; | 1807 webrtc::VideoEncoderConfig::ContentType::kScreen; |
1808 } else { | 1808 } else { |
1809 encoder_config.min_transmit_bitrate_bps = 0; | 1809 encoder_config.min_transmit_bitrate_bps = 0; |
1810 encoder_config.content_type = | 1810 encoder_config.content_type = |
1811 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; | 1811 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; |
1812 } | 1812 } |
1813 | 1813 |
1814 // Restrict dimensions according to codec max. | 1814 // Restrict dimensions according to codec max. |
1815 int width = dimensions.width; | 1815 int width = dimensions.width; |
1816 int height = dimensions.height; | 1816 int height = dimensions.height; |
1817 if (!dimensions.is_screencast) { | 1817 if (!is_screencast) { |
1818 if (codec.width < width) | 1818 if (codec.width < width) |
1819 width = codec.width; | 1819 width = codec.width; |
1820 if (codec.height < height) | 1820 if (codec.height < height) |
1821 height = codec.height; | 1821 height = codec.height; |
1822 } | 1822 } |
1823 | 1823 |
1824 VideoCodec clamped_codec = codec; | 1824 VideoCodec clamped_codec = codec; |
1825 clamped_codec.width = width; | 1825 clamped_codec.width = width; |
1826 clamped_codec.height = height; | 1826 clamped_codec.height = height; |
1827 | 1827 |
1828 // By default, the stream count for the codec configuration should match the | 1828 // By default, the stream count for the codec configuration should match the |
1829 // number of negotiated ssrcs. But if the codec is blacklisted for simulcast | 1829 // number of negotiated ssrcs. But if the codec is blacklisted for simulcast |
1830 // or a screencast, only configure a single stream. | 1830 // or a screencast, only configure a single stream. |
1831 size_t stream_count = parameters_.config.rtp.ssrcs.size(); | 1831 size_t stream_count = parameters_.config.rtp.ssrcs.size(); |
1832 if (IsCodecBlacklistedForSimulcast(codec.name) || dimensions.is_screencast) { | 1832 if (IsCodecBlacklistedForSimulcast(codec.name) || is_screencast) { |
1833 stream_count = 1; | 1833 stream_count = 1; |
1834 } | 1834 } |
1835 | 1835 |
1836 encoder_config.streams = | 1836 encoder_config.streams = |
1837 CreateVideoStreams(clamped_codec, parameters_.options, | 1837 CreateVideoStreams(clamped_codec, parameters_.options, |
1838 parameters_.max_bitrate_bps, stream_count); | 1838 parameters_.max_bitrate_bps, stream_count); |
1839 | 1839 |
1840 // Conference mode screencast uses 2 temporal layers split at 100kbit. | 1840 // Conference mode screencast uses 2 temporal layers split at 100kbit. |
1841 if (parameters_.conference_mode && dimensions.is_screencast && | 1841 if (parameters_.conference_mode && is_screencast && |
1842 encoder_config.streams.size() == 1) { | 1842 encoder_config.streams.size() == 1) { |
1843 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); | 1843 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); |
1844 | 1844 |
1845 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked | 1845 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked |
1846 // on the VideoCodec struct as target and max bitrates, respectively. | 1846 // on the VideoCodec struct as target and max bitrates, respectively. |
1847 // See eg. webrtc::VP8EncoderImpl::SetRates(). | 1847 // See eg. webrtc::VP8EncoderImpl::SetRates(). |
1848 encoder_config.streams[0].target_bitrate_bps = | 1848 encoder_config.streams[0].target_bitrate_bps = |
1849 config.tl0_bitrate_kbps * 1000; | 1849 config.tl0_bitrate_kbps * 1000; |
1850 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; | 1850 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; |
1851 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); | 1851 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); |
1852 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( | 1852 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( |
1853 config.tl0_bitrate_kbps * 1000); | 1853 config.tl0_bitrate_kbps * 1000); |
1854 } | 1854 } |
1855 return encoder_config; | 1855 return encoder_config; |
1856 } | 1856 } |
1857 | 1857 |
1858 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( | 1858 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( |
1859 int width, | 1859 int width, |
1860 int height, | 1860 int height) { |
1861 bool is_screencast) { | |
1862 if (last_dimensions_.width == width && last_dimensions_.height == height && | 1861 if (last_dimensions_.width == width && last_dimensions_.height == height && |
1863 last_dimensions_.is_screencast == is_screencast && | |
1864 !pending_encoder_reconfiguration_) { | 1862 !pending_encoder_reconfiguration_) { |
1865 // Configured using the same parameters, do not reconfigure. | 1863 // Configured using the same parameters, do not reconfigure. |
1866 return; | 1864 return; |
1867 } | 1865 } |
1868 LOG(LS_INFO) << "SetDimensions: " << width << "x" << height | |
1869 << (is_screencast ? " (screencast)" : " (not screencast)"); | |
1870 | 1866 |
1871 last_dimensions_.width = width; | 1867 last_dimensions_.width = width; |
1872 last_dimensions_.height = height; | 1868 last_dimensions_.height = height; |
1873 last_dimensions_.is_screencast = is_screencast; | |
1874 | 1869 |
1875 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 1870 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); |
1876 | 1871 |
1877 RTC_CHECK(parameters_.codec_settings); | 1872 RTC_CHECK(parameters_.codec_settings); |
1878 VideoCodecSettings codec_settings = *parameters_.codec_settings; | 1873 VideoCodecSettings codec_settings = *parameters_.codec_settings; |
1879 | 1874 |
1880 webrtc::VideoEncoderConfig encoder_config = | 1875 webrtc::VideoEncoderConfig encoder_config = |
1881 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 1876 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); |
1882 | 1877 |
1883 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( | 1878 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( |
1884 codec_settings.codec, parameters_.options, is_screencast); | 1879 codec_settings.codec); |
1885 | 1880 |
1886 bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config); | 1881 bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config); |
1887 | 1882 |
1888 encoder_config.encoder_specific_settings = NULL; | 1883 encoder_config.encoder_specific_settings = NULL; |
1889 pending_encoder_reconfiguration_ = false; | 1884 pending_encoder_reconfiguration_ = false; |
1890 | 1885 |
1891 if (!stream_reconfigured) { | 1886 if (!stream_reconfigured) { |
1892 LOG(LS_WARNING) << "Failed to reconfigure video encoder for dimensions: " | |
1893 << width << "x" << height; | |
1894 return; | 1887 return; |
1895 } | 1888 } |
1896 | 1889 |
1897 parameters_.encoder_config = encoder_config; | 1890 parameters_.encoder_config = encoder_config; |
1898 } | 1891 } |
1899 | 1892 |
1900 void WebRtcVideoChannel2::WebRtcVideoSendStream::Start() { | 1893 void WebRtcVideoChannel2::WebRtcVideoSendStream::Start() { |
1901 rtc::CritScope cs(&lock_); | 1894 rtc::CritScope cs(&lock_); |
1902 RTC_DCHECK(stream_ != NULL); | 1895 RTC_DCHECK(stream_ != NULL); |
1903 stream_->Start(); | 1896 stream_->Start(); |
(...skipping 10 matching lines...) Expand all Loading... |
1914 | 1907 |
1915 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) { | 1908 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) { |
1916 if (worker_thread_ != rtc::Thread::Current()) { | 1909 if (worker_thread_ != rtc::Thread::Current()) { |
1917 invoker_.AsyncInvoke<void>( | 1910 invoker_.AsyncInvoke<void>( |
1918 worker_thread_, | 1911 worker_thread_, |
1919 rtc::Bind(&WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate, | 1912 rtc::Bind(&WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate, |
1920 this, load)); | 1913 this, load)); |
1921 return; | 1914 return; |
1922 } | 1915 } |
1923 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1916 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1924 LOG(LS_INFO) << "OnLoadUpdate " << load; | |
1925 if (!capturer_) { | 1917 if (!capturer_) { |
1926 return; | 1918 return; |
1927 } | 1919 } |
1928 { | 1920 { |
1929 rtc::CritScope cs(&lock_); | 1921 rtc::CritScope cs(&lock_); |
| 1922 LOG(LS_INFO) << "OnLoadUpdate " << load << ", is_screencast: " |
| 1923 << (parameters_.options.is_screencast |
| 1924 ? (*parameters_.options.is_screencast ? "true" |
| 1925 : "false") |
| 1926 : "unset"); |
1930 // Do not adapt resolution for screen content as this will likely result in | 1927 // Do not adapt resolution for screen content as this will likely result in |
1931 // blurry and unreadable text. | 1928 // blurry and unreadable text. |
1932 if (capturer_is_screencast_) | 1929 if (parameters_.options.is_screencast.value_or(false)) |
1933 return; | 1930 return; |
1934 | 1931 |
1935 rtc::Optional<int> max_pixel_count; | 1932 rtc::Optional<int> max_pixel_count; |
1936 rtc::Optional<int> max_pixel_count_step_up; | 1933 rtc::Optional<int> max_pixel_count_step_up; |
1937 if (load == kOveruse) { | 1934 if (load == kOveruse) { |
1938 max_pixel_count = rtc::Optional<int>( | 1935 max_pixel_count = rtc::Optional<int>( |
1939 (last_dimensions_.height * last_dimensions_.width) / 2); | 1936 (last_dimensions_.height * last_dimensions_.width) / 2); |
1940 // Increase |number_of_cpu_adapt_changes_| if | 1937 // Increase |number_of_cpu_adapt_changes_| if |
1941 // sink_wants_.max_pixel_count will be changed since | 1938 // sink_wants_.max_pixel_count will be changed since |
1942 // last time |capturer_->AddOrUpdateSink| was called. That is, this will | 1939 // last time |capturer_->AddOrUpdateSink| was called. That is, this will |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps; | 2070 bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps; |
2074 bwe_info->actual_enc_bitrate += stats.media_bitrate_bps; | 2071 bwe_info->actual_enc_bitrate += stats.media_bitrate_bps; |
2075 } | 2072 } |
2076 | 2073 |
2077 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { | 2074 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { |
2078 if (stream_ != NULL) { | 2075 if (stream_ != NULL) { |
2079 call_->DestroyVideoSendStream(stream_); | 2076 call_->DestroyVideoSendStream(stream_); |
2080 } | 2077 } |
2081 | 2078 |
2082 RTC_CHECK(parameters_.codec_settings); | 2079 RTC_CHECK(parameters_.codec_settings); |
| 2080 RTC_DCHECK_EQ((parameters_.encoder_config.content_type == |
| 2081 webrtc::VideoEncoderConfig::ContentType::kScreen), |
| 2082 parameters_.options.is_screencast.value_or(false)) |
| 2083 << "encoder content type inconsistent with screencast option"; |
2083 parameters_.encoder_config.encoder_specific_settings = | 2084 parameters_.encoder_config.encoder_specific_settings = |
2084 ConfigureVideoEncoderSettings( | 2085 ConfigureVideoEncoderSettings(parameters_.codec_settings->codec); |
2085 parameters_.codec_settings->codec, parameters_.options, | |
2086 parameters_.encoder_config.content_type == | |
2087 webrtc::VideoEncoderConfig::ContentType::kScreen); | |
2088 | 2086 |
2089 webrtc::VideoSendStream::Config config = parameters_.config; | 2087 webrtc::VideoSendStream::Config config = parameters_.config; |
2090 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { | 2088 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { |
2091 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 2089 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
2092 "payload type the set codec. Ignoring RTX."; | 2090 "payload type the set codec. Ignoring RTX."; |
2093 config.rtp.rtx.ssrcs.clear(); | 2091 config.rtp.rtx.ssrcs.clear(); |
2094 } | 2092 } |
2095 stream_ = call_->CreateVideoSendStream(config, parameters_.encoder_config); | 2093 stream_ = call_->CreateVideoSendStream(config, parameters_.encoder_config); |
2096 | 2094 |
2097 parameters_.encoder_config.encoder_specific_settings = NULL; | 2095 parameters_.encoder_config.encoder_specific_settings = NULL; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2517 rtx_mapping[video_codecs[i].codec.id] != | 2515 rtx_mapping[video_codecs[i].codec.id] != |
2518 fec_settings.red_payload_type) { | 2516 fec_settings.red_payload_type) { |
2519 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2517 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2520 } | 2518 } |
2521 } | 2519 } |
2522 | 2520 |
2523 return video_codecs; | 2521 return video_codecs; |
2524 } | 2522 } |
2525 | 2523 |
2526 } // namespace cricket | 2524 } // namespace cricket |
OLD | NEW |