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 23 matching lines...) Expand all Loading... | |
34 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 34 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
35 #include "webrtc/media/engine/webrtcvoiceengine.h" | 35 #include "webrtc/media/engine/webrtcvoiceengine.h" |
36 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" | 36 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" |
37 #include "webrtc/system_wrappers/include/field_trial.h" | 37 #include "webrtc/system_wrappers/include/field_trial.h" |
38 #include "webrtc/video_decoder.h" | 38 #include "webrtc/video_decoder.h" |
39 #include "webrtc/video_encoder.h" | 39 #include "webrtc/video_encoder.h" |
40 | 40 |
41 namespace cricket { | 41 namespace cricket { |
42 namespace { | 42 namespace { |
43 | 43 |
44 // Three things happen when the FlexFEC field trial is enabled: | 44 // If this field trial is enabled, we will enable sending FlexFEC and disable |
45 // 1) FlexFEC is exposed in the default codec list, eventually showing up | 45 // sending ULPFEC whenever the former has been negotiated. Receiving FlexFEC |
46 // in the default SDP. (See InternalEncoderFactory ctor.) | 46 // is enabled whenever FlexFEC has been negotiated. |
47 // 2) FlexFEC send parameters are set in the VideoSendStream config. | |
48 // 3) FlexFEC receive parameters are set in the FlexfecReceiveStream config, | |
49 // and the corresponding object is instantiated. | |
50 const char kFlexfecFieldTrialName[] = "WebRTC-FlexFEC-03"; | |
51 | |
52 bool IsFlexfecFieldTrialEnabled() { | 47 bool IsFlexfecFieldTrialEnabled() { |
53 return webrtc::field_trial::IsEnabled(kFlexfecFieldTrialName); | 48 return webrtc::field_trial::FindFullName("WebRTC-FlexFEC-03") == "Enabled"; |
54 } | 49 } |
55 | 50 |
56 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. | 51 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. |
57 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { | 52 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { |
58 public: | 53 public: |
59 // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned | 54 // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned |
60 // by e.g. PeerConnectionFactory. | 55 // by e.g. PeerConnectionFactory. |
61 explicit EncoderFactoryAdapter(cricket::WebRtcVideoEncoderFactory* factory) | 56 explicit EncoderFactoryAdapter(cricket::WebRtcVideoEncoderFactory* factory) |
62 : factory_(factory) {} | 57 : factory_(factory) {} |
63 virtual ~EncoderFactoryAdapter() {} | 58 virtual ~EncoderFactoryAdapter() {} |
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1549 | 1544 |
1550 // ValidateStreamParams should prevent this from happening. | 1545 // ValidateStreamParams should prevent this from happening. |
1551 RTC_CHECK(!parameters_.config.rtp.ssrcs.empty()); | 1546 RTC_CHECK(!parameters_.config.rtp.ssrcs.empty()); |
1552 rtp_parameters_.encodings[0].ssrc = | 1547 rtp_parameters_.encodings[0].ssrc = |
1553 rtc::Optional<uint32_t>(parameters_.config.rtp.ssrcs[0]); | 1548 rtc::Optional<uint32_t>(parameters_.config.rtp.ssrcs[0]); |
1554 | 1549 |
1555 // RTX. | 1550 // RTX. |
1556 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, | 1551 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, |
1557 ¶meters_.config.rtp.rtx.ssrcs); | 1552 ¶meters_.config.rtp.rtx.ssrcs); |
1558 | 1553 |
1559 // FlexFEC. | 1554 // FlexFEC SSRCs. |
1560 // TODO(brandtr): This code needs to be generalized when we add support for | 1555 // TODO(brandtr): This code needs to be generalized when we add support for |
1561 // multistream protection. | 1556 // multistream protection. |
1562 if (IsFlexfecFieldTrialEnabled()) { | 1557 if (IsFlexfecFieldTrialEnabled()) { |
1563 uint32_t flexfec_ssrc; | 1558 uint32_t flexfec_ssrc; |
1564 bool flexfec_enabled = false; | 1559 bool flexfec_enabled = false; |
1565 for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) { | 1560 for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) { |
1566 if (sp.GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)) { | 1561 if (sp.GetFecFrSsrc(primary_ssrc, &flexfec_ssrc)) { |
1567 if (flexfec_enabled) { | 1562 if (flexfec_enabled) { |
1568 LOG(LS_INFO) << "Multiple FlexFEC streams proposed by remote, but " | 1563 LOG(LS_INFO) << "Multiple FlexFEC streams proposed by remote, but " |
1569 "our implementation only supports a single FlexFEC " | 1564 "our implementation only supports a single FlexFEC " |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1708 if (new_encoder.external) { | 1703 if (new_encoder.external) { |
1709 webrtc::VideoCodecType type = | 1704 webrtc::VideoCodecType type = |
1710 webrtc::PayloadNameToCodecType(codec_settings.codec.name) | 1705 webrtc::PayloadNameToCodecType(codec_settings.codec.name) |
1711 .value_or(webrtc::kVideoCodecUnknown); | 1706 .value_or(webrtc::kVideoCodecUnknown); |
1712 parameters_.config.encoder_settings.internal_source = | 1707 parameters_.config.encoder_settings.internal_source = |
1713 external_encoder_factory_->EncoderTypeHasInternalSource(type); | 1708 external_encoder_factory_->EncoderTypeHasInternalSource(type); |
1714 } else { | 1709 } else { |
1715 parameters_.config.encoder_settings.internal_source = false; | 1710 parameters_.config.encoder_settings.internal_source = false; |
1716 } | 1711 } |
1717 parameters_.config.rtp.ulpfec = codec_settings.ulpfec; | 1712 parameters_.config.rtp.ulpfec = codec_settings.ulpfec; |
1718 parameters_.config.rtp.flexfec.payload_type = | 1713 if (IsFlexfecFieldTrialEnabled()) { |
brandtr
2017/02/28 17:50:33
This check is not strictly necessary, but without
| |
1719 codec_settings.flexfec_payload_type; | 1714 parameters_.config.rtp.flexfec.payload_type = |
1715 codec_settings.flexfec_payload_type; | |
1716 } | |
1720 | 1717 |
1721 // Set RTX payload type if RTX is enabled. | 1718 // Set RTX payload type if RTX is enabled. |
1722 if (!parameters_.config.rtp.rtx.ssrcs.empty()) { | 1719 if (!parameters_.config.rtp.rtx.ssrcs.empty()) { |
1723 if (codec_settings.rtx_payload_type == -1) { | 1720 if (codec_settings.rtx_payload_type == -1) { |
1724 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " | 1721 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " |
1725 "payload type. Ignoring."; | 1722 "payload type. Ignoring."; |
1726 parameters_.config.rtp.rtx.ssrcs.clear(); | 1723 parameters_.config.rtp.rtx.ssrcs.clear(); |
1727 } else { | 1724 } else { |
1728 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; | 1725 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; |
1729 } | 1726 } |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2288 | 2285 |
2289 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { | 2286 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::RecreateWebRtcStream() { |
2290 if (stream_) { | 2287 if (stream_) { |
2291 call_->DestroyVideoReceiveStream(stream_); | 2288 call_->DestroyVideoReceiveStream(stream_); |
2292 stream_ = nullptr; | 2289 stream_ = nullptr; |
2293 } | 2290 } |
2294 if (flexfec_stream_) { | 2291 if (flexfec_stream_) { |
2295 call_->DestroyFlexfecReceiveStream(flexfec_stream_); | 2292 call_->DestroyFlexfecReceiveStream(flexfec_stream_); |
2296 flexfec_stream_ = nullptr; | 2293 flexfec_stream_ = nullptr; |
2297 } | 2294 } |
2298 if (IsFlexfecFieldTrialEnabled() && flexfec_config_.IsCompleteAndEnabled()) { | 2295 if (flexfec_config_.IsCompleteAndEnabled()) { |
brandtr
2017/02/28 17:50:32
Our ability on receiving FlexFEC packets should no
| |
2299 flexfec_stream_ = call_->CreateFlexfecReceiveStream(flexfec_config_); | 2296 flexfec_stream_ = call_->CreateFlexfecReceiveStream(flexfec_config_); |
2300 flexfec_stream_->Start(); | 2297 flexfec_stream_->Start(); |
2301 } | 2298 } |
2302 stream_ = call_->CreateVideoReceiveStream(config_.Copy()); | 2299 stream_ = call_->CreateVideoReceiveStream(config_.Copy()); |
2303 stream_->Start(); | 2300 stream_->Start(); |
2304 } | 2301 } |
2305 | 2302 |
2306 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( | 2303 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::ClearDecoders( |
2307 std::vector<AllocatedDecoder>* allocated_decoders) { | 2304 std::vector<AllocatedDecoder>* allocated_decoders) { |
2308 for (size_t i = 0; i < allocated_decoders->size(); ++i) { | 2305 for (size_t i = 0; i < allocated_decoders->size(); ++i) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2527 rtx_mapping[video_codecs[i].codec.id] != | 2524 rtx_mapping[video_codecs[i].codec.id] != |
2528 ulpfec_config.red_payload_type) { | 2525 ulpfec_config.red_payload_type) { |
2529 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2526 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
2530 } | 2527 } |
2531 } | 2528 } |
2532 | 2529 |
2533 return video_codecs; | 2530 return video_codecs; |
2534 } | 2531 } |
2535 | 2532 |
2536 } // namespace cricket | 2533 } // namespace cricket |
OLD | NEW |