| 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 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 last_frame_timestamp_ms_ += 1; | 1609 last_frame_timestamp_ms_ += 1; |
| 1610 black_frame.set_render_time_ms(last_frame_timestamp_ms_); | 1610 black_frame.set_render_time_ms(last_frame_timestamp_ms_); |
| 1611 stream_->Input()->IncomingCapturedFrame(black_frame); | 1611 stream_->Input()->IncomingCapturedFrame(black_frame); |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 capturer_ = NULL; | 1614 capturer_ = NULL; |
| 1615 return true; | 1615 return true; |
| 1616 } | 1616 } |
| 1617 } | 1617 } |
| 1618 capturer_ = capturer; | 1618 capturer_ = capturer; |
| 1619 // |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since |
| 1620 // that might cause a lock order inversion. |
| 1619 capturer_->AddOrUpdateSink(this, sink_wants_); | 1621 capturer_->AddOrUpdateSink(this, sink_wants_); |
| 1620 return true; | 1622 return true; |
| 1621 } | 1623 } |
| 1622 | 1624 |
| 1623 void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { | 1625 void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { |
| 1624 rtc::CritScope cs(&lock_); | 1626 rtc::CritScope cs(&lock_); |
| 1625 muted_ = mute; | 1627 muted_ = mute; |
| 1626 } | 1628 } |
| 1627 | 1629 |
| 1628 bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { | 1630 bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { |
| 1629 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1631 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1630 if (capturer_ == NULL) { | 1632 if (capturer_ == NULL) { |
| 1631 return false; | 1633 return false; |
| 1632 } | 1634 } |
| 1633 | 1635 |
| 1636 // |capturer_->RemoveSink| may not be called while holding |lock_| since |
| 1637 // that might cause a lock order inversion. |
| 1634 capturer_->RemoveSink(this); | 1638 capturer_->RemoveSink(this); |
| 1635 capturer_ = NULL; | 1639 capturer_ = NULL; |
| 1636 // Reset |cpu_restricted_counter_| if the capturer is changed. It is not | 1640 // Reset |cpu_restricted_counter_| if the capturer is changed. It is not |
| 1637 // possible to know if the video resolution is restricted by CPU usage after | 1641 // possible to know if the video resolution is restricted by CPU usage after |
| 1638 // the capturer is changed since the next capturer might be screen capture | 1642 // the capturer is changed since the next capturer might be screen capture |
| 1639 // with another resolution and frame rate. | 1643 // with another resolution and frame rate. |
| 1640 cpu_restricted_counter_ = 0; | 1644 cpu_restricted_counter_ = 0; |
| 1641 return true; | 1645 return true; |
| 1642 } | 1646 } |
| 1643 | 1647 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetCodec."; | 1752 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetCodec."; |
| 1749 RecreateWebRtcStream(); | 1753 RecreateWebRtcStream(); |
| 1750 if (allocated_encoder_.encoder != new_encoder.encoder) { | 1754 if (allocated_encoder_.encoder != new_encoder.encoder) { |
| 1751 DestroyVideoEncoder(&allocated_encoder_); | 1755 DestroyVideoEncoder(&allocated_encoder_); |
| 1752 allocated_encoder_ = new_encoder; | 1756 allocated_encoder_ = new_encoder; |
| 1753 } | 1757 } |
| 1754 } | 1758 } |
| 1755 | 1759 |
| 1756 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( | 1760 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( |
| 1757 const ChangedSendParameters& params) { | 1761 const ChangedSendParameters& params) { |
| 1758 rtc::CritScope cs(&lock_); | 1762 { |
| 1759 // |recreate_stream| means construction-time parameters have changed and the | 1763 rtc::CritScope cs(&lock_); |
| 1760 // sending stream needs to be reset with the new config. | 1764 // |recreate_stream| means construction-time parameters have changed and the |
| 1761 bool recreate_stream = false; | 1765 // sending stream needs to be reset with the new config. |
| 1762 if (params.rtcp_mode) { | 1766 bool recreate_stream = false; |
| 1763 parameters_.config.rtp.rtcp_mode = *params.rtcp_mode; | 1767 if (params.rtcp_mode) { |
| 1764 recreate_stream = true; | 1768 parameters_.config.rtp.rtcp_mode = *params.rtcp_mode; |
| 1765 } | 1769 recreate_stream = true; |
| 1770 } |
| 1771 if (params.rtp_header_extensions) { |
| 1772 parameters_.config.rtp.extensions = *params.rtp_header_extensions; |
| 1773 recreate_stream = true; |
| 1774 } |
| 1775 if (params.max_bandwidth_bps) { |
| 1776 // Max bitrate has changed, reconfigure encoder settings on the next frame |
| 1777 // or stream recreation. |
| 1778 parameters_.max_bitrate_bps = *params.max_bandwidth_bps; |
| 1779 pending_encoder_reconfiguration_ = true; |
| 1780 } |
| 1781 if (params.conference_mode) { |
| 1782 parameters_.conference_mode = *params.conference_mode; |
| 1783 } |
| 1784 if (params.options) |
| 1785 SetOptions(*params.options); |
| 1786 |
| 1787 // Set codecs and options. |
| 1788 if (params.codec) { |
| 1789 SetCodec(*params.codec); |
| 1790 return; |
| 1791 } else if (params.conference_mode && parameters_.codec_settings) { |
| 1792 SetCodec(*parameters_.codec_settings); |
| 1793 return; |
| 1794 } |
| 1795 if (recreate_stream) { |
| 1796 LOG(LS_INFO) |
| 1797 << "RecreateWebRtcStream (send) because of SetSendParameters"; |
| 1798 RecreateWebRtcStream(); |
| 1799 } |
| 1800 } // release |lock_| |
| 1801 |
| 1802 // |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since |
| 1803 // that might cause a lock order inversion. |
| 1766 if (params.rtp_header_extensions) { | 1804 if (params.rtp_header_extensions) { |
| 1767 parameters_.config.rtp.extensions = *params.rtp_header_extensions; | |
| 1768 sink_wants_.rotation_applied = !ContainsHeaderExtension( | 1805 sink_wants_.rotation_applied = !ContainsHeaderExtension( |
| 1769 *params.rtp_header_extensions, kRtpVideoRotationHeaderExtension); | 1806 *params.rtp_header_extensions, kRtpVideoRotationHeaderExtension); |
| 1770 if (capturer_) { | 1807 if (capturer_) { |
| 1771 capturer_->AddOrUpdateSink(this, sink_wants_); | 1808 capturer_->AddOrUpdateSink(this, sink_wants_); |
| 1772 } | 1809 } |
| 1773 recreate_stream = true; | |
| 1774 } | |
| 1775 if (params.max_bandwidth_bps) { | |
| 1776 // Max bitrate has changed, reconfigure encoder settings on the next frame | |
| 1777 // or stream recreation. | |
| 1778 parameters_.max_bitrate_bps = *params.max_bandwidth_bps; | |
| 1779 pending_encoder_reconfiguration_ = true; | |
| 1780 } | |
| 1781 if (params.conference_mode) { | |
| 1782 parameters_.conference_mode = *params.conference_mode; | |
| 1783 } | |
| 1784 if (params.options) | |
| 1785 SetOptions(*params.options); | |
| 1786 | |
| 1787 // Set codecs and options. | |
| 1788 if (params.codec) { | |
| 1789 SetCodec(*params.codec); | |
| 1790 return; | |
| 1791 } else if (params.conference_mode && parameters_.codec_settings) { | |
| 1792 SetCodec(*parameters_.codec_settings); | |
| 1793 return; | |
| 1794 } | |
| 1795 if (recreate_stream) { | |
| 1796 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; | |
| 1797 RecreateWebRtcStream(); | |
| 1798 } | 1810 } |
| 1799 } | 1811 } |
| 1800 | 1812 |
| 1801 webrtc::VideoEncoderConfig | 1813 webrtc::VideoEncoderConfig |
| 1802 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 1814 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
| 1803 const Dimensions& dimensions, | 1815 const Dimensions& dimensions, |
| 1804 const VideoCodec& codec) const { | 1816 const VideoCodec& codec) const { |
| 1805 webrtc::VideoEncoderConfig encoder_config; | 1817 webrtc::VideoEncoderConfig encoder_config; |
| 1806 bool is_screencast = parameters_.options.is_screencast.value_or(false); | 1818 bool is_screencast = parameters_.options.is_screencast.value_or(false); |
| 1807 if (is_screencast) { | 1819 if (is_screencast) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 if (sink_wants_.max_pixel_count || | 1966 if (sink_wants_.max_pixel_count || |
| 1955 (sink_wants_.max_pixel_count_step_up && | 1967 (sink_wants_.max_pixel_count_step_up && |
| 1956 *sink_wants_.max_pixel_count_step_up < *max_pixel_count_step_up)) { | 1968 *sink_wants_.max_pixel_count_step_up < *max_pixel_count_step_up)) { |
| 1957 ++number_of_cpu_adapt_changes_; | 1969 ++number_of_cpu_adapt_changes_; |
| 1958 --cpu_restricted_counter_; | 1970 --cpu_restricted_counter_; |
| 1959 } | 1971 } |
| 1960 } | 1972 } |
| 1961 sink_wants_.max_pixel_count = max_pixel_count; | 1973 sink_wants_.max_pixel_count = max_pixel_count; |
| 1962 sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up; | 1974 sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up; |
| 1963 } | 1975 } |
| 1976 // |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since |
| 1977 // that might cause a lock order inversion. |
| 1964 capturer_->AddOrUpdateSink(this, sink_wants_); | 1978 capturer_->AddOrUpdateSink(this, sink_wants_); |
| 1965 } | 1979 } |
| 1966 | 1980 |
| 1967 VideoSenderInfo | 1981 VideoSenderInfo |
| 1968 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { | 1982 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { |
| 1969 VideoSenderInfo info; | 1983 VideoSenderInfo info; |
| 1970 webrtc::VideoSendStream::Stats stats; | 1984 webrtc::VideoSendStream::Stats stats; |
| 1971 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1985 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1972 { | 1986 { |
| 1973 rtc::CritScope cs(&lock_); | 1987 rtc::CritScope cs(&lock_); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2515 rtx_mapping[video_codecs[i].codec.id] != | 2529 rtx_mapping[video_codecs[i].codec.id] != |
| 2516 fec_settings.red_payload_type) { | 2530 fec_settings.red_payload_type) { |
| 2517 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2531 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2518 } | 2532 } |
| 2519 } | 2533 } |
| 2520 | 2534 |
| 2521 return video_codecs; | 2535 return video_codecs; |
| 2522 } | 2536 } |
| 2523 | 2537 |
| 2524 } // namespace cricket | 2538 } // namespace cricket |
| OLD | NEW |