magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "media/engine/internalencoderfactory.h" |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 12 | |
| 13 | #include <utility> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "modules/video_coding/codecs/h264/include/h264.h" |
| 16 | #include "modules/video_coding/codecs/vp8/include/vp8.h" |
| 17 | #include "modules/video_coding/codecs/vp9/include/vp9.h" |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 18 | |
| 19 | namespace cricket { |
| 20 | |
| 21 | InternalEncoderFactory::InternalEncoderFactory() { |
Magnus Jedvert | 849b3ae | 2017-09-29 17:54:09 +0200 | [diff] [blame] | 22 | supported_codecs_.push_back(VideoCodec(kVp8CodecName)); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 23 | if (webrtc::VP9Encoder::IsSupported()) |
Magnus Jedvert | 849b3ae | 2017-09-29 17:54:09 +0200 | [diff] [blame] | 24 | supported_codecs_.push_back(VideoCodec(kVp9CodecName)); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 25 | |
Magnus Jedvert | 849b3ae | 2017-09-29 17:54:09 +0200 | [diff] [blame] | 26 | for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs()) |
| 27 | supported_codecs_.push_back(VideoCodec(format)); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | InternalEncoderFactory::~InternalEncoderFactory() {} |
| 31 | |
| 32 | // WebRtcVideoEncoderFactory implementation. |
| 33 | webrtc::VideoEncoder* InternalEncoderFactory::CreateVideoEncoder( |
Magnus Jedvert | 849b3ae | 2017-09-29 17:54:09 +0200 | [diff] [blame] | 34 | const VideoCodec& codec) { |
magjed | 10165ab | 2016-11-22 10:16:57 -0800 | [diff] [blame] | 35 | const webrtc::VideoCodecType codec_type = |
kthelgason | 1cdddc9 | 2017-08-24 03:52:48 -0700 | [diff] [blame] | 36 | webrtc::PayloadStringToCodecType(codec.name); |
magjed | 10165ab | 2016-11-22 10:16:57 -0800 | [diff] [blame] | 37 | switch (codec_type) { |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 38 | case webrtc::kVideoCodecH264: |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 39 | return webrtc::H264Encoder::Create(codec).release(); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 40 | case webrtc::kVideoCodecVP8: |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 41 | return webrtc::VP8Encoder::Create().release(); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 42 | case webrtc::kVideoCodecVP9: |
Magnus Jedvert | 46a2765 | 2017-11-13 14:10:02 +0100 | [diff] [blame] | 43 | return webrtc::VP9Encoder::Create().release(); |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 44 | default: |
| 45 | return nullptr; |
| 46 | } |
| 47 | } |
| 48 | |
Magnus Jedvert | 849b3ae | 2017-09-29 17:54:09 +0200 | [diff] [blame] | 49 | const std::vector<VideoCodec>& |
magjed | 509e4fe | 2016-11-18 01:34:11 -0800 | [diff] [blame] | 50 | InternalEncoderFactory::supported_codecs() const { |
| 51 | return supported_codecs_; |
| 52 | } |
| 53 | |
| 54 | void InternalEncoderFactory::DestroyVideoEncoder( |
| 55 | webrtc::VideoEncoder* encoder) { |
| 56 | delete encoder; |
| 57 | } |
| 58 | |
| 59 | } // namespace cricket |