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 25 matching lines...) Expand all Loading... | |
36 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 36 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
37 #include "webrtc/media/engine/webrtcvoiceengine.h" | 37 #include "webrtc/media/engine/webrtcvoiceengine.h" |
38 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" | 38 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" |
39 #include "webrtc/system_wrappers/include/field_trial.h" | 39 #include "webrtc/system_wrappers/include/field_trial.h" |
40 | 40 |
41 using DegradationPreference = webrtc::VideoSendStream::DegradationPreference; | 41 using DegradationPreference = webrtc::VideoSendStream::DegradationPreference; |
42 | 42 |
43 namespace cricket { | 43 namespace cricket { |
44 namespace { | 44 namespace { |
45 // If this field trial is enabled, we will enable sending FlexFEC and disable | 45 // If this field trial is enabled, we will enable sending FlexFEC and disable |
46 // sending ULPFEC whenever the former has been negotiated. | 46 // sending ULPFEC whenever the former has been negotiated in the SDPs. |
47 // FlexFEC can only be negotiated when the "flexfec-03" SDP codec is enabled, | |
48 // which is done by enabling the "WebRTC-FlexFEC-03-Advertised" field trial; see | |
49 // internalencoderfactory.cc. | |
50 bool IsFlexfecFieldTrialEnabled() { | 47 bool IsFlexfecFieldTrialEnabled() { |
51 return webrtc::field_trial::IsEnabled("WebRTC-FlexFEC-03"); | 48 return webrtc::field_trial::IsEnabled("WebRTC-FlexFEC-03"); |
52 } | 49 } |
53 | 50 |
51 // If this field trial is enabled, the "flexfec-03" codec may have been | |
52 // advertised as being supported in the local SDP. That means that we must be | |
53 // ready to receive FlexFEC packets. See internalencoderfactory.cc. | |
54 bool IsFlexfecAdvertisedFieldTrialEnabled() { | |
55 return webrtc::field_trial::IsEnabled("WebRTC-FlexFEC-03-Advertised"); | |
56 } | |
57 | |
54 // If this field trial is enabled, we will report VideoContentType RTP extension | 58 // If this field trial is enabled, we will report VideoContentType RTP extension |
55 // in capabilities (thus, it will end up in the default SDP and extension will | 59 // in capabilities (thus, it will end up in the default SDP and extension will |
56 // be sent for all key-frames). | 60 // be sent for all key-frames). |
57 bool IsVideoContentTypeExtensionFieldTrialEnabled() { | 61 bool IsVideoContentTypeExtensionFieldTrialEnabled() { |
58 return webrtc::field_trial::IsEnabled("WebRTC-VideoContentTypeExtension"); | 62 return webrtc::field_trial::IsEnabled("WebRTC-VideoContentTypeExtension"); |
59 } | 63 } |
60 | 64 |
61 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. | 65 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. |
62 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { | 66 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { |
63 public: | 67 public: |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 const VideoOptions& options, | 640 const VideoOptions& options, |
637 WebRtcVideoEncoderFactory* external_encoder_factory, | 641 WebRtcVideoEncoderFactory* external_encoder_factory, |
638 WebRtcVideoDecoderFactory* external_decoder_factory) | 642 WebRtcVideoDecoderFactory* external_decoder_factory) |
639 : VideoMediaChannel(config), | 643 : VideoMediaChannel(config), |
640 call_(call), | 644 call_(call), |
641 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 645 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
642 video_config_(config.video), | 646 video_config_(config.video), |
643 external_encoder_factory_(external_encoder_factory), | 647 external_encoder_factory_(external_encoder_factory), |
644 external_decoder_factory_(external_decoder_factory), | 648 external_decoder_factory_(external_decoder_factory), |
645 default_send_options_(options), | 649 default_send_options_(options), |
646 last_stats_log_ms_(-1) { | 650 last_stats_log_ms_(-1), |
651 map_flexfec_recv_(IsFlexfecAdvertisedFieldTrialEnabled()), | |
652 map_flexfec_send_(IsFlexfecFieldTrialEnabled()) { | |
647 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 653 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
648 | 654 |
649 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 655 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
650 sending_ = false; | 656 sending_ = false; |
651 recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory)); | 657 recv_codecs_ = MapCodecs(GetSupportedCodecs(external_encoder_factory), |
658 map_flexfec_recv_); | |
652 } | 659 } |
653 | 660 |
654 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 661 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
655 for (auto& kv : send_streams_) | 662 for (auto& kv : send_streams_) |
656 delete kv.second; | 663 delete kv.second; |
657 for (auto& kv : receive_streams_) | 664 for (auto& kv : receive_streams_) |
658 delete kv.second; | 665 delete kv.second; |
659 } | 666 } |
660 | 667 |
661 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings> | 668 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 bool WebRtcVideoChannel2::GetChangedSendParameters( | 710 bool WebRtcVideoChannel2::GetChangedSendParameters( |
704 const VideoSendParameters& params, | 711 const VideoSendParameters& params, |
705 ChangedSendParameters* changed_params) const { | 712 ChangedSendParameters* changed_params) const { |
706 if (!ValidateCodecFormats(params.codecs) || | 713 if (!ValidateCodecFormats(params.codecs) || |
707 !ValidateRtpExtensions(params.extensions)) { | 714 !ValidateRtpExtensions(params.extensions)) { |
708 return false; | 715 return false; |
709 } | 716 } |
710 | 717 |
711 // Select one of the remote codecs that will be used as send codec. | 718 // Select one of the remote codecs that will be used as send codec. |
712 const rtc::Optional<VideoCodecSettings> selected_send_codec = | 719 const rtc::Optional<VideoCodecSettings> selected_send_codec = |
713 SelectSendVideoCodec(MapCodecs(params.codecs)); | 720 SelectSendVideoCodec(MapCodecs(params.codecs, map_flexfec_send_)); |
714 | 721 |
715 if (!selected_send_codec) { | 722 if (!selected_send_codec) { |
716 LOG(LS_ERROR) << "No video codecs supported."; | 723 LOG(LS_ERROR) << "No video codecs supported."; |
717 return false; | 724 return false; |
718 } | 725 } |
719 | 726 |
720 if (!send_codec_ || *selected_send_codec != *send_codec_) | 727 if (!send_codec_ || *selected_send_codec != *send_codec_) |
721 changed_params->codec = selected_send_codec; | 728 changed_params->codec = selected_send_codec; |
722 | 729 |
723 // Handle RTP header extensions. | 730 // Handle RTP header extensions. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 bool WebRtcVideoChannel2::GetChangedRecvParameters( | 951 bool WebRtcVideoChannel2::GetChangedRecvParameters( |
945 const VideoRecvParameters& params, | 952 const VideoRecvParameters& params, |
946 ChangedRecvParameters* changed_params) const { | 953 ChangedRecvParameters* changed_params) const { |
947 if (!ValidateCodecFormats(params.codecs) || | 954 if (!ValidateCodecFormats(params.codecs) || |
948 !ValidateRtpExtensions(params.extensions)) { | 955 !ValidateRtpExtensions(params.extensions)) { |
949 return false; | 956 return false; |
950 } | 957 } |
951 | 958 |
952 // Handle receive codecs. | 959 // Handle receive codecs. |
953 const std::vector<VideoCodecSettings> mapped_codecs = | 960 const std::vector<VideoCodecSettings> mapped_codecs = |
954 MapCodecs(params.codecs); | 961 MapCodecs(params.codecs, map_flexfec_recv_); |
955 if (mapped_codecs.empty()) { | 962 if (mapped_codecs.empty()) { |
956 LOG(LS_ERROR) << "SetRecvParameters called without any video codecs."; | 963 LOG(LS_ERROR) << "SetRecvParameters called without any video codecs."; |
957 return false; | 964 return false; |
958 } | 965 } |
959 | 966 |
960 // Verify that every mapped codec is supported locally. | 967 // Verify that every mapped codec is supported locally. |
961 const std::vector<VideoCodec> local_supported_codecs = | 968 const std::vector<VideoCodec> local_supported_codecs = |
962 GetSupportedCodecs(external_encoder_factory_); | 969 GetSupportedCodecs(external_encoder_factory_); |
963 for (const VideoCodecSettings& mapped_codec : mapped_codecs) { | 970 for (const VideoCodecSettings& mapped_codec : mapped_codecs) { |
964 if (!FindMatchingCodec(local_supported_codecs, mapped_codec.codec)) { | 971 if (!FindMatchingCodec(local_supported_codecs, mapped_codec.codec)) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1114 send_ssrcs_.insert(used_ssrc); | 1121 send_ssrcs_.insert(used_ssrc); |
1115 | 1122 |
1116 webrtc::VideoSendStream::Config config(this); | 1123 webrtc::VideoSendStream::Config config(this); |
1117 config.suspend_below_min_bitrate = video_config_.suspend_below_min_bitrate; | 1124 config.suspend_below_min_bitrate = video_config_.suspend_below_min_bitrate; |
1118 config.periodic_alr_bandwidth_probing = | 1125 config.periodic_alr_bandwidth_probing = |
1119 video_config_.periodic_alr_bandwidth_probing; | 1126 video_config_.periodic_alr_bandwidth_probing; |
1120 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( | 1127 WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( |
1121 call_, sp, std::move(config), default_send_options_, | 1128 call_, sp, std::move(config), default_send_options_, |
1122 external_encoder_factory_, video_config_.enable_cpu_overuse_detection, | 1129 external_encoder_factory_, video_config_.enable_cpu_overuse_detection, |
1123 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, | 1130 bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, |
1124 send_params_); | 1131 send_params_, map_flexfec_send_); |
1125 | 1132 |
1126 uint32_t ssrc = sp.first_ssrc(); | 1133 uint32_t ssrc = sp.first_ssrc(); |
1127 RTC_DCHECK(ssrc != 0); | 1134 RTC_DCHECK(ssrc != 0); |
1128 send_streams_[ssrc] = stream; | 1135 send_streams_[ssrc] = stream; |
1129 | 1136 |
1130 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { | 1137 if (rtcp_receiver_report_ssrc_ == kDefaultRtcpReceiverReportSsrc) { |
1131 rtcp_receiver_report_ssrc_ = ssrc; | 1138 rtcp_receiver_report_ssrc_ = ssrc; |
1132 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " | 1139 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " |
1133 "a send stream."; | 1140 "a send stream."; |
1134 for (auto& kv : receive_streams_) | 1141 for (auto& kv : receive_streams_) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1267 | 1274 |
1268 config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; | 1275 config->rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; |
1269 config->rtp.transport_cc = | 1276 config->rtp.transport_cc = |
1270 send_codec_ ? HasTransportCc(send_codec_->codec) : false; | 1277 send_codec_ ? HasTransportCc(send_codec_->codec) : false; |
1271 | 1278 |
1272 sp.GetFidSsrc(ssrc, &config->rtp.rtx_ssrc); | 1279 sp.GetFidSsrc(ssrc, &config->rtp.rtx_ssrc); |
1273 | 1280 |
1274 config->rtp.extensions = recv_rtp_extensions_; | 1281 config->rtp.extensions = recv_rtp_extensions_; |
1275 | 1282 |
1276 // TODO(brandtr): Generalize when we add support for multistream protection. | 1283 // TODO(brandtr): Generalize when we add support for multistream protection. |
1277 if (sp.GetFecFrSsrc(ssrc, &flexfec_config->remote_ssrc)) { | 1284 if (map_flexfec_recv_ && |
1285 sp.GetFecFrSsrc(ssrc, &flexfec_config->remote_ssrc)) { | |
1278 flexfec_config->protected_media_ssrcs = {ssrc}; | 1286 flexfec_config->protected_media_ssrcs = {ssrc}; |
1279 flexfec_config->local_ssrc = config->rtp.local_ssrc; | 1287 flexfec_config->local_ssrc = config->rtp.local_ssrc; |
1280 flexfec_config->rtcp_mode = config->rtp.rtcp_mode; | 1288 flexfec_config->rtcp_mode = config->rtp.rtcp_mode; |
1281 // TODO(brandtr): We should be spec-compliant and set |transport_cc| here | 1289 // TODO(brandtr): We should be spec-compliant and set |transport_cc| here |
1282 // based on the rtcp-fb for the FlexFEC codec, not the media codec. | 1290 // based on the rtcp-fb for the FlexFEC codec, not the media codec. |
1283 flexfec_config->transport_cc = config->rtp.transport_cc; | 1291 flexfec_config->transport_cc = config->rtp.transport_cc; |
1284 flexfec_config->rtp_header_extensions = config->rtp.extensions; | 1292 flexfec_config->rtp_header_extensions = config->rtp.extensions; |
1285 } | 1293 } |
1286 } | 1294 } |
1287 | 1295 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1565 const StreamParams& sp, | 1573 const StreamParams& sp, |
1566 webrtc::VideoSendStream::Config config, | 1574 webrtc::VideoSendStream::Config config, |
1567 const VideoOptions& options, | 1575 const VideoOptions& options, |
1568 WebRtcVideoEncoderFactory* external_encoder_factory, | 1576 WebRtcVideoEncoderFactory* external_encoder_factory, |
1569 bool enable_cpu_overuse_detection, | 1577 bool enable_cpu_overuse_detection, |
1570 int max_bitrate_bps, | 1578 int max_bitrate_bps, |
1571 const rtc::Optional<VideoCodecSettings>& codec_settings, | 1579 const rtc::Optional<VideoCodecSettings>& codec_settings, |
1572 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, | 1580 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, |
1573 // TODO(deadbeef): Don't duplicate information between send_params, | 1581 // TODO(deadbeef): Don't duplicate information between send_params, |
1574 // rtp_extensions, options, etc. | 1582 // rtp_extensions, options, etc. |
1575 const VideoSendParameters& send_params) | 1583 const VideoSendParameters& send_params, |
1584 bool map_flexfec_send) | |
1576 : worker_thread_(rtc::Thread::Current()), | 1585 : worker_thread_(rtc::Thread::Current()), |
1577 ssrcs_(sp.ssrcs), | 1586 ssrcs_(sp.ssrcs), |
1578 ssrc_groups_(sp.ssrc_groups), | 1587 ssrc_groups_(sp.ssrc_groups), |
1579 call_(call), | 1588 call_(call), |
1580 enable_cpu_overuse_detection_(enable_cpu_overuse_detection), | 1589 enable_cpu_overuse_detection_(enable_cpu_overuse_detection), |
1581 source_(nullptr), | 1590 source_(nullptr), |
1582 external_encoder_factory_(external_encoder_factory), | 1591 external_encoder_factory_(external_encoder_factory), |
1583 internal_encoder_factory_(new InternalEncoderFactory()), | 1592 internal_encoder_factory_(new InternalEncoderFactory()), |
1584 stream_(nullptr), | 1593 stream_(nullptr), |
1585 encoder_sink_(nullptr), | 1594 encoder_sink_(nullptr), |
(...skipping 11 matching lines...) Expand all Loading... | |
1597 rtp_parameters_.encodings[0].ssrc = | 1606 rtp_parameters_.encodings[0].ssrc = |
1598 rtc::Optional<uint32_t>(parameters_.config.rtp.ssrcs[0]); | 1607 rtc::Optional<uint32_t>(parameters_.config.rtp.ssrcs[0]); |
1599 | 1608 |
1600 // RTX. | 1609 // RTX. |
1601 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1610 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1602 ¶meters_.config.rtp.rtx.ssrcs); | 1611 ¶meters_.config.rtp.rtx.ssrcs); |
1603 | 1612 |
1604 // FlexFEC SSRCs. | 1613 // FlexFEC SSRCs. |
1605 // TODO(brandtr): This code needs to be generalized when we add support for | 1614 // TODO(brandtr): This code needs to be generalized when we add support for |
1606 // multistream protection. | 1615 // multistream protection. |
1607 if (IsFlexfecFieldTrialEnabled()) { | 1616 if (map_flexfec_send) { |
perkj_webrtc
2017/05/12 12:05:05
rename variable or keep function call. is_flexfec_
brandtr
2017/05/15 12:24:13
Kept function call.
| |
1608 uint32_t flexfec_ssrc; | 1617 uint32_t flexfec_ssrc; |
1609 bool flexfec_enabled = false; | 1618 bool flexfec_enabled = false; |
1610 for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) { | 1619 for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) { |
1611 if (sp.GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)) { | 1620 if (sp.GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)) { |
1612 if (flexfec_enabled) { | 1621 if (flexfec_enabled) { |
1613 LOG(LS_INFO) << "Multiple FlexFEC streams proposed by remote, but " | 1622 LOG(LS_INFO) << "Multiple FlexFEC streams in local SDP, but " |
1614 "our implementation only supports a single FlexFEC " | 1623 "our implementation only supports a single FlexFEC " |
1615 "stream. Will not enable FlexFEC for proposed " | 1624 "stream. Will not enable FlexFEC for proposed " |
1616 "stream with SSRC: " | 1625 "stream with SSRC: " |
1617 << flexfec_ssrc << "."; | 1626 << flexfec_ssrc << "."; |
1618 continue; | 1627 continue; |
1619 } | 1628 } |
1620 | 1629 |
1621 flexfec_enabled = true; | 1630 flexfec_enabled = true; |
1622 parameters_.config.rtp.flexfec.ssrc = flexfec_ssrc; | 1631 parameters_.config.rtp.flexfec.ssrc = flexfec_ssrc; |
1623 parameters_.config.rtp.flexfec.protected_media_ssrcs = {primary_ssrc}; | 1632 parameters_.config.rtp.flexfec.protected_media_ssrcs = {primary_ssrc}; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1778 if (new_encoder.external) { | 1787 if (new_encoder.external) { |
1779 webrtc::VideoCodecType type = | 1788 webrtc::VideoCodecType type = |
1780 webrtc::PayloadNameToCodecType(codec_settings.codec.name) | 1789 webrtc::PayloadNameToCodecType(codec_settings.codec.name) |
1781 .value_or(webrtc::kVideoCodecUnknown); | 1790 .value_or(webrtc::kVideoCodecUnknown); |
1782 parameters_.config.encoder_settings.internal_source = | 1791 parameters_.config.encoder_settings.internal_source = |
1783 external_encoder_factory_->EncoderTypeHasInternalSource(type); | 1792 external_encoder_factory_->EncoderTypeHasInternalSource(type); |
1784 } else { | 1793 } else { |
1785 parameters_.config.encoder_settings.internal_source = false; | 1794 parameters_.config.encoder_settings.internal_source = false; |
1786 } | 1795 } |
1787 parameters_.config.rtp.ulpfec = codec_settings.ulpfec; | 1796 parameters_.config.rtp.ulpfec = codec_settings.ulpfec; |
1788 if (IsFlexfecFieldTrialEnabled()) { | 1797 parameters_.config.rtp.flexfec.payload_type = |
1789 parameters_.config.rtp.flexfec.payload_type = | 1798 codec_settings.flexfec_payload_type; |
1790 codec_settings.flexfec_payload_type; | |
1791 } | |
1792 | 1799 |
1793 // Set RTX payload type if RTX is enabled. | 1800 // Set RTX payload type if RTX is enabled. |
1794 if (!parameters_.config.rtp.rtx.ssrcs.empty()) { | 1801 if (!parameters_.config.rtp.rtx.ssrcs.empty()) { |
1795 if (codec_settings.rtx_payload_type == -1) { | 1802 if (codec_settings.rtx_payload_type == -1) { |
1796 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 1803 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
1797 "payload type. Ignoring."; | 1804 "payload type. Ignoring."; |
1798 parameters_.config.rtp.rtx.ssrcs.clear(); | 1805 parameters_.config.rtp.rtx.ssrcs.clear(); |
1799 } else { | 1806 } else { |
1800 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1807 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
1801 } | 1808 } |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2495 flexfec_payload_type == other.flexfec_payload_type && | 2502 flexfec_payload_type == other.flexfec_payload_type && |
2496 rtx_payload_type == other.rtx_payload_type; | 2503 rtx_payload_type == other.rtx_payload_type; |
2497 } | 2504 } |
2498 | 2505 |
2499 bool WebRtcVideoChannel2::VideoCodecSettings::operator!=( | 2506 bool WebRtcVideoChannel2::VideoCodecSettings::operator!=( |
2500 const WebRtcVideoChannel2::VideoCodecSettings& other) const { | 2507 const WebRtcVideoChannel2::VideoCodecSettings& other) const { |
2501 return !(*this == other); | 2508 return !(*this == other); |
2502 } | 2509 } |
2503 | 2510 |
2504 std::vector<WebRtcVideoChannel2::VideoCodecSettings> | 2511 std::vector<WebRtcVideoChannel2::VideoCodecSettings> |
2505 WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs) { | 2512 WebRtcVideoChannel2::MapCodecs(const std::vector<VideoCodec>& codecs, |
2513 bool map_flexfec) { | |
perkj_webrtc
2017/05/12 12:05:05
remove and use IsFlexfecFieldTrialEnabled() in her
brandtr
2017/05/15 12:24:13
Done.
As was clear from our F2F discussion, howev
| |
2506 RTC_DCHECK(!codecs.empty()); | 2514 RTC_DCHECK(!codecs.empty()); |
2507 | 2515 |
2508 std::vector<VideoCodecSettings> video_codecs; | 2516 std::vector<VideoCodecSettings> video_codecs; |
2509 std::map<int, bool> payload_used; | 2517 std::map<int, bool> payload_used; |
2510 std::map<int, VideoCodec::CodecType> payload_codec_type; | 2518 std::map<int, VideoCodec::CodecType> payload_codec_type; |
2511 // |rtx_mapping| maps video payload type to rtx payload type. | 2519 // |rtx_mapping| maps video payload type to rtx payload type. |
2512 std::map<int, int> rtx_mapping; | 2520 std::map<int, int> rtx_mapping; |
2513 | 2521 |
2514 webrtc::UlpfecConfig ulpfec_config; | 2522 webrtc::UlpfecConfig ulpfec_config; |
2515 int flexfec_payload_type = -1; | 2523 int flexfec_payload_type = -1; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2587 return std::vector<VideoCodecSettings>(); | 2595 return std::vector<VideoCodecSettings>(); |
2588 } | 2596 } |
2589 | 2597 |
2590 if (it->first == ulpfec_config.red_payload_type) { | 2598 if (it->first == ulpfec_config.red_payload_type) { |
2591 ulpfec_config.red_rtx_payload_type = it->second; | 2599 ulpfec_config.red_rtx_payload_type = it->second; |
2592 } | 2600 } |
2593 } | 2601 } |
2594 | 2602 |
2595 for (size_t i = 0; i < video_codecs.size(); ++i) { | 2603 for (size_t i = 0; i < video_codecs.size(); ++i) { |
2596 video_codecs[i].ulpfec = ulpfec_config; | 2604 video_codecs[i].ulpfec = ulpfec_config; |
2597 video_codecs[i].flexfec_payload_type = flexfec_payload_type; | 2605 // Only map the FlexFEC payload type if we know that FlexFEC will actually |
2606 // be used. By doing that, we reduce the number of | |
2607 // VideoReceiveStream/VideoSendStream object recreations during SDP | |
2608 // renegotiation. | |
2609 if (map_flexfec) { | |
2610 video_codecs[i].flexfec_payload_type = flexfec_payload_type; | |
2611 } | |
2598 if (rtx_mapping[video_codecs[i].codec.id] != 0 && | 2612 if (rtx_mapping[video_codecs[i].codec.id] != 0 && |
2599 rtx_mapping[video_codecs[i].codec.id] != | 2613 rtx_mapping[video_codecs[i].codec.id] != |
2600 ulpfec_config.red_payload_type) { | 2614 ulpfec_config.red_payload_type) { |
2601 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2615 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2602 } | 2616 } |
2603 } | 2617 } |
2604 | 2618 |
2605 return video_codecs; | 2619 return video_codecs; |
2606 } | 2620 } |
2607 | 2621 |
2608 } // namespace cricket | 2622 } // namespace cricket |
OLD | NEW |