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 | |
| 14 | #if defined(WEBRTC_IOS) |
| 15 | #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h" |
| 16 | #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h" |
| 17 | #endif |
| 18 | |
| 19 | #include "webrtc/base/checks.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // We need this file to be C++ only so it will compile properly for all |
| 24 | // platforms. In order to write ObjC specific implementations we use private |
| 25 | // externs. This function is defined in h264.mm. |
| 26 | #if defined(WEBRTC_IOS) |
| 27 | extern bool IsH264CodecSupportedObjC(); |
| 28 | #endif |
| 29 | |
| 30 | bool IsH264CodecSupported() { |
| 31 | #if defined(WEBRTC_IOS) |
| 32 | return IsH264CodecSupportedObjC(); |
| 33 | #else |
| 34 | return false; |
| 35 | #endif |
| 36 | } |
| 37 | |
| 38 | H264Encoder* H264Encoder::Create() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 39 | RTC_DCHECK(H264Encoder::IsSupported()); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 40 | #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
| 41 | return new H264VideoToolboxEncoder(); |
| 42 | #else |
| 43 | RTC_NOTREACHED(); |
| 44 | return nullptr; |
| 45 | #endif |
| 46 | } |
| 47 | |
| 48 | bool H264Encoder::IsSupported() { |
| 49 | return IsH264CodecSupported(); |
| 50 | } |
| 51 | |
| 52 | H264Decoder* H264Decoder::Create() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 53 | RTC_DCHECK(H264Decoder::IsSupported()); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 54 | #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
| 55 | return new H264VideoToolboxDecoder(); |
| 56 | #else |
| 57 | RTC_NOTREACHED(); |
| 58 | return nullptr; |
| 59 | #endif |
| 60 | } |
| 61 | |
| 62 | bool H264Decoder::IsSupported() { |
| 63 | return IsH264CodecSupported(); |
| 64 | } |
| 65 | |
| 66 | } // namespace webrtc |