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/webrtcvideoencoderfactory.h" | 11 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
12 | 12 |
13 #include "webrtc/media/base/mediaconstants.h" | 13 #include "webrtc/common_types.h" |
14 | |
15 static const char* NameFromCodecType(webrtc::VideoCodecType type) { | |
16 switch (type) { | |
17 case webrtc::kVideoCodecVP8: | |
18 return cricket::kVp8CodecName; | |
19 case webrtc::kVideoCodecVP9: | |
20 return cricket::kVp9CodecName; | |
21 case webrtc::kVideoCodecH264: | |
22 return cricket::kH264CodecName; | |
23 default: | |
24 return "Unknown codec"; | |
25 } | |
26 } | |
27 | 14 |
28 namespace cricket { | 15 namespace cricket { |
29 | 16 |
30 webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder( | 17 webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder( |
31 const cricket::VideoCodec& codec) { | 18 const cricket::VideoCodec& codec) { |
32 return CreateVideoEncoder(CodecTypeFromName(codec.name)); | 19 return CreateVideoEncoder(webrtc::PayloadNameToCodecType(codec.name) |
20 .value_or(webrtc::kVideoCodecUnknown)); | |
33 } | 21 } |
34 | 22 |
35 const std::vector<cricket::VideoCodec>& | 23 const std::vector<cricket::VideoCodec>& |
36 WebRtcVideoEncoderFactory::supported_codecs() const { | 24 WebRtcVideoEncoderFactory::supported_codecs() const { |
37 const std::vector<VideoCodec>& encoder_codecs = codecs(); | 25 const std::vector<VideoCodec>& encoder_codecs = codecs(); |
38 for (const VideoCodec& encoder_codec : encoder_codecs) { | 26 for (const VideoCodec& encoder_codec : encoder_codecs) { |
39 codecs_.push_back(cricket::VideoCodec(encoder_codec.name)); | 27 codecs_.push_back(cricket::VideoCodec(encoder_codec.name)); |
40 } | 28 } |
41 return codecs_; | 29 return codecs_; |
42 } | 30 } |
43 | 31 |
44 webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder( | 32 webrtc::VideoEncoder* WebRtcVideoEncoderFactory::CreateVideoEncoder( |
45 webrtc::VideoCodecType type) { | 33 webrtc::VideoCodecType type) { |
46 const cricket::VideoCodec codec(NameFromCodecType(type)); | 34 const cricket::VideoCodec codec( |
35 webrtc::CodecTypeToPayloadName(type).value_or("Unknown")); | |
sprang_webrtc
2016/11/18 07:10:48
The name will now be "Unknown" instead of "Unknown
magjed1
2016/11/18 11:48:18
I changed it back to "Unknown codec" just in case.
| |
47 return CreateVideoEncoder(codec); | 36 return CreateVideoEncoder(codec); |
48 } | 37 } |
49 | 38 |
50 const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& | 39 const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& |
51 WebRtcVideoEncoderFactory::codecs() const { | 40 WebRtcVideoEncoderFactory::codecs() const { |
52 const std::vector<cricket::VideoCodec>& codecs = supported_codecs(); | 41 const std::vector<cricket::VideoCodec>& codecs = supported_codecs(); |
53 for (const cricket::VideoCodec& codec : codecs) { | 42 for (const cricket::VideoCodec& codec : codecs) { |
54 encoder_codecs_.push_back( | 43 encoder_codecs_.push_back( |
55 VideoCodec(CodecTypeFromName(codec.name), codec.name)); | 44 VideoCodec(webrtc::PayloadNameToCodecType(codec.name) |
45 .value_or(webrtc::kVideoCodecUnknown), | |
46 codec.name)); | |
56 } | 47 } |
57 return encoder_codecs_; | 48 return encoder_codecs_; |
58 } | 49 } |
59 | 50 |
60 } // namespace cricket | 51 } // namespace cricket |
OLD | NEW |