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; | |
pthatcher1
2016/01/28 19:13:28
Please make the style like kDefaultSuspendBelowMin
| |
60 const int kDefault_screencast_min_bitrate = 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 } | 616 } |
613 | 617 |
614 WebRtcVideoChannel2::WebRtcVideoChannel2( | 618 WebRtcVideoChannel2::WebRtcVideoChannel2( |
615 webrtc::Call* call, | 619 webrtc::Call* call, |
616 const VideoOptions& options, | 620 const VideoOptions& options, |
617 const std::vector<VideoCodec>& recv_codecs, | 621 const std::vector<VideoCodec>& recv_codecs, |
618 WebRtcVideoEncoderFactory* external_encoder_factory, | 622 WebRtcVideoEncoderFactory* external_encoder_factory, |
619 WebRtcVideoDecoderFactory* external_decoder_factory) | 623 WebRtcVideoDecoderFactory* external_decoder_factory) |
620 : call_(call), | 624 : call_(call), |
621 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 625 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
626 signal_cpu_adaptation_(true), | |
627 disable_prerenderer_smoothing_(false), | |
622 external_encoder_factory_(external_encoder_factory), | 628 external_encoder_factory_(external_encoder_factory), |
623 external_decoder_factory_(external_decoder_factory) { | 629 external_decoder_factory_(external_decoder_factory) { |
624 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 630 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
625 SetDefaultOptions(); | 631 |
626 options_.SetAll(options); | 632 SetSharedOptions(options); |
627 if (options_.cpu_overuse_detection) | 633 send_params_.options = options; |
628 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; | 634 |
629 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 635 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
630 sending_ = false; | 636 sending_ = false; |
631 default_send_ssrc_ = 0; | 637 default_send_ssrc_ = 0; |
632 SetRecvCodecs(recv_codecs); | 638 SetRecvCodecs(recv_codecs); |
633 } | 639 } |
634 | 640 |
635 void WebRtcVideoChannel2::SetDefaultOptions() { | |
636 options_.cpu_overuse_detection = rtc::Optional<bool>(true); | |
637 options_.dscp = rtc::Optional<bool>(false); | |
638 options_.suspend_below_min_bitrate = rtc::Optional<bool>(false); | |
639 options_.screencast_min_bitrate = rtc::Optional<int>(0); | |
640 } | |
641 | |
642 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 641 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
643 for (auto& kv : send_streams_) | 642 for (auto& kv : send_streams_) |
644 delete kv.second; | 643 delete kv.second; |
645 for (auto& kv : receive_streams_) | 644 for (auto& kv : receive_streams_) |
646 delete kv.second; | 645 delete kv.second; |
647 } | 646 } |
648 | 647 |
649 bool WebRtcVideoChannel2::CodecIsExternallySupported( | 648 bool WebRtcVideoChannel2::CodecIsExternallySupported( |
650 const std::string& name) const { | 649 const std::string& name) const { |
651 if (external_encoder_factory_ == NULL) { | 650 if (external_encoder_factory_ == NULL) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 return false; | 709 return false; |
711 } | 710 } |
712 | 711 |
713 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { | 712 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { |
714 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters"); | 713 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters"); |
715 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); | 714 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); |
716 // TODO(pbos): Refactor this to only recreate the send streams once | 715 // TODO(pbos): Refactor this to only recreate the send streams once |
717 // instead of 4 times. | 716 // instead of 4 times. |
718 if (!SetSendCodecs(params.codecs) || | 717 if (!SetSendCodecs(params.codecs) || |
719 !SetSendRtpHeaderExtensions(params.extensions) || | 718 !SetSendRtpHeaderExtensions(params.extensions) || |
720 !SetMaxSendBandwidth(params.max_bandwidth_bps) || | 719 !SetMaxSendBandwidth(params.max_bandwidth_bps)) { |
721 !SetOptions(params.options)) { | |
722 return false; | 720 return false; |
723 } | 721 } |
724 if (send_params_.rtcp.reduced_size != params.rtcp.reduced_size) { | 722 |
723 VideoOptions options = send_params_.options; | |
724 send_params_ = params; | |
725 | |
726 // Take care to keep old values of options, if the new params | |
727 // doesn't specify any value. | |
728 options.SetAll(params.options); | |
729 send_params_.options = options; | |
730 | |
731 SetSharedOptions(send_params_.options); | |
732 // Call each stream's SetSendParameters method. Leaves to the callee | |
733 // to check if there's any change. | |
734 { | |
725 rtc::CritScope stream_lock(&stream_crit_); | 735 rtc::CritScope stream_lock(&stream_crit_); |
726 for (auto& kv : send_streams_) { | 736 for (auto& kv : send_streams_) { |
727 kv.second->SetSendParameters(params); | 737 kv.second->SetSendParameters(params); |
728 } | 738 } |
729 } | 739 } |
730 send_params_ = params; | 740 |
731 return true; | 741 return true; |
732 } | 742 } |
733 | 743 |
734 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { | 744 bool WebRtcVideoChannel2::SetRecvParameters(const VideoRecvParameters& params) { |
735 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters"); | 745 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetRecvParameters"); |
736 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString(); | 746 LOG(LS_INFO) << "SetRecvParameters: " << params.ToString(); |
737 // TODO(pbos): Refactor this to only recreate the recv streams once | 747 // TODO(pbos): Refactor this to only recreate the recv streams once |
738 // instead of twice. | 748 // instead of twice. |
739 if (!SetRecvCodecs(params.codecs) || | 749 if (!SetRecvCodecs(params.codecs) || |
740 !SetRecvRtpHeaderExtensions(params.extensions)) { | 750 !SetRecvRtpHeaderExtensions(params.extensions)) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
916 } | 926 } |
917 | 927 |
918 bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable, | 928 bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable, |
919 const VideoOptions* options) { | 929 const VideoOptions* options) { |
920 // TODO(solenberg): The state change should be fully rolled back if any one of | 930 // TODO(solenberg): The state change should be fully rolled back if any one of |
921 // these calls fail. | 931 // these calls fail. |
922 if (!MuteStream(ssrc, !enable)) { | 932 if (!MuteStream(ssrc, !enable)) { |
923 return false; | 933 return false; |
924 } | 934 } |
925 if (enable && options) { | 935 if (enable && options) { |
926 return SetOptions(*options); | 936 return SetOptions(ssrc, *options); |
927 } else { | 937 } else { |
928 return true; | 938 return true; |
929 } | 939 } |
930 } | 940 } |
931 | 941 |
932 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( | 942 bool WebRtcVideoChannel2::ValidateSendSsrcAvailability( |
933 const StreamParams& sp) const { | 943 const StreamParams& sp) const { |
934 for (uint32_t ssrc: sp.ssrcs) { | 944 for (uint32_t ssrc: sp.ssrcs) { |
935 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { | 945 if (send_ssrcs_.find(ssrc) != send_ssrcs_.end()) { |
936 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; | 946 LOG(LS_ERROR) << "Send stream with SSRC '" << ssrc << "' already exists."; |
(...skipping 25 matching lines...) Expand all Loading... | |
962 if (!ValidateSendSsrcAvailability(sp)) | 972 if (!ValidateSendSsrcAvailability(sp)) |
963 return false; | 973 return false; |
964 | 974 |
965 for (uint32_t used_ssrc : sp.ssrcs) | 975 for (uint32_t used_ssrc : sp.ssrcs) |
966 send_ssrcs_.insert(used_ssrc); | 976 send_ssrcs_.insert(used_ssrc); |
967 | 977 |
968 webrtc::VideoSendStream::Config config(this); | 978 webrtc::VideoSendStream::Config config(this); |
969 config.overuse_callback = this; | 979 config.overuse_callback = this; |
970 | 980 |
971 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( | 981 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( |
972 call_, sp, config, external_encoder_factory_, options_, | 982 call_, sp, config, external_encoder_factory_, |
973 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, | 983 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, |
974 send_params_); | 984 send_params_); |
975 | 985 |
976 uint32_t ssrc = sp.first_ssrc(); | 986 uint32_t ssrc = sp.first_ssrc(); |
977 RTC_DCHECK(ssrc != 0); | 987 RTC_DCHECK(ssrc != 0); |
978 send_streams_[ssrc] = stream; | 988 send_streams_[ssrc] = stream; |
979 | 989 |
980 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { | 990 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { |
981 rtcp_receiver_report_ssrc_ = ssrc; | 991 rtcp_receiver_report_ssrc_ = ssrc; |
982 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " | 992 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... | |
1092 | 1102 |
1093 // Set up A/V sync group based on sync label. | 1103 // Set up A/V sync group based on sync label. |
1094 config.sync_group = sp.sync_label; | 1104 config.sync_group = sp.sync_label; |
1095 | 1105 |
1096 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; | 1106 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; |
1097 config.rtp.transport_cc = | 1107 config.rtp.transport_cc = |
1098 send_codec_ ? HasTransportCc(send_codec_->codec) : false; | 1108 send_codec_ ? HasTransportCc(send_codec_->codec) : false; |
1099 | 1109 |
1100 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( | 1110 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( |
1101 call_, sp, config, external_decoder_factory_, default_stream, | 1111 call_, sp, config, external_decoder_factory_, default_stream, |
1102 recv_codecs_, options_.disable_prerenderer_smoothing.value_or(false)); | 1112 recv_codecs_, disable_prerenderer_smoothing_); |
1103 | 1113 |
1104 return true; | 1114 return true; |
1105 } | 1115 } |
1106 | 1116 |
1107 void WebRtcVideoChannel2::ConfigureReceiverRtp( | 1117 void WebRtcVideoChannel2::ConfigureReceiverRtp( |
1108 webrtc::VideoReceiveStream::Config* config, | 1118 webrtc::VideoReceiveStream::Config* config, |
1109 const StreamParams& sp) const { | 1119 const StreamParams& sp) const { |
1110 uint32_t ssrc = sp.first_ssrc(); | 1120 uint32_t ssrc = sp.first_ssrc(); |
1111 | 1121 |
1112 config->rtp.remote_ssrc = ssrc; | 1122 config->rtp.remote_ssrc = ssrc; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1443 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { | 1453 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { |
1444 bitrate_config_.min_bitrate_bps = max_bitrate_bps; | 1454 bitrate_config_.min_bitrate_bps = max_bitrate_bps; |
1445 } | 1455 } |
1446 call_->SetBitrateConfig(bitrate_config_); | 1456 call_->SetBitrateConfig(bitrate_config_); |
1447 rtc::CritScope stream_lock(&stream_crit_); | 1457 rtc::CritScope stream_lock(&stream_crit_); |
1448 for (auto& kv : send_streams_) | 1458 for (auto& kv : send_streams_) |
1449 kv.second->SetMaxBitrateBps(max_bitrate_bps); | 1459 kv.second->SetMaxBitrateBps(max_bitrate_bps); |
1450 return true; | 1460 return true; |
1451 } | 1461 } |
1452 | 1462 |
1453 bool WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { | 1463 void WebRtcVideoChannel2::SetSharedOptions(const VideoOptions& options) { |
1454 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); | |
1455 LOG(LS_INFO) << "SetOptions: " << options.ToString(); | |
1456 VideoOptions old_options = options_; | |
1457 options_.SetAll(options); | |
1458 if (options_ == old_options) { | |
1459 // No new options to set. | |
1460 return true; | |
1461 } | |
1462 { | 1464 { |
1463 rtc::CritScope lock(&capturer_crit_); | 1465 rtc::CritScope lock(&capturer_crit_); |
1464 if (options_.cpu_overuse_detection) | 1466 if (options.cpu_overuse_detection) |
1465 signal_cpu_adaptation_ = *options_.cpu_overuse_detection; | 1467 signal_cpu_adaptation_ = *options.cpu_overuse_detection; |
1466 } | 1468 } |
1467 rtc::DiffServCodePoint dscp = | 1469 if (options.disable_prerenderer_smoothing) |
1468 options_.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; | 1470 disable_prerenderer_smoothing_ = *options.disable_prerenderer_smoothing; |
1469 MediaChannel::SetDscp(dscp); | 1471 |
1472 if (options.dscp) { | |
1473 rtc::DiffServCodePoint dscp = | |
1474 *options.dscp ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; | |
1475 MediaChannel::SetDscp(dscp); | |
1476 } | |
1477 } | |
1478 | |
1479 bool WebRtcVideoChannel2::SetOptions(uint32_t ssrc, | |
1480 const VideoOptions& options) { | |
1481 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); | |
1482 LOG(LS_INFO) << "SetOptions: ssrc " << ssrc << ": " << options.ToString(); | |
1483 SetSharedOptions(options); | |
pthatcher1
2016/01/28 19:13:28
Is this really necessary? I don't think it is.
| |
1484 | |
1470 rtc::CritScope stream_lock(&stream_crit_); | 1485 rtc::CritScope stream_lock(&stream_crit_); |
1471 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it = | 1486 if (send_streams_.find(ssrc) == send_streams_.end()) { |
1472 send_streams_.begin(); | 1487 return false; |
1473 it != send_streams_.end(); ++it) { | |
1474 it->second->SetOptions(options_); | |
1475 } | 1488 } |
1489 send_streams_[ssrc]->SetOptions(options); | |
pthatcher1
2016/01/28 19:13:28
You can avoid a double look up by doing this:
aut
nisse-webrtc
2016/02/15 08:14:20
Done. Changed all similar patterns in the file.
| |
1490 | |
1476 return true; | 1491 return true; |
1477 } | 1492 } |
1478 | 1493 |
1479 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { | 1494 void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
1480 MediaChannel::SetInterface(iface); | 1495 MediaChannel::SetInterface(iface); |
1481 // Set the RTP recv/send buffer to a bigger size | 1496 // Set the RTP recv/send buffer to a bigger size |
1482 MediaChannel::SetOption(NetworkInterface::ST_RTP, | 1497 MediaChannel::SetOption(NetworkInterface::ST_RTP, |
1483 rtc::Socket::OPT_RCVBUF, | 1498 rtc::Socket::OPT_RCVBUF, |
1484 kVideoRtpBufferSize); | 1499 kVideoRtpBufferSize); |
1485 | 1500 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1576 this->encoder = | 1591 this->encoder = |
1577 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); | 1592 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); |
1578 } | 1593 } |
1579 } | 1594 } |
1580 | 1595 |
1581 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( | 1596 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
1582 webrtc::Call* call, | 1597 webrtc::Call* call, |
1583 const StreamParams& sp, | 1598 const StreamParams& sp, |
1584 const webrtc::VideoSendStream::Config& config, | 1599 const webrtc::VideoSendStream::Config& config, |
1585 WebRtcVideoEncoderFactory* external_encoder_factory, | 1600 WebRtcVideoEncoderFactory* external_encoder_factory, |
1586 const VideoOptions& options, | |
1587 int max_bitrate_bps, | 1601 int max_bitrate_bps, |
1588 const rtc::Optional<VideoCodecSettings>& codec_settings, | 1602 const rtc::Optional<VideoCodecSettings>& codec_settings, |
1589 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 1603 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
1590 // TODO(deadbeef): Don't duplicate information between send_params, | 1604 // TODO(deadbeef): Don't duplicate information between send_params, |
1591 // rtp_extensions, options, etc. | 1605 // rtp_extensions, options, etc. |
1592 const VideoSendParameters& send_params) | 1606 const VideoSendParameters& send_params) |
1593 : ssrcs_(sp.ssrcs), | 1607 : ssrcs_(sp.ssrcs), |
1594 ssrc_groups_(sp.ssrc_groups), | 1608 ssrc_groups_(sp.ssrc_groups), |
1595 call_(call), | 1609 call_(call), |
1596 external_encoder_factory_(external_encoder_factory), | 1610 external_encoder_factory_(external_encoder_factory), |
1597 stream_(NULL), | 1611 stream_(NULL), |
1598 parameters_(config, options, max_bitrate_bps, codec_settings), | 1612 parameters_(config, send_params.options, max_bitrate_bps, codec_settings), |
1599 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), | 1613 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), |
1600 capturer_(NULL), | 1614 capturer_(NULL), |
1601 sending_(false), | 1615 sending_(false), |
1602 muted_(false), | 1616 muted_(false), |
1603 old_adapt_changes_(0), | 1617 old_adapt_changes_(0), |
1604 first_frame_timestamp_ms_(0), | 1618 first_frame_timestamp_ms_(0), |
1605 last_frame_timestamp_ms_(0) { | 1619 last_frame_timestamp_ms_(0) { |
1606 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1620 parameters_.config.rtp.max_packet_size = kVideoMtu; |
1607 | 1621 |
1608 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); | 1622 sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1785 bool apply_rotation) { | 1799 bool apply_rotation) { |
1786 rtc::CritScope cs(&lock_); | 1800 rtc::CritScope cs(&lock_); |
1787 if (capturer_ == NULL) | 1801 if (capturer_ == NULL) |
1788 return; | 1802 return; |
1789 | 1803 |
1790 capturer_->SetApplyRotation(apply_rotation); | 1804 capturer_->SetApplyRotation(apply_rotation); |
1791 } | 1805 } |
1792 | 1806 |
1793 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( | 1807 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( |
1794 const VideoOptions& options) { | 1808 const VideoOptions& options) { |
1809 | |
1795 rtc::CritScope cs(&lock_); | 1810 rtc::CritScope cs(&lock_); |
1796 if (parameters_.codec_settings) { | 1811 if (parameters_.codec_settings) { |
1797 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" | 1812 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" |
1798 << options.ToString(); | 1813 << options.ToString(); |
1799 SetCodecAndOptions(*parameters_.codec_settings, options); | 1814 SetCodecAndOptions(*parameters_.codec_settings, options); |
1800 } else { | 1815 } else { |
1801 parameters_.options = options; | 1816 parameters_.options = options; |
1802 } | 1817 } |
1803 } | 1818 } |
1804 | 1819 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1894 "payload type. Ignoring."; | 1909 "payload type. Ignoring."; |
1895 parameters_.config.rtp.rtx.ssrcs.clear(); | 1910 parameters_.config.rtp.rtx.ssrcs.clear(); |
1896 } else { | 1911 } else { |
1897 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1912 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
1898 } | 1913 } |
1899 } | 1914 } |
1900 | 1915 |
1901 parameters_.config.rtp.nack.rtp_history_ms = | 1916 parameters_.config.rtp.nack.rtp_history_ms = |
1902 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 1917 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; |
1903 | 1918 |
1904 RTC_CHECK(options.suspend_below_min_bitrate); | |
1905 parameters_.config.suspend_below_min_bitrate = | 1919 parameters_.config.suspend_below_min_bitrate = |
1906 *options.suspend_below_min_bitrate; | 1920 options.suspend_below_min_bitrate.value_or( |
1921 kDefault_suspend_below_min_bitrate); | |
1907 | 1922 |
1908 parameters_.codec_settings = | 1923 parameters_.codec_settings = |
1909 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); | 1924 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); |
1910 parameters_.options = options; | 1925 parameters_.options = options; |
1911 | 1926 |
1912 LOG(LS_INFO) | 1927 LOG(LS_INFO) |
1913 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" | 1928 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" |
1914 << options.ToString(); | 1929 << options.ToString(); |
1915 RecreateWebRtcStream(); | 1930 RecreateWebRtcStream(); |
1916 if (allocated_encoder_.encoder != new_encoder.encoder) { | 1931 if (allocated_encoder_.encoder != new_encoder.encoder) { |
1917 DestroyVideoEncoder(&allocated_encoder_); | 1932 DestroyVideoEncoder(&allocated_encoder_); |
1918 allocated_encoder_ = new_encoder; | 1933 allocated_encoder_ = new_encoder; |
1919 } | 1934 } |
1920 } | 1935 } |
1921 | 1936 |
1922 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions( | 1937 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions( |
1923 const std::vector<webrtc::RtpExtension>& rtp_extensions) { | 1938 const std::vector<webrtc::RtpExtension>& rtp_extensions) { |
1924 rtc::CritScope cs(&lock_); | 1939 rtc::CritScope cs(&lock_); |
1925 parameters_.config.rtp.extensions = rtp_extensions; | 1940 parameters_.config.rtp.extensions = rtp_extensions; |
1926 if (stream_ != nullptr) { | 1941 if (stream_ != nullptr) { |
1927 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions"; | 1942 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions"; |
1928 RecreateWebRtcStream(); | 1943 RecreateWebRtcStream(); |
1929 } | 1944 } |
1930 } | 1945 } |
1931 | 1946 |
1932 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( | 1947 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( |
1933 const VideoSendParameters& send_params) { | 1948 const VideoSendParameters& send_params) { |
1934 rtc::CritScope cs(&lock_); | 1949 rtc::CritScope cs(&lock_); |
1935 parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size | 1950 webrtc::RtcpMode mode = send_params.rtcp.reduced_size |
1936 ? webrtc::RtcpMode::kReducedSize | 1951 ? webrtc::RtcpMode::kReducedSize |
1937 : webrtc::RtcpMode::kCompound; | 1952 : webrtc::RtcpMode::kCompound; |
pthatcher1
2016/01/28 19:13:28
I'd call the variable "rtcp_mode".
| |
1938 if (stream_ != nullptr) { | 1953 |
1954 bool need_recreate = (mode != parameters_.config.rtp.rtcp_mode); | |
1955 | |
1956 parameters_.config.rtp.rtcp_mode = mode; | |
pthatcher1
2016/01/28 19:13:28
This might be more clear as:
bool need_recreate =
pbos-webrtc
2016/01/28 22:47:36
I think this code looks different at HEAD, I touch
| |
1957 | |
1958 VideoOptions old_options = parameters_.options; | |
1959 parameters_.options.SetAll(send_params.options); | |
1960 | |
1961 if (!(parameters_.options == old_options) && | |
1962 parameters_.codec_settings) { | |
1963 LOG(LS_INFO) << "SetCodecAndOptions because of SetSendParameters; options=" | |
1964 << send_params.options.ToString(); | |
1965 SetCodecAndOptions(*parameters_.codec_settings, send_params.options); | |
1966 // RecreateWebRtcStream already called | |
1967 need_recreate = false; | |
1968 } | |
1969 if (need_recreate && stream_ != nullptr) { | |
1939 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; | 1970 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetSendParameters"; |
1940 RecreateWebRtcStream(); | 1971 RecreateWebRtcStream(); |
1941 } | 1972 } |
1942 } | 1973 } |
1943 | 1974 |
1944 webrtc::VideoEncoderConfig | 1975 webrtc::VideoEncoderConfig |
1945 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 1976 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( |
1946 const Dimensions& dimensions, | 1977 const Dimensions& dimensions, |
1947 const VideoCodec& codec) const { | 1978 const VideoCodec& codec) const { |
1948 webrtc::VideoEncoderConfig encoder_config; | 1979 webrtc::VideoEncoderConfig encoder_config; |
1949 if (dimensions.is_screencast) { | 1980 if (dimensions.is_screencast) { |
1950 RTC_CHECK(parameters_.options.screencast_min_bitrate); | |
1951 encoder_config.min_transmit_bitrate_bps = | 1981 encoder_config.min_transmit_bitrate_bps = |
1952 *parameters_.options.screencast_min_bitrate * 1000; | 1982 1000 * parameters_.options.screencast_min_bitrate.value_or( |
1983 kDefault_screencast_min_bitrate); | |
1953 encoder_config.content_type = | 1984 encoder_config.content_type = |
1954 webrtc::VideoEncoderConfig::ContentType::kScreen; | 1985 webrtc::VideoEncoderConfig::ContentType::kScreen; |
1955 } else { | 1986 } else { |
1956 encoder_config.min_transmit_bitrate_bps = 0; | 1987 encoder_config.min_transmit_bitrate_bps = 0; |
1957 encoder_config.content_type = | 1988 encoder_config.content_type = |
1958 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; | 1989 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; |
1959 } | 1990 } |
1960 | 1991 |
1961 // Restrict dimensions according to codec max. | 1992 // Restrict dimensions according to codec max. |
1962 int width = dimensions.width; | 1993 int width = dimensions.width; |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2626 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2657 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2627 } | 2658 } |
2628 } | 2659 } |
2629 | 2660 |
2630 return video_codecs; | 2661 return video_codecs; |
2631 } | 2662 } |
2632 | 2663 |
2633 } // namespace cricket | 2664 } // namespace cricket |
2634 | 2665 |
2635 #endif // HAVE_WEBRTC_VIDEO | 2666 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |