Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 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 | |
| 12 | #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 13 | |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame^] | 14 | #if defined(WEBRTC_THIRD_PARTY_H264) |
| 15 | #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" |
| 16 | #include "webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h" |
| 17 | #endif |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 18 | #if defined(WEBRTC_IOS) |
| 19 | #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h" |
| 20 | #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h" |
| 21 | #endif |
| 22 | |
| 23 | #include "webrtc/base/checks.h" |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame^] | 24 | #include "webrtc/base/logging.h" |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
| 27 | |
| 28 | // We need this file to be C++ only so it will compile properly for all |
| 29 | // platforms. In order to write ObjC specific implementations we use private |
| 30 | // externs. This function is defined in h264.mm. |
| 31 | #if defined(WEBRTC_IOS) |
| 32 | extern bool IsH264CodecSupportedObjC(); |
| 33 | #endif |
| 34 | |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame^] | 35 | // If any H.264 codec is supported (iOS HW or OpenH264/FFmpeg). |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 36 | bool IsH264CodecSupported() { |
| 37 | #if defined(WEBRTC_IOS) |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame^] | 38 | if (IsH264CodecSupportedObjC()) { |
| 39 | return true; |
| 40 | } |
| 41 | #endif |
| 42 | #if defined(WEBRTC_THIRD_PARTY_H264) |
| 43 | return true; |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 44 | #else |
| 45 | return false; |
| 46 | #endif |
| 47 | } |
| 48 | |
| 49 | H264Encoder* H264Encoder::Create() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 50 | RTC_DCHECK(H264Encoder::IsSupported()); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 51 | #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame^] | 52 | if (IsH264CodecSupportedObjC()) { |
| 53 | LOG(LS_INFO) << "Creating H264VideoToolboxEncoder."; |
| 54 | return new H264VideoToolboxEncoder(); |
| 55 | } |
| 56 | #endif |
| 57 | #if defined(WEBRTC_THIRD_PARTY_H264) |
| 58 | LOG(LS_INFO) << "Creating H264EncoderImpl."; |
| 59 | return new H264EncoderImpl(); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 60 | #else |
| 61 | RTC_NOTREACHED(); |
| 62 | return nullptr; |
| 63 | #endif |
| 64 | } |
| 65 | |
| 66 | bool H264Encoder::IsSupported() { |
| 67 | return IsH264CodecSupported(); |
| 68 | } |
| 69 | |
| 70 | H264Decoder* H264Decoder::Create() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 71 | RTC_DCHECK(H264Decoder::IsSupported()); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 72 | #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame^] | 73 | if (IsH264CodecSupportedObjC()) { |
| 74 | LOG(LS_INFO) << "Creating H264VideoToolboxDecoder."; |
| 75 | return new H264VideoToolboxDecoder(); |
| 76 | } |
| 77 | #endif |
| 78 | #if defined(WEBRTC_THIRD_PARTY_H264) |
| 79 | LOG(LS_INFO) << "Creating H264DecoderImpl."; |
| 80 | return new H264DecoderImpl(); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 81 | #else |
| 82 | RTC_NOTREACHED(); |
| 83 | return nullptr; |
| 84 | #endif |
| 85 | } |
| 86 | |
| 87 | bool H264Decoder::IsSupported() { |
| 88 | return IsH264CodecSupported(); |
| 89 | } |
| 90 | |
| 91 | } // namespace webrtc |