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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 WebRtcVideoEncoderFactory* external_encoder_factory, | 609 WebRtcVideoEncoderFactory* external_encoder_factory, |
610 WebRtcVideoDecoderFactory* external_decoder_factory) | 610 WebRtcVideoDecoderFactory* external_decoder_factory) |
611 : VideoMediaChannel(config), | 611 : VideoMediaChannel(config), |
612 call_(call), | 612 call_(call), |
613 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 613 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
614 signal_cpu_adaptation_(config.enable_cpu_overuse_detection), | 614 signal_cpu_adaptation_(config.enable_cpu_overuse_detection), |
615 disable_prerenderer_smoothing_(config.disable_prerenderer_smoothing), | 615 disable_prerenderer_smoothing_(config.disable_prerenderer_smoothing), |
616 external_encoder_factory_(external_encoder_factory), | 616 external_encoder_factory_(external_encoder_factory), |
617 external_decoder_factory_(external_decoder_factory) { | 617 external_decoder_factory_(external_decoder_factory) { |
618 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 618 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
619 options_.SetAll(options); | 619 |
620 send_params_.options = options; | |
621 | |
620 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 622 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
621 sending_ = false; | 623 sending_ = false; |
622 default_send_ssrc_ = 0; | 624 default_send_ssrc_ = 0; |
623 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); | 625 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); |
624 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); | 626 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); |
625 } | 627 } |
626 | 628 |
627 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 629 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
628 for (auto& kv : send_streams_) | 630 for (auto& kv : send_streams_) |
629 delete kv.second; | 631 delete kv.second; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && | 731 if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps && |
730 params.max_bandwidth_bps >= 0) { | 732 params.max_bandwidth_bps >= 0) { |
731 // 0 uncaps max bitrate (-1). | 733 // 0 uncaps max bitrate (-1). |
732 changed_params->max_bandwidth_bps = rtc::Optional<int>( | 734 changed_params->max_bandwidth_bps = rtc::Optional<int>( |
733 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); | 735 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps); |
734 } | 736 } |
735 | 737 |
736 // Handle options. | 738 // Handle options. |
737 // TODO(pbos): Require VideoSendParameters to contain a full set of options | 739 // TODO(pbos): Require VideoSendParameters to contain a full set of options |
738 // and check if params.options != options_ instead of applying a delta. | 740 // and check if params.options != options_ instead of applying a delta. |
739 VideoOptions new_options = options_; | 741 VideoOptions new_options = send_params_.options; |
740 new_options.SetAll(params.options); | 742 new_options.SetAll(params.options); |
741 if (!(new_options == options_)) { | 743 if (!(new_options == send_params_.options)) { |
742 changed_params->options = rtc::Optional<VideoOptions>(new_options); | 744 changed_params->options = rtc::Optional<VideoOptions>(new_options); |
743 } | 745 } |
744 | 746 |
745 // Handle RTCP mode. | 747 // Handle RTCP mode. |
746 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { | 748 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { |
747 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( | 749 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( |
748 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize | 750 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize |
749 : webrtc::RtcpMode::kCompound); | 751 : webrtc::RtcpMode::kCompound); |
750 } | 752 } |
751 | 753 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 bitrate_config_.min_bitrate_bps = max_bitrate_bps; | 796 bitrate_config_.min_bitrate_bps = max_bitrate_bps; |
795 } | 797 } |
796 bitrate_config_changed = true; | 798 bitrate_config_changed = true; |
797 } | 799 } |
798 | 800 |
799 if (bitrate_config_changed) { | 801 if (bitrate_config_changed) { |
800 call_->SetBitrateConfig(bitrate_config_); | 802 call_->SetBitrateConfig(bitrate_config_); |
801 } | 803 } |
802 | 804 |
803 if (changed_params.options) | 805 if (changed_params.options) |
804 options_.SetAll(*changed_params.options); | 806 send_params_.options.SetAll(*changed_params.options); |
805 | 807 |
806 { | 808 { |
807 rtc::CritScope stream_lock(&stream_crit_); | 809 rtc::CritScope stream_lock(&stream_crit_); |
808 for (auto& kv : send_streams_) { | 810 for (auto& kv : send_streams_) { |
809 kv.second->SetSendParameters(changed_params); | 811 kv.second->SetSendParameters(changed_params); |
810 } | 812 } |
811 if (changed_params.codec) { | 813 if (changed_params.codec) { |
812 // Update receive feedback parameters from new codec. | 814 // Update receive feedback parameters from new codec. |
813 LOG(LS_INFO) | 815 LOG(LS_INFO) |
814 << "SetFeedbackOptions on all the receive streams because the send " | 816 << "SetFeedbackOptions on all the receive streams because the send " |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable | 945 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable |
944 << "options: " << (options ? options->ToString() : "nullptr") | 946 << "options: " << (options ? options->ToString() : "nullptr") |
945 << ")."; | 947 << ")."; |
946 | 948 |
947 // TODO(solenberg): The state change should be fully rolled back if any one of | 949 // TODO(solenberg): The state change should be fully rolled back if any one of |
948 // these calls fail. | 950 // these calls fail. |
949 if (!MuteStream(ssrc, !enable)) { | 951 if (!MuteStream(ssrc, !enable)) { |
950 return false; | 952 return false; |
951 } | 953 } |
952 if (enable && options) { | 954 if (enable && options) { |
953 VideoSendParameters new_params = send_params_; | 955 SetOptions(ssrc, *options); |
954 new_params.options.SetAll(*options); | |
955 SetSendParameters(send_params_); | |
956 } | 956 } |
957 return true; | 957 return true; |
958 } | 958 } |
959 | 959 |
960 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( | 960 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( |
961 const StreamParams& sp) const { | 961 const StreamParams& sp) const { |
962 for (uint32_t ssrc : sp.ssrcs) { | 962 for (uint32_t ssrc : sp.ssrcs) { |
963 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { | 963 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { |
964 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; | 964 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; |
965 return false; | 965 return false; |
(...skipping 23 matching lines...) Expand all Loading... | |
989 | 989 |
990 if (!ValidateSendSsrcAvailability(sp)) | 990 if (!ValidateSendSsrcAvailability(sp)) |
991 return false; | 991 return false; |
992 | 992 |
993 for (uint32_t used_ssrc : sp.ssrcs) | 993 for (uint32_t used_ssrc : sp.ssrcs) |
994 send_ssrcs_.insert(used_ssrc); | 994 send_ssrcs_.insert(used_ssrc); |
995 | 995 |
996 webrtc::VideoSendStream::Config config(this); | 996 webrtc::VideoSendStream::Config config(this); |
997 config.overuse_callback = this; | 997 config.overuse_callback = this; |
998 | 998 |
999 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( | 999 WebRtcVideoSendStream* stream = |
1000 call_, sp, config, external_encoder_factory_, options_, | 1000 new WebRtcVideoSendStream(call_, sp, config, external_encoder_factory_, |
1001 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, | 1001 bitrate_config_.max_bitrate_bps, send_codec_, |
1002 send_params_); | 1002 send_rtp_extensions_, send_params_); |
1003 | 1003 |
1004 uint32_t ssrc = sp.first_ssrc(); | 1004 uint32_t ssrc = sp.first_ssrc(); |
1005 RTC_DCHECK(ssrc != 0); | 1005 RTC_DCHECK(ssrc != 0); |
1006 send_streams_[ssrc] = stream; | 1006 send_streams_[ssrc] = stream; |
1007 | 1007 |
1008 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { | 1008 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { |
1009 rtcp_receiver_report_ssrc_ = ssrc; | 1009 rtcp_receiver_report_ssrc_ = ssrc; |
1010 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " | 1010 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " |
1011 "a send stream."; | 1011 "a send stream."; |
1012 for (auto& kv : receive_streams_) | 1012 for (auto& kv : receive_streams_) |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 } | 1261 } |
1262 video_media_info->bw_estimations.push_back(bwe_info); | 1262 video_media_info->bw_estimations.push_back(bwe_info); |
1263 } | 1263 } |
1264 | 1264 |
1265 bool WebRtcVideoChannel2::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { | 1265 bool WebRtcVideoChannel2::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { |
1266 LOG(LS_INFO) << "SetCapturer: " << ssrc << " -> " | 1266 LOG(LS_INFO) << "SetCapturer: " << ssrc << " -> " |
1267 << (capturer != NULL ? "(capturer)" : "NULL"); | 1267 << (capturer != NULL ? "(capturer)" : "NULL"); |
1268 RTC_DCHECK(ssrc != 0); | 1268 RTC_DCHECK(ssrc != 0); |
1269 { | 1269 { |
1270 rtc::CritScope stream_lock(&stream_crit_); | 1270 rtc::CritScope stream_lock(&stream_crit_); |
1271 if (send_streams_.find(ssrc) == send_streams_.end()) { | 1271 auto kv = send_streams_.find(ssrc); |
pbos-webrtc
2016/02/17 12:09:47
auto& kv
| |
1272 if (kv == send_streams_.end()) { | |
1272 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; | 1273 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
1273 return false; | 1274 return false; |
1274 } | 1275 } |
1275 if (!send_streams_[ssrc]->SetCapturer(capturer)) { | 1276 if (!kv->second->SetCapturer(capturer)) { |
1276 return false; | 1277 return false; |
1277 } | 1278 } |
1278 } | 1279 } |
1279 { | 1280 { |
1280 rtc::CritScope lock(&capturer_crit_); | 1281 rtc::CritScope lock(&capturer_crit_); |
1281 capturers_[ssrc] = capturer; | 1282 capturers_[ssrc] = capturer; |
1282 } | 1283 } |
1283 return true; | 1284 return true; |
1284 } | 1285 } |
1285 | 1286 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1359 void WebRtcVideoChannel2::OnReadyToSend(bool ready) { | 1360 void WebRtcVideoChannel2::OnReadyToSend(bool ready) { |
1360 LOG(LS_VERBOSE) << "OnReadyToSend: " << (ready ? "Ready." : "Not ready."); | 1361 LOG(LS_VERBOSE) << "OnReadyToSend: " << (ready ? "Ready." : "Not ready."); |
1361 call_->SignalNetworkState(ready ? webrtc::kNetworkUp : webrtc::kNetworkDown); | 1362 call_->SignalNetworkState(ready ? webrtc::kNetworkUp : webrtc::kNetworkDown); |
1362 } | 1363 } |
1363 | 1364 |
1364 bool WebRtcVideoChannel2::MuteStream(uint32_t ssrc, bool mute) { | 1365 bool WebRtcVideoChannel2::MuteStream(uint32_t ssrc, bool mute) { |
1365 LOG(LS_VERBOSE) << "MuteStream: " << ssrc << " -> " | 1366 LOG(LS_VERBOSE) << "MuteStream: " << ssrc << " -> " |
1366 << (mute ? "mute" : "unmute"); | 1367 << (mute ? "mute" : "unmute"); |
1367 RTC_DCHECK(ssrc != 0); | 1368 RTC_DCHECK(ssrc != 0); |
1368 rtc::CritScope stream_lock(&stream_crit_); | 1369 rtc::CritScope stream_lock(&stream_crit_); |
1369 if (send_streams_.find(ssrc) == send_streams_.end()) { | 1370 auto kv = send_streams_.find(ssrc); |
pbos-webrtc
2016/02/17 12:09:47
auto& kv
nisse-webrtc
2016/02/17 12:27:49
Done. const auto& was needed to make the compiler
| |
1371 if (kv == send_streams_.end()) { | |
1370 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; | 1372 LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
1371 return false; | 1373 return false; |
1372 } | 1374 } |
1373 | 1375 |
1374 send_streams_[ssrc]->MuteStream(mute); | 1376 kv->second->MuteStream(mute); |
1375 return true; | 1377 return true; |
1376 } | 1378 } |
1377 | 1379 |
1378 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. | 1380 // TODO(pbos): Remove SetOptions in favor of SetSendParameters. |
1379 void WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { | 1381 void WebRtcVideoChannel2::SetOptions(uint32_t ssrc, |
1380 VideoSendParameters new_params = send_params_; | 1382 const VideoOptions& options) { |
1381 new_params.options.SetAll(options); | 1383 LOG(LS_INFO) << "SetOptions: ssrc " << ssrc << ": " << options.ToString(); |
1382 SetSendParameters(send_params_); | 1384 |
1385 rtc::CritScope stream_lock(&stream_crit_); | |
1386 auto kv = send_streams_.find(ssrc); | |
pbos-webrtc
2016/02/17 12:09:47
auto& kv
| |
1387 if (kv == send_streams_.end()) { | |
1388 return; | |
1389 } | |
1390 kv->second->SetOptions(options); | |
1383 } | 1391 } |
1384 | 1392 |
1385 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { | 1393 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
1386 MediaChannel::SetInterface(iface); | 1394 MediaChannel::SetInterface(iface); |
1387 // Set the RTP recv/send buffer to a bigger size | 1395 // Set the RTP recv/send buffer to a bigger size |
1388 MediaChannel::SetOption(NetworkInterface::ST_RTP, | 1396 MediaChannel::SetOption(NetworkInterface::ST_RTP, |
1389 rtc::Socket::OPT_RCVBUF, | 1397 rtc::Socket::OPT_RCVBUF, |
1390 kVideoRtpBufferSize); | 1398 kVideoRtpBufferSize); |
1391 | 1399 |
1392 // Speculative change to increase the outbound socket buffer size. | 1400 // Speculative change to increase the outbound socket buffer size. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1474 this->encoder = | 1482 this->encoder = |
1475 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); | 1483 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); |
1476 } | 1484 } |
1477 } | 1485 } |
1478 | 1486 |
1479 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( | 1487 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
1480 webrtc::Call* call, | 1488 webrtc::Call* call, |
1481 const StreamParams& sp, | 1489 const StreamParams& sp, |
1482 const webrtc::VideoSendStream::Config& config, | 1490 const webrtc::VideoSendStream::Config& config, |
1483 WebRtcVideoEncoderFactory* external_encoder_factory, | 1491 WebRtcVideoEncoderFactory* external_encoder_factory, |
1484 const VideoOptions& options, | |
1485 int max_bitrate_bps, | 1492 int max_bitrate_bps, |
1486 const rtc::Optional<VideoCodecSettings>& codec_settings, | 1493 const rtc::Optional<VideoCodecSettings>& codec_settings, |
1487 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 1494 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
1488 // TODO(deadbeef): Don't duplicate information between send_params, | 1495 // TODO(deadbeef): Don't duplicate information between send_params, |
1489 // rtp_extensions, options, etc. | 1496 // rtp_extensions, options, etc. |
1490 const VideoSendParameters& send_params) | 1497 const VideoSendParameters& send_params) |
1491 : ssrcs_(sp.ssrcs), | 1498 : ssrcs_(sp.ssrcs), |
1492 ssrc_groups_(sp.ssrc_groups), | 1499 ssrc_groups_(sp.ssrc_groups), |
1493 call_(call), | 1500 call_(call), |
1494 external_encoder_factory_(external_encoder_factory), | 1501 external_encoder_factory_(external_encoder_factory), |
1495 stream_(NULL), | 1502 stream_(NULL), |
1496 parameters_(config, options, max_bitrate_bps, codec_settings), | 1503 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), |
1497 pending_encoder_reconfiguration_(false), | 1504 pending_encoder_reconfiguration_(false), |
1498 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), | 1505 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), |
1499 capturer_(NULL), | 1506 capturer_(NULL), |
1500 sending_(false), | 1507 sending_(false), |
1501 muted_(false), | 1508 muted_(false), |
1502 old_adapt_changes_(0), | 1509 old_adapt_changes_(0), |
1503 first_frame_timestamp_ms_(0), | 1510 first_frame_timestamp_ms_(0), |
1504 last_frame_timestamp_ms_(0) { | 1511 last_frame_timestamp_ms_(0) { |
1505 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1512 parameters_.config.rtp.max_packet_size = kVideoMtu; |
1506 | 1513 |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2483 rtx_mapping[video_codecs[i].codec.id] != | 2490 rtx_mapping[video_codecs[i].codec.id] != |
2484 fec_settings.red_payload_type) { | 2491 fec_settings.red_payload_type) { |
2485 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2492 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2486 } | 2493 } |
2487 } | 2494 } |
2488 | 2495 |
2489 return video_codecs; | 2496 return video_codecs; |
2490 } | 2497 } |
2491 | 2498 |
2492 } // namespace cricket | 2499 } // namespace cricket |
OLD | NEW |