OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/media/engine/internalencoderfactory.h" | 11 #include "webrtc/media/engine/internalencoderfactory.h" |
12 | 12 |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
| 18 #include "webrtc/system_wrappers/include/field_trial.h" |
18 | 19 |
19 namespace cricket { | 20 namespace cricket { |
20 | 21 |
| 22 namespace { |
| 23 |
| 24 const char kFlexfecFieldTrialName[] = "WebRTC-FlexFEC-03"; |
| 25 |
| 26 bool IsFlexfecFieldTrialEnabled() { |
| 27 return webrtc::field_trial::FindFullName(kFlexfecFieldTrialName) == "Enabled"; |
| 28 } |
| 29 |
| 30 } // namespace |
| 31 |
21 InternalEncoderFactory::InternalEncoderFactory() { | 32 InternalEncoderFactory::InternalEncoderFactory() { |
22 supported_codecs_.push_back(cricket::VideoCodec(kVp8CodecName)); | 33 supported_codecs_.push_back(cricket::VideoCodec(kVp8CodecName)); |
23 if (webrtc::VP9Encoder::IsSupported()) | 34 if (webrtc::VP9Encoder::IsSupported()) |
24 supported_codecs_.push_back(cricket::VideoCodec(kVp9CodecName)); | 35 supported_codecs_.push_back(cricket::VideoCodec(kVp9CodecName)); |
25 if (webrtc::H264Encoder::IsSupported()) { | 36 if (webrtc::H264Encoder::IsSupported()) { |
26 cricket::VideoCodec codec(kH264CodecName); | 37 cricket::VideoCodec codec(kH264CodecName); |
27 // TODO(magjed): Move setting these parameters into webrtc::H264Encoder | 38 // TODO(magjed): Move setting these parameters into webrtc::H264Encoder |
28 // instead. | 39 // instead. |
29 // TODO(hta): Set FMTP parameters for all codecs of type H264. | 40 // TODO(hta): Set FMTP parameters for all codecs of type H264. |
30 codec.SetParam(kH264FmtpProfileLevelId, | 41 codec.SetParam(kH264FmtpProfileLevelId, |
31 kH264ProfileLevelConstrainedBaseline); | 42 kH264ProfileLevelConstrainedBaseline); |
32 codec.SetParam(kH264FmtpLevelAsymmetryAllowed, "1"); | 43 codec.SetParam(kH264FmtpLevelAsymmetryAllowed, "1"); |
33 codec.SetParam(kH264FmtpPacketizationMode, "1"); | 44 codec.SetParam(kH264FmtpPacketizationMode, "1"); |
34 supported_codecs_.push_back(std::move(codec)); | 45 supported_codecs_.push_back(std::move(codec)); |
35 } | 46 } |
36 | 47 |
37 supported_codecs_.push_back(cricket::VideoCodec(kRedCodecName)); | 48 supported_codecs_.push_back(cricket::VideoCodec(kRedCodecName)); |
38 supported_codecs_.push_back(cricket::VideoCodec(kUlpfecCodecName)); | 49 supported_codecs_.push_back(cricket::VideoCodec(kUlpfecCodecName)); |
| 50 |
| 51 if (IsFlexfecFieldTrialEnabled()) { |
| 52 cricket::VideoCodec flexfec_codec(kFlexfecCodecName); |
| 53 // This value is currently arbitrarily set to 10 seconds. (The unit |
| 54 // is microseconds.) This parameter MUST be present in the SDP, but |
| 55 // we never use the actual value anywhere in our code however. |
| 56 // TODO(brandtr): Consider honouring this value in the sender and receiver. |
| 57 flexfec_codec.SetParam(kFlexfecFmtpRepairWindow, "10000000"); |
| 58 supported_codecs_.push_back(flexfec_codec); |
| 59 } |
39 } | 60 } |
40 | 61 |
41 InternalEncoderFactory::~InternalEncoderFactory() {} | 62 InternalEncoderFactory::~InternalEncoderFactory() {} |
42 | 63 |
43 // WebRtcVideoEncoderFactory implementation. | 64 // WebRtcVideoEncoderFactory implementation. |
44 webrtc::VideoEncoder* InternalEncoderFactory::CreateVideoEncoder( | 65 webrtc::VideoEncoder* InternalEncoderFactory::CreateVideoEncoder( |
45 const cricket::VideoCodec& codec) { | 66 const cricket::VideoCodec& codec) { |
46 switch (CodecTypeFromName(codec.name)) { | 67 switch (CodecTypeFromName(codec.name)) { |
47 case webrtc::kVideoCodecH264: | 68 case webrtc::kVideoCodecH264: |
48 return webrtc::H264Encoder::Create(); | 69 return webrtc::H264Encoder::Create(); |
(...skipping 10 matching lines...) Expand all Loading... |
59 InternalEncoderFactory::supported_codecs() const { | 80 InternalEncoderFactory::supported_codecs() const { |
60 return supported_codecs_; | 81 return supported_codecs_; |
61 } | 82 } |
62 | 83 |
63 void InternalEncoderFactory::DestroyVideoEncoder( | 84 void InternalEncoderFactory::DestroyVideoEncoder( |
64 webrtc::VideoEncoder* encoder) { | 85 webrtc::VideoEncoder* encoder) { |
65 delete encoder; | 86 delete encoder; |
66 } | 87 } |
67 | 88 |
68 } // namespace cricket | 89 } // namespace cricket |
OLD | NEW |