OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2015 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 |
| 11 #include "webrtc/video_encoder.h" |
| 12 |
| 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
| 17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
| 18 |
| 19 namespace webrtc { |
| 20 VideoEncoder* VideoEncoder::Create(VideoEncoder::EncoderType codec_type) { |
| 21 RTC_DCHECK(IsSupportedSoftware(codec_type)); |
| 22 switch (codec_type) { |
| 23 case kH264: |
| 24 return H264Encoder::Create(); |
| 25 case kVp8: |
| 26 return VP8Encoder::Create(); |
| 27 case kVp9: |
| 28 return VP9Encoder::Create(); |
| 29 case kUnsupportedCodec: |
| 30 RTC_NOTREACHED(); |
| 31 return nullptr; |
| 32 } |
| 33 RTC_NOTREACHED(); |
| 34 return nullptr; |
| 35 } |
| 36 |
| 37 bool VideoEncoder::IsSupportedSoftware(EncoderType codec_type) { |
| 38 switch (codec_type) { |
| 39 case kH264: |
| 40 return H264Encoder::IsSupported(); |
| 41 case kVp8: |
| 42 return true; |
| 43 case kVp9: |
| 44 return VP9Encoder::IsSupported(); |
| 45 case kUnsupportedCodec: |
| 46 RTC_NOTREACHED(); |
| 47 return false; |
| 48 } |
| 49 RTC_NOTREACHED(); |
| 50 return false; |
| 51 } |
| 52 |
| 53 VideoEncoder::EncoderType VideoEncoder::CodecToEncoderType( |
| 54 VideoCodecType codec_type) { |
| 55 switch (codec_type) { |
| 56 case kVideoCodecH264: |
| 57 return VideoEncoder::kH264; |
| 58 case kVideoCodecVP8: |
| 59 return VideoEncoder::kVp8; |
| 60 case kVideoCodecVP9: |
| 61 return VideoEncoder::kVp9; |
| 62 default: |
| 63 return VideoEncoder::kUnsupportedCodec; |
| 64 } |
| 65 } |
| 66 |
| 67 } // namespace webrtc |
OLD | NEW |