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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 } | 741 } |
742 | 742 |
743 if (!send_codec_ || supported_codecs.front() != *send_codec_) { | 743 if (!send_codec_ || supported_codecs.front() != *send_codec_) { |
744 changed_params->codec = | 744 changed_params->codec = |
745 rtc::Optional<VideoCodecSettings>(supported_codecs.front()); | 745 rtc::Optional<VideoCodecSettings>(supported_codecs.front()); |
746 } | 746 } |
747 | 747 |
748 // Handle RTP header extensions. | 748 // Handle RTP header extensions. |
749 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( | 749 std::vector<webrtc::RtpExtension> filtered_extensions = FilterRtpExtensions( |
750 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true); | 750 params.extensions, webrtc::RtpExtension::IsSupportedForVideo, true); |
751 if (send_rtp_extensions_ != filtered_extensions) { | 751 if (!send_rtp_extensions_ || (*send_rtp_extensions_ != filtered_extensions)) { |
752 changed_params->rtp_header_extensions = | 752 changed_params->rtp_header_extensions = |
753 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); | 753 rtc::Optional<std::vector<webrtc::RtpExtension>>(filtered_extensions); |
754 } | 754 } |
755 | 755 |
756 // Handle max bitrate. | 756 // Handle max bitrate. |
757 if (params.max_bandwidth_bps != send_params_.max_bandwidth_bps && | 757 if (params.max_bandwidth_bps != send_params_.max_bandwidth_bps && |
758 params.max_bandwidth_bps >= 0) { | 758 params.max_bandwidth_bps >= 0) { |
759 // 0 uncaps max bitrate (-1). | 759 // 0 uncaps max bitrate (-1). |
760 changed_params->max_bandwidth_bps = rtc::Optional<int>( | 760 changed_params->max_bandwidth_bps = rtc::Optional<int>( |
761 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); | 761 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); |
(...skipping 27 matching lines...) Expand all Loading... | |
789 return false; | 789 return false; |
790 } | 790 } |
791 | 791 |
792 if (changed_params.codec) { | 792 if (changed_params.codec) { |
793 const VideoCodecSettings& codec_settings = *changed_params.codec; | 793 const VideoCodecSettings& codec_settings = *changed_params.codec; |
794 send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings); | 794 send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings); |
795 LOG(LS_INFO) << "Using codec: " << codec_settings.codec.ToString(); | 795 LOG(LS_INFO) << "Using codec: " << codec_settings.codec.ToString(); |
796 } | 796 } |
797 | 797 |
798 if (changed_params.rtp_header_extensions) { | 798 if (changed_params.rtp_header_extensions) { |
799 send_rtp_extensions_ = *changed_params.rtp_header_extensions; | 799 send_rtp_extensions_ = changed_params.rtp_header_extensions; |
800 } | 800 } |
801 | 801 |
802 if (changed_params.codec || changed_params.max_bandwidth_bps) { | 802 if (changed_params.codec || changed_params.max_bandwidth_bps) { |
803 if (send_codec_) { | 803 if (send_codec_) { |
804 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean | 804 // TODO(holmer): Changing the codec parameters shouldn't necessarily mean |
805 // that we change the min/max of bandwidth estimation. Reevaluate this. | 805 // that we change the min/max of bandwidth estimation. Reevaluate this. |
806 bitrate_config_ = GetBitrateConfigForCodec(send_codec_->codec); | 806 bitrate_config_ = GetBitrateConfigForCodec(send_codec_->codec); |
807 if (!changed_params.codec) { | 807 if (!changed_params.codec) { |
808 // If the codec isn't changing, set the start bitrate to -1 which means | 808 // If the codec isn't changing, set the start bitrate to -1 which means |
809 // "unchanged" so that BWE isn't affected. | 809 // "unchanged" so that BWE isn't affected. |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1513 | 1513 |
1514 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( | 1514 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
1515 webrtc::Call* call, | 1515 webrtc::Call* call, |
1516 const StreamParams& sp, | 1516 const StreamParams& sp, |
1517 const webrtc::VideoSendStream::Config& config, | 1517 const webrtc::VideoSendStream::Config& config, |
1518 const VideoOptions& options, | 1518 const VideoOptions& options, |
1519 WebRtcVideoEncoderFactory* external_encoder_factory, | 1519 WebRtcVideoEncoderFactory* external_encoder_factory, |
1520 bool enable_cpu_overuse_detection, | 1520 bool enable_cpu_overuse_detection, |
1521 int max_bitrate_bps, | 1521 int max_bitrate_bps, |
1522 const rtc::Optional<VideoCodecSettings>& codec_settings, | 1522 const rtc::Optional<VideoCodecSettings>& codec_settings, |
1523 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 1523 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, |
1524 // TODO(deadbeef): Don't duplicate information between send_params, | 1524 // TODO(deadbeef): Don't duplicate information between send_params, |
1525 // rtp_extensions, options, etc. | 1525 // rtp_extensions, options, etc. |
1526 const VideoSendParameters& send_params) | 1526 const VideoSendParameters& send_params) |
1527 : worker_thread_(rtc::Thread::Current()), | 1527 : worker_thread_(rtc::Thread::Current()), |
1528 ssrcs_(sp.ssrcs), | 1528 ssrcs_(sp.ssrcs), |
1529 ssrc_groups_(sp.ssrc_groups), | 1529 ssrc_groups_(sp.ssrc_groups), |
1530 call_(call), | 1530 call_(call), |
1531 cpu_restricted_counter_(0), | 1531 cpu_restricted_counter_(0), |
1532 number_of_cpu_adapt_changes_(0), | 1532 number_of_cpu_adapt_changes_(0), |
1533 source_(nullptr), | 1533 source_(nullptr), |
1534 external_encoder_factory_(external_encoder_factory), | 1534 external_encoder_factory_(external_encoder_factory), |
1535 stream_(nullptr), | 1535 stream_(nullptr), |
1536 parameters_(config, options, max_bitrate_bps, codec_settings), | 1536 parameters_(config, options, max_bitrate_bps, codec_settings), |
1537 rtp_parameters_(CreateRtpParametersWithOneEncoding()), | 1537 rtp_parameters_(CreateRtpParametersWithOneEncoding()), |
1538 pending_encoder_reconfiguration_(false), | 1538 pending_encoder_reconfiguration_(false), |
1539 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), | 1539 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
1540 sending_(false), | 1540 sending_(false), |
1541 last_frame_timestamp_ms_(0) { | 1541 last_frame_timestamp_ms_(0) { |
1542 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1542 parameters_.config.rtp.max_packet_size = kVideoMtu; |
1543 parameters_.conference_mode = send_params.conference_mode; | 1543 parameters_.conference_mode = send_params.conference_mode; |
1544 | 1544 |
1545 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); | 1545 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
1546 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1546 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1547 ¶meters_.config.rtp.rtx.ssrcs); | 1547 ¶meters_.config.rtp.rtx.ssrcs); |
1548 parameters_.config.rtp.c_name = sp.cname; | 1548 parameters_.config.rtp.c_name = sp.cname; |
1549 parameters_.config.rtp.extensions = rtp_extensions; | 1549 if (rtp_extensions) { |
1550 parameters_.config.rtp.extensions = *rtp_extensions; | |
1551 } | |
1550 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size | 1552 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size |
1551 ? webrtc::RtcpMode::kReducedSize | 1553 ? webrtc::RtcpMode::kReducedSize |
1552 : webrtc::RtcpMode::kCompound; | 1554 : webrtc::RtcpMode::kCompound; |
1553 parameters_.config.overuse_callback = | 1555 parameters_.config.overuse_callback = |
1554 enable_cpu_overuse_detection ? this : nullptr; | 1556 enable_cpu_overuse_detection ? this : nullptr; |
1555 | 1557 |
1556 sink_wants_.rotation_applied = !ContainsHeaderExtension( | 1558 sink_wants_.rotation_applied = |
1557 rtp_extensions, webrtc::RtpExtension::kVideoRotationUri); | 1559 rtp_extensions && |
1560 !ContainsHeaderExtension(*rtp_extensions, | |
1561 webrtc::RtpExtension::kVideoRotationUri); | |
pthatcher1
2016/06/15 20:40:23
Can you leave a comment explaining that if it's no
skvlad
2016/06/15 22:10:36
Added a comment.
| |
1558 | 1562 |
1559 if (codec_settings) { | 1563 if (codec_settings) { |
1560 SetCodec(*codec_settings); | 1564 SetCodec(*codec_settings); |
1561 } | 1565 } |
1562 } | 1566 } |
1563 | 1567 |
1564 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { | 1568 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { |
1565 DisconnectSource(); | 1569 DisconnectSource(); |
1566 if (stream_ != NULL) { | 1570 if (stream_ != NULL) { |
1567 call_->DestroyVideoSendStream(stream_); | 1571 call_->DestroyVideoSendStream(stream_); |
(...skipping 18 matching lines...) Expand all Loading... | |
1586 frame.set_render_time_ms(render_time_ms_); | 1590 frame.set_render_time_ms(render_time_ms_); |
1587 return frame; | 1591 return frame; |
1588 } | 1592 } |
1589 | 1593 |
1590 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( | 1594 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( |
1591 const VideoFrame& frame) { | 1595 const VideoFrame& frame) { |
1592 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); | 1596 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); |
1593 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, | 1597 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, |
1594 frame.rotation()); | 1598 frame.rotation()); |
1595 rtc::CritScope cs(&lock_); | 1599 rtc::CritScope cs(&lock_); |
1600 | |
1601 last_rotation_ = video_frame.rotation(); | |
1602 last_frame_is_texture_ = | |
1603 video_frame.video_frame_buffer()->native_handle() != NULL; | |
tommi
2016/06/15 21:00:39
nit: nullptr
skvlad
2016/06/15 22:10:36
Done, and moved into a webrtc::VideoFrame class me
| |
1604 if (video_frame.width() != last_dimensions_.width || | |
1605 video_frame.height() != last_dimensions_.height) { | |
1606 last_dimensions_.width = video_frame.width(); | |
1607 last_dimensions_.height = video_frame.height(); | |
1608 pending_encoder_reconfiguration_ = true; | |
1609 LOG(LS_INFO) << "Caching frame dimensions: " << last_dimensions_.width | |
1610 << "x" << last_dimensions_.height << ", r=" << last_rotation_ | |
1611 << ", texture=" << last_frame_is_texture_; | |
1612 } | |
1613 | |
1596 if (stream_ == NULL) { | 1614 if (stream_ == NULL) { |
1597 // Frame input before send codecs are configured, dropping frame. | 1615 // Frame input before send codecs are configured, dropping frame. |
1598 return; | 1616 return; |
1599 } | 1617 } |
1600 | 1618 |
1601 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; | 1619 int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
1602 | 1620 |
1603 // frame->GetTimeStamp() is essentially a delta, align to webrtc time | 1621 // frame->GetTimeStamp() is essentially a delta, align to webrtc time |
1604 if (!first_frame_timestamp_ms_) { | 1622 if (!first_frame_timestamp_ms_) { |
1605 first_frame_timestamp_ms_ = | 1623 first_frame_timestamp_ms_ = |
1606 rtc::Optional<int64_t>(rtc::TimeMillis() - frame_delta_ms); | 1624 rtc::Optional<int64_t>(rtc::TimeMillis() - frame_delta_ms); |
1607 } | 1625 } |
1608 | 1626 |
1609 last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms; | 1627 last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms; |
1610 | 1628 |
1611 video_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1629 video_frame.set_render_time_ms(last_frame_timestamp_ms_); |
1612 // Reconfigure codec if necessary. | 1630 |
1613 SetDimensions(video_frame.width(), video_frame.height()); | 1631 ReconfigureEncoderIfNecessary(); |
1614 last_rotation_ = video_frame.rotation(); | |
1615 | 1632 |
1616 // Not sending, abort after reconfiguration. Reconfiguration should still | 1633 // Not sending, abort after reconfiguration. Reconfiguration should still |
1617 // occur to permit sending this input as quickly as possible once we start | 1634 // occur to permit sending this input as quickly as possible once we start |
1618 // sending (without having to reconfigure then). | 1635 // sending (without having to reconfigure then). |
1619 if (!sending_) { | 1636 if (!sending_) { |
1620 return; | 1637 return; |
1621 } | 1638 } |
1622 | 1639 |
1623 stream_->Input()->IncomingCapturedFrame(video_frame); | 1640 stream_->Input()->IncomingCapturedFrame(video_frame); |
1624 } | 1641 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1751 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( | 1768 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( |
1752 AllocatedEncoder* encoder) { | 1769 AllocatedEncoder* encoder) { |
1753 if (encoder->external) { | 1770 if (encoder->external) { |
1754 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); | 1771 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); |
1755 } | 1772 } |
1756 delete encoder->encoder; | 1773 delete encoder->encoder; |
1757 } | 1774 } |
1758 | 1775 |
1759 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec( | 1776 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec( |
1760 const VideoCodecSettings& codec_settings) { | 1777 const VideoCodecSettings& codec_settings) { |
1761 parameters_.encoder_config = | 1778 parameters_.encoder_config = CreateVideoEncoderConfig( |
1762 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 1779 last_dimensions_, last_frame_is_texture_, codec_settings.codec); |
1763 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 1780 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); |
1764 | 1781 |
1765 AllocatedEncoder new_encoder = CreateVideoEncoder(codec_settings.codec); | 1782 AllocatedEncoder new_encoder = CreateVideoEncoder(codec_settings.codec); |
1766 parameters_.config.encoder_settings.encoder = new_encoder.encoder; | 1783 parameters_.config.encoder_settings.encoder = new_encoder.encoder; |
1767 parameters_.config.encoder_settings.full_overuse_time = new_encoder.external; | 1784 parameters_.config.encoder_settings.full_overuse_time = new_encoder.external; |
1768 parameters_.config.encoder_settings.payload_name = codec_settings.codec.name; | 1785 parameters_.config.encoder_settings.payload_name = codec_settings.codec.name; |
1769 parameters_.config.encoder_settings.payload_type = codec_settings.codec.id; | 1786 parameters_.config.encoder_settings.payload_type = codec_settings.codec.id; |
1770 if (new_encoder.external) { | 1787 if (new_encoder.external) { |
1771 webrtc::VideoCodecType type = CodecTypeFromName(codec_settings.codec.name); | 1788 webrtc::VideoCodecType type = CodecTypeFromName(codec_settings.codec.name); |
1772 parameters_.config.encoder_settings.internal_source = | 1789 parameters_.config.encoder_settings.internal_source = |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1892 } else { | 1909 } else { |
1893 if (stream_ != nullptr) { | 1910 if (stream_ != nullptr) { |
1894 stream_->Stop(); | 1911 stream_->Stop(); |
1895 } | 1912 } |
1896 } | 1913 } |
1897 } | 1914 } |
1898 | 1915 |
1899 webrtc::VideoEncoderConfig | 1916 webrtc::VideoEncoderConfig |
1900 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 1917 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
1901 const Dimensions& dimensions, | 1918 const Dimensions& dimensions, |
1919 bool encode_from_texture, | |
pthatcher1
2016/06/15 20:40:23
Since these always come from last_dimentions_ and
skvlad
2016/06/15 22:10:36
Using member variables now.
| |
1902 const VideoCodec& codec) const { | 1920 const VideoCodec& codec) const { |
1903 webrtc::VideoEncoderConfig encoder_config; | 1921 webrtc::VideoEncoderConfig encoder_config; |
1904 bool is_screencast = parameters_.options.is_screencast.value_or(false); | 1922 bool is_screencast = parameters_.options.is_screencast.value_or(false); |
1905 if (is_screencast) { | 1923 if (is_screencast) { |
1906 encoder_config.min_transmit_bitrate_bps = | 1924 encoder_config.min_transmit_bitrate_bps = |
1907 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); | 1925 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); |
1908 encoder_config.content_type = | 1926 encoder_config.content_type = |
1909 webrtc::VideoEncoderConfig::ContentType::kScreen; | 1927 webrtc::VideoEncoderConfig::ContentType::kScreen; |
1910 } else { | 1928 } else { |
1911 encoder_config.min_transmit_bitrate_bps = 0; | 1929 encoder_config.min_transmit_bitrate_bps = 0; |
(...skipping 21 matching lines...) Expand all Loading... | |
1933 size_t stream_count = parameters_.config.rtp.ssrcs.size(); | 1951 size_t stream_count = parameters_.config.rtp.ssrcs.size(); |
1934 if (IsCodecBlacklistedForSimulcast(codec.name) || is_screencast) { | 1952 if (IsCodecBlacklistedForSimulcast(codec.name) || is_screencast) { |
1935 stream_count = 1; | 1953 stream_count = 1; |
1936 } | 1954 } |
1937 | 1955 |
1938 int stream_max_bitrate = | 1956 int stream_max_bitrate = |
1939 MinPositive(rtp_parameters_.encodings[0].max_bitrate_bps, | 1957 MinPositive(rtp_parameters_.encodings[0].max_bitrate_bps, |
1940 parameters_.max_bitrate_bps); | 1958 parameters_.max_bitrate_bps); |
1941 encoder_config.streams = CreateVideoStreams( | 1959 encoder_config.streams = CreateVideoStreams( |
1942 clamped_codec, parameters_.options, stream_max_bitrate, stream_count); | 1960 clamped_codec, parameters_.options, stream_max_bitrate, stream_count); |
1961 encoder_config.encode_from_texture = encode_from_texture; | |
1943 | 1962 |
1944 // Conference mode screencast uses 2 temporal layers split at 100kbit. | 1963 // Conference mode screencast uses 2 temporal layers split at 100kbit. |
1945 if (parameters_.conference_mode && is_screencast && | 1964 if (parameters_.conference_mode && is_screencast && |
1946 encoder_config.streams.size() == 1) { | 1965 encoder_config.streams.size() == 1) { |
1947 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); | 1966 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); |
1948 | 1967 |
1949 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked | 1968 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked |
1950 // on the VideoCodec struct as target and max bitrates, respectively. | 1969 // on the VideoCodec struct as target and max bitrates, respectively. |
1951 // See eg. webrtc::VP8EncoderImpl::SetRates(). | 1970 // See eg. webrtc::VP8EncoderImpl::SetRates(). |
1952 encoder_config.streams[0].target_bitrate_bps = | 1971 encoder_config.streams[0].target_bitrate_bps = |
1953 config.tl0_bitrate_kbps * 1000; | 1972 config.tl0_bitrate_kbps * 1000; |
1954 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; | 1973 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; |
1955 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); | 1974 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); |
1956 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( | 1975 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( |
1957 config.tl0_bitrate_kbps * 1000); | 1976 config.tl0_bitrate_kbps * 1000); |
1958 } | 1977 } |
1959 if (CodecNamesEq(codec.name, kVp9CodecName) && !is_screencast && | 1978 if (CodecNamesEq(codec.name, kVp9CodecName) && !is_screencast && |
1960 encoder_config.streams.size() == 1) { | 1979 encoder_config.streams.size() == 1) { |
1961 encoder_config.streams[0].temporal_layer_thresholds_bps.resize( | 1980 encoder_config.streams[0].temporal_layer_thresholds_bps.resize( |
1962 GetDefaultVp9TemporalLayers() - 1); | 1981 GetDefaultVp9TemporalLayers() - 1); |
1963 } | 1982 } |
1964 return encoder_config; | 1983 return encoder_config; |
1965 } | 1984 } |
1966 | 1985 |
1967 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( | 1986 void WebRtcVideoChannel2::WebRtcVideoSendStream:: |
1968 int width, | 1987 ReconfigureEncoderIfNecessary() { |
pthatcher1
2016/06/15 20:40:23
Why not just call this ReconfigureEncoder() and ha
skvlad
2016/06/15 22:10:36
Done.
| |
1969 int height) { | 1988 if (!pending_encoder_reconfiguration_) { |
1970 if (last_dimensions_.width == width && last_dimensions_.height == height && | |
1971 !pending_encoder_reconfiguration_) { | |
1972 // Configured using the same parameters, do not reconfigure. | 1989 // Configured using the same parameters, do not reconfigure. |
1973 return; | 1990 return; |
1974 } | 1991 } |
1975 | 1992 |
1976 last_dimensions_.width = width; | |
1977 last_dimensions_.height = height; | |
1978 | |
1979 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 1993 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); |
1980 | 1994 |
1981 RTC_CHECK(parameters_.codec_settings); | 1995 RTC_CHECK(parameters_.codec_settings); |
1982 VideoCodecSettings codec_settings = *parameters_.codec_settings; | 1996 VideoCodecSettings codec_settings = *parameters_.codec_settings; |
1983 | 1997 |
1984 webrtc::VideoEncoderConfig encoder_config = | 1998 webrtc::VideoEncoderConfig encoder_config = CreateVideoEncoderConfig( |
1985 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 1999 last_dimensions_, last_frame_is_texture_, codec_settings.codec); |
1986 | 2000 |
1987 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( | 2001 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( |
1988 codec_settings.codec); | 2002 codec_settings.codec); |
1989 | 2003 |
1990 stream_->ReconfigureVideoEncoder(encoder_config); | 2004 stream_->ReconfigureVideoEncoder(encoder_config); |
1991 | 2005 |
1992 encoder_config.encoder_specific_settings = NULL; | 2006 encoder_config.encoder_specific_settings = NULL; |
1993 pending_encoder_reconfiguration_ = false; | 2007 pending_encoder_reconfiguration_ = false; |
1994 | 2008 |
1995 parameters_.encoder_config = encoder_config; | 2009 parameters_.encoder_config = encoder_config; |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2613 rtx_mapping[video_codecs[i].codec.id] != | 2627 rtx_mapping[video_codecs[i].codec.id] != |
2614 fec_settings.red_payload_type) { | 2628 fec_settings.red_payload_type) { |
2615 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2629 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2616 } | 2630 } |
2617 } | 2631 } |
2618 | 2632 |
2619 return video_codecs; | 2633 return video_codecs; |
2620 } | 2634 } |
2621 | 2635 |
2622 } // namespace cricket | 2636 } // namespace cricket |
OLD | NEW |