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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 | 403 |
404 int max_qp = kDefaultQpMax; | 404 int max_qp = kDefaultQpMax; |
405 codec.GetParam(kCodecParamMaxQuantization, &max_qp); | 405 codec.GetParam(kCodecParamMaxQuantization, &max_qp); |
406 stream.max_qp = max_qp; | 406 stream.max_qp = max_qp; |
407 std::vector<webrtc::VideoStream> streams; | 407 std::vector<webrtc::VideoStream> streams; |
408 streams.push_back(stream); | 408 streams.push_back(stream); |
409 return streams; | 409 return streams; |
410 } | 410 } |
411 | 411 |
412 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( | 412 void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( |
413 const VideoCodec& codec, | 413 const VideoCodec& codec) { |
414 const VideoOptions& options, | 414 bool is_screencast = parameters_.options.is_screencast.value_or(false); |
415 bool is_screencast) { | |
416 // No automatic resizing when using simulcast or screencast. | 415 // No automatic resizing when using simulcast or screencast. |
417 bool automatic_resize = | 416 bool automatic_resize = |
418 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; | 417 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; |
419 bool frame_dropping = !is_screencast; | 418 bool frame_dropping = !is_screencast; |
420 bool denoising; | 419 bool denoising; |
421 bool codec_default_denoising = false; | 420 bool codec_default_denoising = false; |
422 if (is_screencast) { | 421 if (is_screencast) { |
423 denoising = false; | 422 denoising = false; |
424 } else { | 423 } else { |
425 // Use codec default if video_noise_reduction is unset. | 424 // Use codec default if video_noise_reduction is unset. |
426 codec_default_denoising = !options.video_noise_reduction; | 425 codec_default_denoising = !parameters_.options.video_noise_reduction; |
427 denoising = options.video_noise_reduction.value_or(false); | 426 denoising = parameters_.options.video_noise_reduction.value_or(false); |
428 } | 427 } |
429 | 428 |
430 if (CodecNamesEq(codec.name, kH264CodecName)) { | 429 if (CodecNamesEq(codec.name, kH264CodecName)) { |
431 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); | 430 encoder_settings_.h264 = webrtc::VideoEncoder::GetDefaultH264Settings(); |
432 encoder_settings_.h264.frameDroppingOn = frame_dropping; | 431 encoder_settings_.h264.frameDroppingOn = frame_dropping; |
433 return &encoder_settings_.h264; | 432 return &encoder_settings_.h264; |
434 } | 433 } |
435 if (CodecNamesEq(codec.name, kVp8CodecName)) { | 434 if (CodecNamesEq(codec.name, kVp8CodecName)) { |
436 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); | 435 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); |
437 encoder_settings_.vp8.automaticResizeOn = automatic_resize; | 436 encoder_settings_.vp8.automaticResizeOn = automatic_resize; |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1521 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); | 1520 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
1522 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1521 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1523 ¶meters_.config.rtp.rtx.ssrcs); | 1522 ¶meters_.config.rtp.rtx.ssrcs); |
1524 parameters_.config.rtp.c_name = sp.cname; | 1523 parameters_.config.rtp.c_name = sp.cname; |
1525 parameters_.config.rtp.extensions = rtp_extensions; | 1524 parameters_.config.rtp.extensions = rtp_extensions; |
1526 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size | 1525 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size |
1527 ? webrtc::RtcpMode::kReducedSize | 1526 ? webrtc::RtcpMode::kReducedSize |
1528 : webrtc::RtcpMode::kCompound; | 1527 : webrtc::RtcpMode::kCompound; |
1529 | 1528 |
1530 if (codec_settings) { | 1529 if (codec_settings) { |
1531 SetCodecAndOptions(*codec_settings, parameters_.options); | 1530 SetCodecAndOptions(*codec_settings); |
1532 } | 1531 } |
1533 } | 1532 } |
1534 | 1533 |
1535 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { | 1534 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { |
1536 DisconnectCapturer(); | 1535 DisconnectCapturer(); |
1537 if (stream_ != NULL) { | 1536 if (stream_ != NULL) { |
1538 call_->DestroyVideoSendStream(stream_); | 1537 call_->DestroyVideoSendStream(stream_); |
1539 } | 1538 } |
1540 DestroyVideoEncoder(&allocated_encoder_); | 1539 DestroyVideoEncoder(&allocated_encoder_); |
1541 } | 1540 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 | 1580 |
1582 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; | 1581 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
1583 // frame->GetTimeStamp() is essentially a delta, align to webrtc time | 1582 // frame->GetTimeStamp() is essentially a delta, align to webrtc time |
1584 if (first_frame_timestamp_ms_ == 0) { | 1583 if (first_frame_timestamp_ms_ == 0) { |
1585 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; | 1584 first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; |
1586 } | 1585 } |
1587 | 1586 |
1588 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; | 1587 last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; |
1589 video_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1588 video_frame.set_render_time_ms(last_frame_timestamp_ms_); |
1590 // Reconfigure codec if necessary. | 1589 // Reconfigure codec if necessary. |
1591 SetDimensions(video_frame.width(), video_frame.height(), | 1590 SetDimensions(video_frame.width(), video_frame.height()); |
1592 capturer_->IsScreencast()); | |
1593 last_rotation_ = video_frame.rotation(); | 1591 last_rotation_ = video_frame.rotation(); |
1594 | 1592 |
1595 stream_->Input()->IncomingCapturedFrame(video_frame); | 1593 stream_->Input()->IncomingCapturedFrame(video_frame); |
1596 } | 1594 } |
1597 | 1595 |
1598 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( | 1596 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( |
1599 VideoCapturer* capturer) { | 1597 VideoCapturer* capturer) { |
1600 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer"); | 1598 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer"); |
1601 if (!DisconnectCapturer() && capturer == NULL) { | 1599 if (!DisconnectCapturer() && capturer == NULL) { |
1602 return false; | 1600 return false; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1661 } | 1659 } |
1662 | 1660 |
1663 const std::vector<uint32_t>& | 1661 const std::vector<uint32_t>& |
1664 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { | 1662 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { |
1665 return ssrcs_; | 1663 return ssrcs_; |
1666 } | 1664 } |
1667 | 1665 |
1668 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( | 1666 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( |
1669 const VideoOptions& options) { | 1667 const VideoOptions& options) { |
1670 rtc::CritScope cs(&lock_); | 1668 rtc::CritScope cs(&lock_); |
1669 // TODO(nisse): Use .SetAll method? | |
1670 parameters_.options = options; | |
pthatcher1
2016/02/20 08:33:00
If you don't, then the options that come from SetV
nisse-webrtc
2016/02/22 07:52:34
I'll change to SetAll. I think splitting VideoOpti
nisse-webrtc
2016/02/23 13:13:59
Done.
| |
1671 if (parameters_.codec_settings) { | 1671 if (parameters_.codec_settings) { |
1672 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" | 1672 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" |
1673 << options.ToString(); | 1673 << options.ToString(); |
1674 SetCodecAndOptions(*parameters_.codec_settings, options); | 1674 SetCodecAndOptions(*parameters_.codec_settings); |
1675 } else { | |
1676 parameters_.options = options; | |
1677 } | 1675 } |
1678 } | 1676 } |
1679 | 1677 |
1680 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { | 1678 webrtc::VideoCodecType CodecTypeFromName(const std::string& name) { |
1681 if (CodecNamesEq(name, kVp8CodecName)) { | 1679 if (CodecNamesEq(name, kVp8CodecName)) { |
1682 return webrtc::kVideoCodecVP8; | 1680 return webrtc::kVideoCodecVP8; |
1683 } else if (CodecNamesEq(name, kVp9CodecName)) { | 1681 } else if (CodecNamesEq(name, kVp9CodecName)) { |
1684 return webrtc::kVideoCodecVP9; | 1682 return webrtc::kVideoCodecVP9; |
1685 } else if (CodecNamesEq(name, kH264CodecName)) { | 1683 } else if (CodecNamesEq(name, kH264CodecName)) { |
1686 return webrtc::kVideoCodecH264; | 1684 return webrtc::kVideoCodecH264; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1725 | 1723 |
1726 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( | 1724 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( |
1727 AllocatedEncoder* encoder) { | 1725 AllocatedEncoder* encoder) { |
1728 if (encoder->external) { | 1726 if (encoder->external) { |
1729 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); | 1727 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); |
1730 } | 1728 } |
1731 delete encoder->encoder; | 1729 delete encoder->encoder; |
1732 } | 1730 } |
1733 | 1731 |
1734 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodecAndOptions( | 1732 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodecAndOptions( |
1735 const VideoCodecSettings& codec_settings, | 1733 const VideoCodecSettings& codec_settings) { |
1736 const VideoOptions& options) { | |
1737 parameters_.encoder_config = | 1734 parameters_.encoder_config = |
1738 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 1735 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); |
1739 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 1736 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); |
1740 | 1737 |
1741 AllocatedEncoder new_encoder = CreateVideoEncoder(codec_settings.codec); | 1738 AllocatedEncoder new_encoder = CreateVideoEncoder(codec_settings.codec); |
1742 parameters_.config.encoder_settings.encoder = new_encoder.encoder; | 1739 parameters_.config.encoder_settings.encoder = new_encoder.encoder; |
1743 parameters_.config.encoder_settings.full_overuse_time = new_encoder.external; | 1740 parameters_.config.encoder_settings.full_overuse_time = new_encoder.external; |
1744 parameters_.config.encoder_settings.payload_name = codec_settings.codec.name; | 1741 parameters_.config.encoder_settings.payload_name = codec_settings.codec.name; |
1745 parameters_.config.encoder_settings.payload_type = codec_settings.codec.id; | 1742 parameters_.config.encoder_settings.payload_type = codec_settings.codec.id; |
1746 if (new_encoder.external) { | 1743 if (new_encoder.external) { |
(...skipping 11 matching lines...) Expand all Loading... | |
1758 parameters_.config.rtp.rtx.ssrcs.clear(); | 1755 parameters_.config.rtp.rtx.ssrcs.clear(); |
1759 } else { | 1756 } else { |
1760 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1757 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
1761 } | 1758 } |
1762 } | 1759 } |
1763 | 1760 |
1764 parameters_.config.rtp.nack.rtp_history_ms = | 1761 parameters_.config.rtp.nack.rtp_history_ms = |
1765 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 1762 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; |
1766 | 1763 |
1767 parameters_.config.suspend_below_min_bitrate = | 1764 parameters_.config.suspend_below_min_bitrate = |
1768 options.suspend_below_min_bitrate.value_or(false); | 1765 parameters_.options.suspend_below_min_bitrate.value_or(false); |
1769 | 1766 |
1770 parameters_.codec_settings = | 1767 parameters_.codec_settings = |
1771 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); | 1768 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); |
1772 parameters_.options = options; | |
1773 | 1769 |
1774 LOG(LS_INFO) | 1770 LOG(LS_INFO) |
1775 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" | 1771 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" |
1776 << options.ToString(); | 1772 << parameters_.options.ToString(); |
1777 RecreateWebRtcStream(); | 1773 RecreateWebRtcStream(); |
1778 if (allocated_encoder_.encoder != new_encoder.encoder) { | 1774 if (allocated_encoder_.encoder != new_encoder.encoder) { |
1779 DestroyVideoEncoder(&allocated_encoder_); | 1775 DestroyVideoEncoder(&allocated_encoder_); |
1780 allocated_encoder_ = new_encoder; | 1776 allocated_encoder_ = new_encoder; |
1781 } | 1777 } |
1782 } | 1778 } |
1783 | 1779 |
1784 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( | 1780 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( |
1785 const ChangedSendParameters& params) { | 1781 const ChangedSendParameters& params) { |
1786 rtc::CritScope cs(&lock_); | 1782 rtc::CritScope cs(&lock_); |
(...skipping 16 matching lines...) Expand all Loading... | |
1803 if (params.max_bandwidth_bps) { | 1799 if (params.max_bandwidth_bps) { |
1804 // Max bitrate has changed, reconfigure encoder settings on the next frame | 1800 // Max bitrate has changed, reconfigure encoder settings on the next frame |
1805 // or stream recreation. | 1801 // or stream recreation. |
1806 parameters_.max_bitrate_bps = *params.max_bandwidth_bps; | 1802 parameters_.max_bitrate_bps = *params.max_bandwidth_bps; |
1807 pending_encoder_reconfiguration_ = true; | 1803 pending_encoder_reconfiguration_ = true; |
1808 } | 1804 } |
1809 if (params.conference_mode) { | 1805 if (params.conference_mode) { |
1810 parameters_.conference_mode = *params.conference_mode; | 1806 parameters_.conference_mode = *params.conference_mode; |
1811 } | 1807 } |
1812 // Set codecs and options. | 1808 // Set codecs and options. |
1809 if (params.options) | |
1810 parameters_.options = *params.options; | |
1813 if (params.codec) { | 1811 if (params.codec) { |
1814 SetCodecAndOptions(*params.codec, | 1812 SetCodecAndOptions(*params.codec); |
1815 params.options ? *params.options : parameters_.options); | |
1816 return; | 1813 return; |
1817 } else if (params.options) { | 1814 } else if (params.options) { |
1818 // Reconfigure if codecs are already set. | 1815 // Reconfigure if codecs are already set. |
1819 if (parameters_.codec_settings) { | 1816 if (parameters_.codec_settings) { |
1820 SetCodecAndOptions(*parameters_.codec_settings, *params.options); | 1817 SetCodecAndOptions(*parameters_.codec_settings); |
1821 return; | 1818 return; |
1822 } else { | |
1823 parameters_.options = *params.options; | |
1824 } | 1819 } |
1825 } | 1820 } |
1826 else if (params.conference_mode && parameters_.codec_settings) { | 1821 else if (params.conference_mode && parameters_.codec_settings) { |
1827 SetCodecAndOptions(*parameters_.codec_settings, parameters_.options); | 1822 SetCodecAndOptions(*parameters_.codec_settings); |
1828 return; | 1823 return; |
1829 } | 1824 } |
1830 if (recreate_stream) { | 1825 if (recreate_stream) { |
1831 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; | 1826 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; |
1832 RecreateWebRtcStream(); | 1827 RecreateWebRtcStream(); |
1833 } | 1828 } |
1834 } | 1829 } |
1835 | 1830 |
1836 webrtc::VideoEncoderConfig | 1831 webrtc::VideoEncoderConfig |
1837 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 1832 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
1838 const Dimensions& dimensions, | 1833 const Dimensions& dimensions, |
1839 const VideoCodec& codec) const { | 1834 const VideoCodec& codec) const { |
1840 webrtc::VideoEncoderConfig encoder_config; | 1835 webrtc::VideoEncoderConfig encoder_config; |
1841 if (dimensions.is_screencast) { | 1836 bool is_screencast = parameters_.options.is_screencast.value_or(false); |
1837 if (is_screencast) { | |
1842 encoder_config.min_transmit_bitrate_bps = | 1838 encoder_config.min_transmit_bitrate_bps = |
1843 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); | 1839 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); |
1844 encoder_config.content_type = | 1840 encoder_config.content_type = |
1845 webrtc::VideoEncoderConfig::ContentType::kScreen; | 1841 webrtc::VideoEncoderConfig::ContentType::kScreen; |
1846 } else { | 1842 } else { |
1847 encoder_config.min_transmit_bitrate_bps = 0; | 1843 encoder_config.min_transmit_bitrate_bps = 0; |
1848 encoder_config.content_type = | 1844 encoder_config.content_type = |
1849 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; | 1845 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; |
1850 } | 1846 } |
1851 | 1847 |
1852 // Restrict dimensions according to codec max. | 1848 // Restrict dimensions according to codec max. |
1853 int width = dimensions.width; | 1849 int width = dimensions.width; |
1854 int height = dimensions.height; | 1850 int height = dimensions.height; |
1855 if (!dimensions.is_screencast) { | 1851 if (!is_screencast) { |
1856 if (codec.width < width) | 1852 if (codec.width < width) |
1857 width = codec.width; | 1853 width = codec.width; |
1858 if (codec.height < height) | 1854 if (codec.height < height) |
1859 height = codec.height; | 1855 height = codec.height; |
1860 } | 1856 } |
1861 | 1857 |
1862 VideoCodec clamped_codec = codec; | 1858 VideoCodec clamped_codec = codec; |
1863 clamped_codec.width = width; | 1859 clamped_codec.width = width; |
1864 clamped_codec.height = height; | 1860 clamped_codec.height = height; |
1865 | 1861 |
1866 // By default, the stream count for the codec configuration should match the | 1862 // By default, the stream count for the codec configuration should match the |
1867 // number of negotiated ssrcs. But if the codec is blacklisted for simulcast | 1863 // number of negotiated ssrcs. But if the codec is blacklisted for simulcast |
1868 // or a screencast, only configure a single stream. | 1864 // or a screencast, only configure a single stream. |
1869 size_t stream_count = parameters_.config.rtp.ssrcs.size(); | 1865 size_t stream_count = parameters_.config.rtp.ssrcs.size(); |
1870 if (IsCodecBlacklistedForSimulcast(codec.name) || dimensions.is_screencast) { | 1866 if (IsCodecBlacklistedForSimulcast(codec.name) || is_screencast) { |
1871 stream_count = 1; | 1867 stream_count = 1; |
1872 } | 1868 } |
1873 | 1869 |
1874 encoder_config.streams = | 1870 encoder_config.streams = |
1875 CreateVideoStreams(clamped_codec, parameters_.options, | 1871 CreateVideoStreams(clamped_codec, parameters_.options, |
1876 parameters_.max_bitrate_bps, stream_count); | 1872 parameters_.max_bitrate_bps, stream_count); |
1877 | 1873 |
1878 // Conference mode screencast uses 2 temporal layers split at 100kbit. | 1874 // Conference mode screencast uses 2 temporal layers split at 100kbit. |
1879 if (parameters_.conference_mode && dimensions.is_screencast && | 1875 if (parameters_.conference_mode && is_screencast && |
1880 encoder_config.streams.size() == 1) { | 1876 encoder_config.streams.size() == 1) { |
1881 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); | 1877 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); |
1882 | 1878 |
1883 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked | 1879 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked |
1884 // on the VideoCodec struct as target and max bitrates, respectively. | 1880 // on the VideoCodec struct as target and max bitrates, respectively. |
1885 // See eg. webrtc::VP8EncoderImpl::SetRates(). | 1881 // See eg. webrtc::VP8EncoderImpl::SetRates(). |
1886 encoder_config.streams[0].target_bitrate_bps = | 1882 encoder_config.streams[0].target_bitrate_bps = |
1887 config.tl0_bitrate_kbps * 1000; | 1883 config.tl0_bitrate_kbps * 1000; |
1888 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; | 1884 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; |
1889 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); | 1885 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); |
1890 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( | 1886 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( |
1891 config.tl0_bitrate_kbps * 1000); | 1887 config.tl0_bitrate_kbps * 1000); |
1892 } | 1888 } |
1893 return encoder_config; | 1889 return encoder_config; |
1894 } | 1890 } |
1895 | 1891 |
1896 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( | 1892 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( |
1897 int width, | 1893 int width, |
1898 int height, | 1894 int height) { |
1899 bool is_screencast) { | |
1900 if (last_dimensions_.width == width && last_dimensions_.height == height && | 1895 if (last_dimensions_.width == width && last_dimensions_.height == height && |
1901 last_dimensions_.is_screencast == is_screencast && | |
1902 !pending_encoder_reconfiguration_) { | 1896 !pending_encoder_reconfiguration_) { |
1903 // Configured using the same parameters, do not reconfigure. | 1897 // Configured using the same parameters, do not reconfigure. |
1904 return; | 1898 return; |
1905 } | 1899 } |
1906 LOG(LS_INFO) << "SetDimensions: " << width << "x" << height | 1900 LOG(LS_INFO) << "SetDimensions: " << width << "x" << height; |
1907 << (is_screencast ? " (screencast)" : " (not screencast)"); | |
1908 | 1901 |
1909 last_dimensions_.width = width; | 1902 last_dimensions_.width = width; |
1910 last_dimensions_.height = height; | 1903 last_dimensions_.height = height; |
1911 last_dimensions_.is_screencast = is_screencast; | |
1912 | 1904 |
1913 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 1905 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); |
1914 | 1906 |
1915 RTC_CHECK(parameters_.codec_settings); | 1907 RTC_CHECK(parameters_.codec_settings); |
1916 VideoCodecSettings codec_settings = *parameters_.codec_settings; | 1908 VideoCodecSettings codec_settings = *parameters_.codec_settings; |
1917 | 1909 |
1918 webrtc::VideoEncoderConfig encoder_config = | 1910 webrtc::VideoEncoderConfig encoder_config = |
1919 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 1911 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); |
1920 | 1912 |
1921 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( | 1913 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( |
1922 codec_settings.codec, parameters_.options, is_screencast); | 1914 codec_settings.codec); |
1923 | 1915 |
1924 bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config); | 1916 bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config); |
1925 | 1917 |
1926 encoder_config.encoder_specific_settings = NULL; | 1918 encoder_config.encoder_specific_settings = NULL; |
1927 pending_encoder_reconfiguration_ = false; | 1919 pending_encoder_reconfiguration_ = false; |
1928 | 1920 |
1929 if (!stream_reconfigured) { | 1921 if (!stream_reconfigured) { |
1930 LOG(LS_WARNING) << "Failed to reconfigure video encoder for dimensions: " | 1922 LOG(LS_WARNING) << "Failed to reconfigure video encoder for dimensions: " |
1931 << width << "x" << height; | 1923 << width << "x" << height; |
1932 return; | 1924 return; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2060 bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps; | 2052 bwe_info->target_enc_bitrate += stats.target_media_bitrate_bps; |
2061 bwe_info->actual_enc_bitrate += stats.media_bitrate_bps; | 2053 bwe_info->actual_enc_bitrate += stats.media_bitrate_bps; |
2062 } | 2054 } |
2063 | 2055 |
2064 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { | 2056 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { |
2065 if (stream_ != NULL) { | 2057 if (stream_ != NULL) { |
2066 call_->DestroyVideoSendStream(stream_); | 2058 call_->DestroyVideoSendStream(stream_); |
2067 } | 2059 } |
2068 | 2060 |
2069 RTC_CHECK(parameters_.codec_settings); | 2061 RTC_CHECK(parameters_.codec_settings); |
2062 RTC_DCHECK_EQ((parameters_.encoder_config.content_type == | |
2063 webrtc::VideoEncoderConfig::ContentType::kScreen), | |
2064 parameters_.options.is_screencast.value_or(false)) | |
2065 << "encoder content type inconsistent with screencast option"; | |
2070 parameters_.encoder_config.encoder_specific_settings = | 2066 parameters_.encoder_config.encoder_specific_settings = |
2071 ConfigureVideoEncoderSettings( | 2067 ConfigureVideoEncoderSettings(parameters_.codec_settings->codec); |
2072 parameters_.codec_settings->codec, parameters_.options, | |
2073 parameters_.encoder_config.content_type == | |
2074 webrtc::VideoEncoderConfig::ContentType::kScreen); | |
2075 | 2068 |
2076 webrtc::VideoSendStream::Config config = parameters_.config; | 2069 webrtc::VideoSendStream::Config config = parameters_.config; |
2077 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { | 2070 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { |
2078 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 2071 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
2079 "payload type the set codec. Ignoring RTX."; | 2072 "payload type the set codec. Ignoring RTX."; |
2080 config.rtp.rtx.ssrcs.clear(); | 2073 config.rtp.rtx.ssrcs.clear(); |
2081 } | 2074 } |
2082 stream_ = call_->CreateVideoSendStream(config, parameters_.encoder_config); | 2075 stream_ = call_->CreateVideoSendStream(config, parameters_.encoder_config); |
2083 | 2076 |
2084 parameters_.encoder_config.encoder_specific_settings = NULL; | 2077 parameters_.encoder_config.encoder_specific_settings = NULL; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2504 rtx_mapping[video_codecs[i].codec.id] != | 2497 rtx_mapping[video_codecs[i].codec.id] != |
2505 fec_settings.red_payload_type) { | 2498 fec_settings.red_payload_type) { |
2506 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2499 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2507 } | 2500 } |
2508 } | 2501 } |
2509 | 2502 |
2510 return video_codecs; | 2503 return video_codecs; |
2511 } | 2504 } |
2512 | 2505 |
2513 } // namespace cricket | 2506 } // namespace cricket |
OLD | NEW |