| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "webrtc/call.h" | 48 #include "webrtc/call.h" |
| 49 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 49 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 50 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" | 50 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" |
| 51 #include "webrtc/system_wrappers/include/field_trial.h" | 51 #include "webrtc/system_wrappers/include/field_trial.h" |
| 52 #include "webrtc/video_decoder.h" | 52 #include "webrtc/video_decoder.h" |
| 53 #include "webrtc/video_encoder.h" | 53 #include "webrtc/video_encoder.h" |
| 54 | 54 |
| 55 namespace cricket { | 55 namespace cricket { |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 // Default values, used when options are unset. |
| 59 const bool kDefault_suspend_below_min_bitrate = false; |
| 60 const int kDefault_screencast_min_bitrate_kbps = 0; |
| 61 |
| 58 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. | 62 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. |
| 59 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { | 63 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { |
| 60 public: | 64 public: |
| 61 // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned | 65 // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned |
| 62 // by e.g. PeerConnectionFactory. | 66 // by e.g. PeerConnectionFactory. |
| 63 explicit EncoderFactoryAdapter(cricket::WebRtcVideoEncoderFactory* factory) | 67 explicit EncoderFactoryAdapter(cricket::WebRtcVideoEncoderFactory* factory) |
| 64 : factory_(factory) {} | 68 : factory_(factory) {} |
| 65 virtual ~EncoderFactoryAdapter() {} | 69 virtual ~EncoderFactoryAdapter() {} |
| 66 | 70 |
| 67 // Implement webrtc::VideoEncoderFactory. | 71 // Implement webrtc::VideoEncoderFactory. |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 642 } |
| 639 | 643 |
| 640 WebRtcVideoChannel2::WebRtcVideoChannel2( | 644 WebRtcVideoChannel2::WebRtcVideoChannel2( |
| 641 webrtc::Call* call, | 645 webrtc::Call* call, |
| 642 const VideoOptions& options, | 646 const VideoOptions& options, |
| 643 const std::vector<VideoCodec>& recv_codecs, | 647 const std::vector<VideoCodec>& recv_codecs, |
| 644 WebRtcVideoEncoderFactory* external_encoder_factory, | 648 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 645 WebRtcVideoDecoderFactory* external_decoder_factory) | 649 WebRtcVideoDecoderFactory* external_decoder_factory) |
| 646 : call_(call), | 650 : call_(call), |
| 647 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 651 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
| 652 signal_cpu_adaptation_(true), |
| 653 disable_prerenderer_smoothing_(false), |
| 648 external_encoder_factory_(external_encoder_factory), | 654 external_encoder_factory_(external_encoder_factory), |
| 649 external_decoder_factory_(external_decoder_factory) { | 655 external_decoder_factory_(external_decoder_factory) { |
| 650 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 656 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 651 SetDefaultOptions(); | 657 |
| 652 options_.SetAll(options); | 658 SetSharedOptions(options); |
| 653 if (options_.cpu_overuse_detection) | 659 send_params_.options = options; |
| 654 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; | 660 |
| 655 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 661 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
| 656 sending_ = false; | 662 sending_ = false; |
| 657 default_send_ssrc_ = 0; | 663 default_send_ssrc_ = 0; |
| 658 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); | 664 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); |
| 659 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); | 665 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); |
| 660 } | 666 } |
| 661 | 667 |
| 662 void WebRtcVideoChannel2::SetDefaultOptions() { | |
| 663 options_.cpu_overuse_detection = rtc::Optional<bool>(true); | |
| 664 options_.dscp = rtc::Optional<bool>(false); | |
| 665 options_.suspend_below_min_bitrate = rtc::Optional<bool>(false); | |
| 666 options_.screencast_min_bitrate_kbps = rtc::Optional<int>(0); | |
| 667 } | |
| 668 | |
| 669 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 668 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
| 670 for (auto& kv : send_streams_) | 669 for (auto& kv : send_streams_) |
| 671 delete kv.second; | 670 delete kv.second; |
| 672 for (auto& kv : receive_streams_) | 671 for (auto& kv : receive_streams_) |
| 673 delete kv.second; | 672 delete kv.second; |
| 674 } | 673 } |
| 675 | 674 |
| 676 bool WebRtcVideoChannel2::CodecIsExternallySupported( | 675 bool WebRtcVideoChannel2::CodecIsExternallySupported( |
| 677 const std::string& name) const { | 676 const std::string& name) const { |
| 678 if (external_encoder_factory_ == NULL) { | 677 if (external_encoder_factory_ == NULL) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && | 770 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && |
| 772 params.max_bandwidth_bps >= 0) { | 771 params.max_bandwidth_bps >= 0) { |
| 773 // 0 uncaps max bitrate (-1). | 772 // 0 uncaps max bitrate (-1). |
| 774 changed_params->max_bandwidth_bps = rtc::Optional<int>( | 773 changed_params->max_bandwidth_bps = rtc::Optional<int>( |
| 775 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); | 774 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); |
| 776 } | 775 } |
| 777 | 776 |
| 778 // Handle options. | 777 // Handle options. |
| 779 // TODO(pbos): Require VideoSendParameters to contain a full set of options | 778 // TODO(pbos): Require VideoSendParameters to contain a full set of options |
| 780 // and check if params.options != options_ instead of applying a delta. | 779 // and check if params.options != options_ instead of applying a delta. |
| 781 VideoOptions new_options = options_; | 780 |
| 781 // Keep the default options. TODO(nisse): This is a bit convoluted. |
| 782 // It might be cleaner to change SetDefaultOptions to only set |
| 783 // options with no current value. Or delete SetDefaultOptions; I |
| 784 // think the problem is references to suspend_below_min_bitrate and |
| 785 // screencast_min_bitrate which require values to be set, but those |
| 786 // references could be changed to use .value_or(the_default_value) |
| 787 // instead. |
| 788 |
| 789 VideoOptions new_options = send_params_.options; |
| 782 new_options.SetAll(params.options); | 790 new_options.SetAll(params.options); |
| 783 if (!(new_options == options_)) { | 791 if (!(new_options == send_params_.options)) { |
| 784 changed_params->options = rtc::Optional<VideoOptions>(new_options); | 792 changed_params->options = rtc::Optional<VideoOptions>(new_options); |
| 785 } | 793 } |
| 794 #if 0 |
| 795 send_params_.options = new_options; |
| 796 #endif |
| 786 | 797 |
| 787 // Handle RTCP mode. | 798 // Handle RTCP mode. |
| 788 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { | 799 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { |
| 789 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( | 800 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( |
| 790 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize | 801 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
| 791 : webrtc::RtcpMode::kCompound); | 802 : webrtc::RtcpMode::kCompound); |
| 792 } | 803 } |
| 793 | 804 |
| 805 #if 0 |
| 806 SetSharedOptions(params.options); |
| 807 // TODO(nisse): Call each stream's SetSendParameters only for |
| 808 // changed parameters? Used to check params.rtcp.reduced_size, but |
| 809 // that broke the |
| 810 // WebRtcVideoChannel2Test.SetOptionsWithSuspendBelowMinBitrate |
| 811 // test. |
| 812 |
| 813 VideoOptions options = send_params_.options; |
| 814 send_params_ = params; |
| 815 |
| 816 // Take care to keep old values of options, if the new params |
| 817 // doesn't specify any value. |
| 818 options.SetAll(params.options); |
| 819 send_params_.options = options; |
| 820 |
| 821 SetSharedOptions(send_params_.options); |
| 822 // Call each stream's SetSendParameters method. Leaves to the callee |
| 823 // to check if there's any change. |
| 824 |
| 825 { |
| 826 rtc::CritScope stream_lock(&stream_crit_); |
| 827 for (auto& kv : send_streams_) { |
| 828 kv.second->SetSendParameters(params); |
| 829 } |
| 830 } |
| 831 #endif |
| 832 |
| 794 return true; | 833 return true; |
| 795 } | 834 } |
| 796 | 835 |
| 797 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { | 836 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { |
| 798 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters"); | 837 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters"); |
| 799 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); | 838 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); |
| 839 // TODO(nisse): Should GetChangedSendParameters call SetSharedOptions? |
| 800 ChangedSendParameters changed_params; | 840 ChangedSendParameters changed_params; |
| 801 if (!GetChangedSendParameters(params, &changed_params)) { | 841 if (!GetChangedSendParameters(params, &changed_params)) { |
| 802 return false; | 842 return false; |
| 803 } | 843 } |
| 804 | 844 |
| 805 bool bitrate_config_changed = false; | 845 bool bitrate_config_changed = false; |
| 806 | 846 |
| 807 if (changed_params.codec) { | 847 if (changed_params.codec) { |
| 808 const VideoCodecSettings& codec_settings = *changed_params.codec; | 848 const VideoCodecSettings& codec_settings = *changed_params.codec; |
| 809 send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings); | 849 send_codec_ = rtc::Optional<VideoCodecSettings>(codec_settings); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 831 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { | 871 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { |
| 832 bitrate_config_.min_bitrate_bps = max_bitrate_bps; | 872 bitrate_config_.min_bitrate_bps = max_bitrate_bps; |
| 833 } | 873 } |
| 834 bitrate_config_changed = true; | 874 bitrate_config_changed = true; |
| 835 } | 875 } |
| 836 | 876 |
| 837 if (bitrate_config_changed) { | 877 if (bitrate_config_changed) { |
| 838 call_->SetBitrateConfig(bitrate_config_); | 878 call_->SetBitrateConfig(bitrate_config_); |
| 839 } | 879 } |
| 840 | 880 |
| 881 #if 0 |
| 841 if (changed_params.options) { | 882 if (changed_params.options) { |
| 842 options_.SetAll(*changed_params.options); | 883 options_.SetAll(*changed_params.options); |
| 843 { | 884 { |
| 844 rtc::CritScope lock(&capturer_crit_); | 885 rtc::CritScope lock(&capturer_crit_); |
| 845 if (options_.cpu_overuse_detection) { | 886 if (options_.cpu_overuse_detection) { |
| 846 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; | 887 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; |
| 847 } | 888 } |
| 848 } | 889 } |
| 849 rtc::DiffServCodePoint dscp = | 890 rtc::DiffServCodePoint dscp = |
| 850 options_.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; | 891 options_.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; |
| 851 MediaChannel::SetDscp(dscp); | 892 MediaChannel::SetDscp(dscp); |
| 852 } | 893 } |
| 853 | 894 #endif |
| 854 { | 895 { |
| 855 rtc::CritScope stream_lock(&stream_crit_); | 896 rtc::CritScope stream_lock(&stream_crit_); |
| 856 for (auto& kv : send_streams_) { | 897 for (auto& kv : send_streams_) { |
| 857 kv.second->SetSendParameters(changed_params); | 898 kv.second->SetSendParameters(changed_params); |
| 858 } | 899 } |
| 859 if (changed_params.codec) { | 900 if (changed_params.codec) { |
| 860 // Update receive feedback parameters from new codec. | 901 // Update receive feedback parameters from new codec. |
| 861 LOG(LS_INFO) | 902 LOG(LS_INFO) |
| 862 << "SetFeedbackOptions on all the receive streams because the send " | 903 << "SetFeedbackOptions on all the receive streams because the send " |
| 863 "codec has changed."; | 904 "codec has changed."; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable | 1043 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable |
| 1003 << "options: " << (options ? options->ToString() : "nullptr") | 1044 << "options: " << (options ? options->ToString() : "nullptr") |
| 1004 << ")."; | 1045 << ")."; |
| 1005 | 1046 |
| 1006 // TODO(solenberg): The state change should be fully rolled back if any one of | 1047 // TODO(solenberg): The state change should be fully rolled back if any one of |
| 1007 // these calls fail. | 1048 // these calls fail. |
| 1008 if (!MuteStream(ssrc, !enable)) { | 1049 if (!MuteStream(ssrc, !enable)) { |
| 1009 return false; | 1050 return false; |
| 1010 } | 1051 } |
| 1011 if (enable && options) { | 1052 if (enable && options) { |
| 1053 // TODO(nisse): Rebase problem. |
| 1054 #if 0 |
| 1012 VideoSendParameters new_params = send_params_; | 1055 VideoSendParameters new_params = send_params_; |
| 1013 new_params.options.SetAll(*options); | 1056 new_params.options.SetAll(*options); |
| 1014 SetSendParameters(send_params_); | 1057 SetSendParameters(send_params_); |
| 1058 #else |
| 1059 return SetOptions(ssrc, *options); |
| 1060 #endif |
| 1015 } | 1061 } |
| 1016 return true; | 1062 return true; |
| 1017 } | 1063 } |
| 1018 | 1064 |
| 1019 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( | 1065 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( |
| 1020 const StreamParams& sp) const { | 1066 const StreamParams& sp) const { |
| 1021 for (uint32_t ssrc: sp.ssrcs) { | 1067 for (uint32_t ssrc: sp.ssrcs) { |
| 1022 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { | 1068 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { |
| 1023 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; | 1069 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; |
| 1024 return false; | 1070 return false; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1049 if (!ValidateSendSsrcAvailability(sp)) | 1095 if (!ValidateSendSsrcAvailability(sp)) |
| 1050 return false; | 1096 return false; |
| 1051 | 1097 |
| 1052 for (uint32_t used_ssrc : sp.ssrcs) | 1098 for (uint32_t used_ssrc : sp.ssrcs) |
| 1053 send_ssrcs_.insert(used_ssrc); | 1099 send_ssrcs_.insert(used_ssrc); |
| 1054 | 1100 |
| 1055 webrtc::VideoSendStream::Config config(this); | 1101 webrtc::VideoSendStream::Config config(this); |
| 1056 config.overuse_callback = this; | 1102 config.overuse_callback = this; |
| 1057 | 1103 |
| 1058 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( | 1104 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( |
| 1059 call_, sp, config, external_encoder_factory_, options_, | 1105 call_, sp, config, external_encoder_factory_, |
| 1060 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, | 1106 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, |
| 1061 send_params_); | 1107 send_params_); |
| 1062 | 1108 |
| 1063 uint32_t ssrc = sp.first_ssrc(); | 1109 uint32_t ssrc = sp.first_ssrc(); |
| 1064 RTC_DCHECK(ssrc != 0); | 1110 RTC_DCHECK(ssrc != 0); |
| 1065 send_streams_[ssrc] = stream; | 1111 send_streams_[ssrc] = stream; |
| 1066 | 1112 |
| 1067 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { | 1113 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { |
| 1068 rtcp_receiver_report_ssrc_ = ssrc; | 1114 rtcp_receiver_report_ssrc_ = ssrc; |
| 1069 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " | 1115 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 | 1225 |
| 1180 // Set up A/V sync group based on sync label. | 1226 // Set up A/V sync group based on sync label. |
| 1181 config.sync_group = sp.sync_label; | 1227 config.sync_group = sp.sync_label; |
| 1182 | 1228 |
| 1183 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; | 1229 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; |
| 1184 config.rtp.transport_cc = | 1230 config.rtp.transport_cc = |
| 1185 send_codec_ ? HasTransportCc(send_codec_->codec) : false; | 1231 send_codec_ ? HasTransportCc(send_codec_->codec) : false; |
| 1186 | 1232 |
| 1187 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( | 1233 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( |
| 1188 call_, sp, config, external_decoder_factory_, default_stream, | 1234 call_, sp, config, external_decoder_factory_, default_stream, |
| 1189 recv_codecs_, options_.disable_prerenderer_smoothing.value_or(false)); | 1235 recv_codecs_, disable_prerenderer_smoothing_); |
| 1190 | 1236 |
| 1191 return true; | 1237 return true; |
| 1192 } | 1238 } |
| 1193 | 1239 |
| 1194 void WebRtcVideoChannel2::ConfigureReceiverRtp( | 1240 void WebRtcVideoChannel2::ConfigureReceiverRtp( |
| 1195 webrtc::VideoReceiveStream::Config* config, | 1241 webrtc::VideoReceiveStream::Config* config, |
| 1196 const StreamParams& sp) const { | 1242 const StreamParams& sp) const { |
| 1197 uint32_t ssrc = sp.first_ssrc(); | 1243 uint32_t ssrc = sp.first_ssrc(); |
| 1198 | 1244 |
| 1199 config->rtp.remote_ssrc = ssrc; | 1245 config->rtp.remote_ssrc = ssrc; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 if (send_streams_.find(ssrc) == send_streams_.end()) { | 1491 if (send_streams_.find(ssrc) == send_streams_.end()) { |
| 1446 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; | 1492 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
| 1447 return false; | 1493 return false; |
| 1448 } | 1494 } |
| 1449 | 1495 |
| 1450 send_streams_[ssrc]->MuteStream(mute); | 1496 send_streams_[ssrc]->MuteStream(mute); |
| 1451 return true; | 1497 return true; |
| 1452 } | 1498 } |
| 1453 | 1499 |
| 1454 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. | 1500 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. |
| 1501 #if 0 |
| 1502 // TODO(nisse): Rebase leftover. |
| 1455 void WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { | 1503 void WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { |
| 1456 VideoSendParameters new_params = send_params_; | 1504 VideoSendParameters new_params = send_params_; |
| 1457 new_params.options.SetAll(options); | 1505 new_params.options.SetAll(options); |
| 1458 SetSendParameters(send_params_); | 1506 SetSendParameters(send_params_); |
| 1459 } | 1507 } |
| 1508 #endif |
| 1509 void WebRtcVideoChannel2::SetSharedOptions(const VideoOptions& options) { |
| 1510 { |
| 1511 rtc::CritScope lock(&capturer_crit_); |
| 1512 if (options.cpu_overuse_detection) |
| 1513 signal_cpu_adaptation_ = *options.cpu_overuse_detection; |
| 1514 } |
| 1515 if (options.disable_prerenderer_smoothing) |
| 1516 disable_prerenderer_smoothing_ = *options.disable_prerenderer_smoothing; |
| 1517 |
| 1518 if (options.dscp) { |
| 1519 rtc::DiffServCodePoint dscp = |
| 1520 *options.dscp ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; |
| 1521 MediaChannel::SetDscp(dscp); |
| 1522 } |
| 1523 } |
| 1524 |
| 1525 bool WebRtcVideoChannel2::SetOptions(uint32_t ssrc, |
| 1526 const VideoOptions& options) { |
| 1527 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); |
| 1528 LOG(LS_INFO) << "SetOptions: ssrc " << ssrc << ": " << options.ToString(); |
| 1529 SetSharedOptions(options); |
| 1530 |
| 1531 rtc::CritScope stream_lock(&stream_crit_); |
| 1532 if (send_streams_.find(ssrc) == send_streams_.end()) { |
| 1533 return false; |
| 1534 } |
| 1535 send_streams_[ssrc]->SetOptions(options); |
| 1536 |
| 1537 return true; |
| 1538 } |
| 1460 | 1539 |
| 1461 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { | 1540 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
| 1462 MediaChannel::SetInterface(iface); | 1541 MediaChannel::SetInterface(iface); |
| 1463 // Set the RTP recv/send buffer to a bigger size | 1542 // Set the RTP recv/send buffer to a bigger size |
| 1464 MediaChannel::SetOption(NetworkInterface::ST_RTP, | 1543 MediaChannel::SetOption(NetworkInterface::ST_RTP, |
| 1465 rtc::Socket::OPT_RCVBUF, | 1544 rtc::Socket::OPT_RCVBUF, |
| 1466 kVideoRtpBufferSize); | 1545 kVideoRtpBufferSize); |
| 1467 | 1546 |
| 1468 // Speculative change to increase the outbound socket buffer size. | 1547 // Speculative change to increase the outbound socket buffer size. |
| 1469 // In b/15152257, we are seeing a significant number of packets discarded | 1548 // In b/15152257, we are seeing a significant number of packets discarded |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 this->encoder = | 1637 this->encoder = |
| 1559 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); | 1638 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); |
| 1560 } | 1639 } |
| 1561 } | 1640 } |
| 1562 | 1641 |
| 1563 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( | 1642 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
| 1564 webrtc::Call* call, | 1643 webrtc::Call* call, |
| 1565 const StreamParams& sp, | 1644 const StreamParams& sp, |
| 1566 const webrtc::VideoSendStream::Config& config, | 1645 const webrtc::VideoSendStream::Config& config, |
| 1567 WebRtcVideoEncoderFactory* external_encoder_factory, | 1646 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 1568 const VideoOptions& options, | |
| 1569 int max_bitrate_bps, | 1647 int max_bitrate_bps, |
| 1570 const rtc::Optional<VideoCodecSettings>& codec_settings, | 1648 const rtc::Optional<VideoCodecSettings>& codec_settings, |
| 1571 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 1649 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
| 1572 // TODO(deadbeef): Don't duplicate information between send_params, | 1650 // TODO(deadbeef): Don't duplicate information between send_params, |
| 1573 // rtp_extensions, options, etc. | 1651 // rtp_extensions, options, etc. |
| 1574 const VideoSendParameters& send_params) | 1652 const VideoSendParameters& send_params) |
| 1575 : ssrcs_(sp.ssrcs), | 1653 : ssrcs_(sp.ssrcs), |
| 1576 ssrc_groups_(sp.ssrc_groups), | 1654 ssrc_groups_(sp.ssrc_groups), |
| 1577 call_(call), | 1655 call_(call), |
| 1578 external_encoder_factory_(external_encoder_factory), | 1656 external_encoder_factory_(external_encoder_factory), |
| 1579 stream_(NULL), | 1657 stream_(NULL), |
| 1580 parameters_(config, options, max_bitrate_bps, codec_settings), | 1658 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), |
| 1581 pending_encoder_reconfiguration_(false), | 1659 pending_encoder_reconfiguration_(false), |
| 1582 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), | 1660 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), |
| 1583 capturer_(NULL), | 1661 capturer_(NULL), |
| 1584 sending_(false), | 1662 sending_(false), |
| 1585 muted_(false), | 1663 muted_(false), |
| 1586 old_adapt_changes_(0), | 1664 old_adapt_changes_(0), |
| 1587 first_frame_timestamp_ms_(0), | 1665 first_frame_timestamp_ms_(0), |
| 1588 last_frame_timestamp_ms_(0) { | 1666 last_frame_timestamp_ms_(0) { |
| 1589 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1667 parameters_.config.rtp.max_packet_size = kVideoMtu; |
| 1590 | 1668 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 "payload type. Ignoring."; | 1939 "payload type. Ignoring."; |
| 1862 parameters_.config.rtp.rtx.ssrcs.clear(); | 1940 parameters_.config.rtp.rtx.ssrcs.clear(); |
| 1863 } else { | 1941 } else { |
| 1864 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1942 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
| 1865 } | 1943 } |
| 1866 } | 1944 } |
| 1867 | 1945 |
| 1868 parameters_.config.rtp.nack.rtp_history_ms = | 1946 parameters_.config.rtp.nack.rtp_history_ms = |
| 1869 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 1947 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; |
| 1870 | 1948 |
| 1871 RTC_CHECK(options.suspend_below_min_bitrate); | |
| 1872 parameters_.config.suspend_below_min_bitrate = | 1949 parameters_.config.suspend_below_min_bitrate = |
| 1873 *options.suspend_below_min_bitrate; | 1950 options.suspend_below_min_bitrate.value_or( |
| 1951 kDefault_suspend_below_min_bitrate); |
| 1874 | 1952 |
| 1875 parameters_.codec_settings = | 1953 parameters_.codec_settings = |
| 1876 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); | 1954 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); |
| 1877 parameters_.options = options; | 1955 parameters_.options = options; |
| 1878 | 1956 |
| 1879 LOG(LS_INFO) | 1957 LOG(LS_INFO) |
| 1880 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" | 1958 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" |
| 1881 << options.ToString(); | 1959 << options.ToString(); |
| 1882 RecreateWebRtcStream(); | 1960 RecreateWebRtcStream(); |
| 1883 if (allocated_encoder_.encoder != new_encoder.encoder) { | 1961 if (allocated_encoder_.encoder != new_encoder.encoder) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 RecreateWebRtcStream(); | 2007 RecreateWebRtcStream(); |
| 1930 } | 2008 } |
| 1931 } | 2009 } |
| 1932 | 2010 |
| 1933 webrtc::VideoEncoderConfig | 2011 webrtc::VideoEncoderConfig |
| 1934 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 2012 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
| 1935 const Dimensions& dimensions, | 2013 const Dimensions& dimensions, |
| 1936 const VideoCodec& codec) const { | 2014 const VideoCodec& codec) const { |
| 1937 webrtc::VideoEncoderConfig encoder_config; | 2015 webrtc::VideoEncoderConfig encoder_config; |
| 1938 if (dimensions.is_screencast) { | 2016 if (dimensions.is_screencast) { |
| 1939 RTC_CHECK(parameters_.options.screencast_min_bitrate_kbps); | |
| 1940 encoder_config.min_transmit_bitrate_bps = | 2017 encoder_config.min_transmit_bitrate_bps = |
| 1941 *parameters_.options.screencast_min_bitrate_kbps * 1000; | 2018 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or( |
| 2019 kDefault_screencast_min_bitrate_kbps); |
| 1942 encoder_config.content_type = | 2020 encoder_config.content_type = |
| 1943 webrtc::VideoEncoderConfig::ContentType::kScreen; | 2021 webrtc::VideoEncoderConfig::ContentType::kScreen; |
| 1944 } else { | 2022 } else { |
| 1945 encoder_config.min_transmit_bitrate_bps = 0; | 2023 encoder_config.min_transmit_bitrate_bps = 0; |
| 1946 encoder_config.content_type = | 2024 encoder_config.content_type = |
| 1947 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; | 2025 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; |
| 1948 } | 2026 } |
| 1949 | 2027 |
| 1950 // Restrict dimensions according to codec max. | 2028 // Restrict dimensions according to codec max. |
| 1951 int width = dimensions.width; | 2029 int width = dimensions.width; |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2683 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2606 } | 2684 } |
| 2607 } | 2685 } |
| 2608 | 2686 |
| 2609 return video_codecs; | 2687 return video_codecs; |
| 2610 } | 2688 } |
| 2611 | 2689 |
| 2612 } // namespace cricket | 2690 } // namespace cricket |
| 2613 | 2691 |
| 2614 #endif // HAVE_WEBRTC_VIDEO | 2692 #endif // HAVE_WEBRTC_VIDEO |
| OLD | NEW |