OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 options_.SetAll(options); | 780 options_.SetAll(options); |
781 if (options_.cpu_overuse_detection) | 781 if (options_.cpu_overuse_detection) |
782 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; | 782 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; |
783 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 783 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
784 sending_ = false; | 784 sending_ = false; |
785 default_send_ssrc_ = 0; | 785 default_send_ssrc_ = 0; |
786 SetRecvCodecs(recv_codecs); | 786 SetRecvCodecs(recv_codecs); |
787 } | 787 } |
788 | 788 |
789 void WebRtcVideoChannel2::SetDefaultOptions() { | 789 void WebRtcVideoChannel2::SetDefaultOptions() { |
790 options_.cpu_overuse_detection = rtc::Maybe<bool>(true); | 790 options_.cpu_overuse_detection = rtc::Optional<bool>(true); |
791 options_.dscp = rtc::Maybe<bool>(false); | 791 options_.dscp = rtc::Optional<bool>(false); |
792 options_.suspend_below_min_bitrate = rtc::Maybe<bool>(false); | 792 options_.suspend_below_min_bitrate = rtc::Optional<bool>(false); |
793 options_.screencast_min_bitrate = rtc::Maybe<int>(0); | 793 options_.screencast_min_bitrate = rtc::Optional<int>(0); |
794 } | 794 } |
795 | 795 |
796 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 796 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
797 for (auto& kv : send_streams_) | 797 for (auto& kv : send_streams_) |
798 delete kv.second; | 798 delete kv.second; |
799 for (auto& kv : receive_streams_) | 799 for (auto& kv : receive_streams_) |
800 delete kv.second; | 800 delete kv.second; |
801 } | 801 } |
802 | 802 |
803 bool WebRtcVideoChannel2::CodecIsExternallySupported( | 803 bool WebRtcVideoChannel2::CodecIsExternallySupported( |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 | 954 |
955 LOG(LS_INFO) << "Using codec: " << supported_codecs.front().codec.ToString(); | 955 LOG(LS_INFO) << "Using codec: " << supported_codecs.front().codec.ToString(); |
956 | 956 |
957 if (send_codec_ && supported_codecs.front() == *send_codec_) { | 957 if (send_codec_ && supported_codecs.front() == *send_codec_) { |
958 LOG(LS_INFO) << "Ignore call to SetSendCodecs because first supported " | 958 LOG(LS_INFO) << "Ignore call to SetSendCodecs because first supported " |
959 "codec hasn't changed."; | 959 "codec hasn't changed."; |
960 // Using same codec, avoid reconfiguring. | 960 // Using same codec, avoid reconfiguring. |
961 return true; | 961 return true; |
962 } | 962 } |
963 | 963 |
964 send_codec_ = rtc::Maybe<WebRtcVideoChannel2::VideoCodecSettings>( | 964 send_codec_ = rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>( |
965 supported_codecs.front()); | 965 supported_codecs.front()); |
966 | 966 |
967 rtc::CritScope stream_lock(&stream_crit_); | 967 rtc::CritScope stream_lock(&stream_crit_); |
968 LOG(LS_INFO) << "Change the send codec because SetSendCodecs has a different " | 968 LOG(LS_INFO) << "Change the send codec because SetSendCodecs has a different " |
969 "first supported codec."; | 969 "first supported codec."; |
970 for (auto& kv : send_streams_) { | 970 for (auto& kv : send_streams_) { |
971 RTC_DCHECK(kv.second != nullptr); | 971 RTC_DCHECK(kv.second != nullptr); |
972 kv.second->SetCodec(supported_codecs.front()); | 972 kv.second->SetCodec(supported_codecs.front()); |
973 } | 973 } |
974 LOG(LS_INFO) << "SetNackAndRemb on all the receive streams because the send " | 974 LOG(LS_INFO) << "SetNackAndRemb on all the receive streams because the send " |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 it != send_streams_.end(); ++it) { | 1698 it != send_streams_.end(); ++it) { |
1699 it->second->Stop(); | 1699 it->second->Stop(); |
1700 } | 1700 } |
1701 } | 1701 } |
1702 | 1702 |
1703 WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters:: | 1703 WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters:: |
1704 VideoSendStreamParameters( | 1704 VideoSendStreamParameters( |
1705 const webrtc::VideoSendStream::Config& config, | 1705 const webrtc::VideoSendStream::Config& config, |
1706 const VideoOptions& options, | 1706 const VideoOptions& options, |
1707 int max_bitrate_bps, | 1707 int max_bitrate_bps, |
1708 const rtc::Maybe<VideoCodecSettings>& codec_settings) | 1708 const rtc::Optional<VideoCodecSettings>& codec_settings) |
1709 : config(config), | 1709 : config(config), |
1710 options(options), | 1710 options(options), |
1711 max_bitrate_bps(max_bitrate_bps), | 1711 max_bitrate_bps(max_bitrate_bps), |
1712 codec_settings(codec_settings) {} | 1712 codec_settings(codec_settings) {} |
1713 | 1713 |
1714 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder( | 1714 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder( |
1715 webrtc::VideoEncoder* encoder, | 1715 webrtc::VideoEncoder* encoder, |
1716 webrtc::VideoCodecType type, | 1716 webrtc::VideoCodecType type, |
1717 bool external) | 1717 bool external) |
1718 : encoder(encoder), | 1718 : encoder(encoder), |
1719 external_encoder(nullptr), | 1719 external_encoder(nullptr), |
1720 type(type), | 1720 type(type), |
1721 external(external) { | 1721 external(external) { |
1722 if (external) { | 1722 if (external) { |
1723 external_encoder = encoder; | 1723 external_encoder = encoder; |
1724 this->encoder = | 1724 this->encoder = |
1725 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); | 1725 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); |
1726 } | 1726 } |
1727 } | 1727 } |
1728 | 1728 |
1729 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( | 1729 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
1730 webrtc::Call* call, | 1730 webrtc::Call* call, |
1731 const StreamParams& sp, | 1731 const StreamParams& sp, |
1732 const webrtc::VideoSendStream::Config& config, | 1732 const webrtc::VideoSendStream::Config& config, |
1733 WebRtcVideoEncoderFactory* external_encoder_factory, | 1733 WebRtcVideoEncoderFactory* external_encoder_factory, |
1734 const VideoOptions& options, | 1734 const VideoOptions& options, |
1735 int max_bitrate_bps, | 1735 int max_bitrate_bps, |
1736 const rtc::Maybe<VideoCodecSettings>& codec_settings, | 1736 const rtc::Optional<VideoCodecSettings>& codec_settings, |
1737 const std::vector<webrtc::RtpExtension>& rtp_extensions) | 1737 const std::vector<webrtc::RtpExtension>& rtp_extensions) |
1738 : ssrcs_(sp.ssrcs), | 1738 : ssrcs_(sp.ssrcs), |
1739 ssrc_groups_(sp.ssrc_groups), | 1739 ssrc_groups_(sp.ssrc_groups), |
1740 call_(call), | 1740 call_(call), |
1741 external_encoder_factory_(external_encoder_factory), | 1741 external_encoder_factory_(external_encoder_factory), |
1742 stream_(NULL), | 1742 stream_(NULL), |
1743 parameters_(config, options, max_bitrate_bps, codec_settings), | 1743 parameters_(config, options, max_bitrate_bps, codec_settings), |
1744 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), | 1744 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), |
1745 capturer_(NULL), | 1745 capturer_(NULL), |
1746 sending_(false), | 1746 sending_(false), |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 } | 2041 } |
2042 | 2042 |
2043 parameters_.config.rtp.nack.rtp_history_ms = | 2043 parameters_.config.rtp.nack.rtp_history_ms = |
2044 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 2044 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; |
2045 | 2045 |
2046 RTC_CHECK(options.suspend_below_min_bitrate); | 2046 RTC_CHECK(options.suspend_below_min_bitrate); |
2047 parameters_.config.suspend_below_min_bitrate = | 2047 parameters_.config.suspend_below_min_bitrate = |
2048 *options.suspend_below_min_bitrate; | 2048 *options.suspend_below_min_bitrate; |
2049 | 2049 |
2050 parameters_.codec_settings = | 2050 parameters_.codec_settings = |
2051 rtc::Maybe<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); | 2051 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); |
2052 parameters_.options = options; | 2052 parameters_.options = options; |
2053 | 2053 |
2054 LOG(LS_INFO) | 2054 LOG(LS_INFO) |
2055 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" | 2055 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" |
2056 << options.ToString(); | 2056 << options.ToString(); |
2057 RecreateWebRtcStream(); | 2057 RecreateWebRtcStream(); |
2058 if (allocated_encoder_.encoder != new_encoder.encoder) { | 2058 if (allocated_encoder_.encoder != new_encoder.encoder) { |
2059 DestroyVideoEncoder(&allocated_encoder_); | 2059 DestroyVideoEncoder(&allocated_encoder_); |
2060 allocated_encoder_ = new_encoder; | 2060 allocated_encoder_ = new_encoder; |
2061 } | 2061 } |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2743 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2744 } | 2744 } |
2745 } | 2745 } |
2746 | 2746 |
2747 return video_codecs; | 2747 return video_codecs; |
2748 } | 2748 } |
2749 | 2749 |
2750 } // namespace cricket | 2750 } // namespace cricket |
2751 | 2751 |
2752 #endif // HAVE_WEBRTC_VIDEO | 2752 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |