OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 | 11 |
12 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 12 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
13 | 13 |
| 14 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" |
| 15 #include "webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h" |
14 #if defined(WEBRTC_IOS) | 16 #if defined(WEBRTC_IOS) |
15 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h" | 17 #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" | 18 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h" |
17 #endif | 19 #endif |
18 | 20 |
19 #include "webrtc/base/checks.h" | 21 #include "webrtc/base/checks.h" |
20 | 22 |
21 namespace webrtc { | 23 namespace webrtc { |
22 | 24 |
23 // We need this file to be C++ only so it will compile properly for all | 25 // 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 | 26 // platforms. In order to write ObjC specific implementations we use private |
25 // externs. This function is defined in h264.mm. | 27 // externs. This function is defined in h264.mm. |
26 #if defined(WEBRTC_IOS) | 28 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
27 extern bool IsH264CodecSupportedObjC(); | 29 extern bool IsH264CodecSupportedObjC(); |
28 #endif | 30 #endif |
29 | 31 |
30 bool IsH264CodecSupported() { | 32 bool IsH264CodecSupported() { |
31 #if defined(WEBRTC_IOS) | 33 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
32 return IsH264CodecSupportedObjC(); | 34 if (IsH264CodecSupportedObjC()) { |
| 35 return true; |
| 36 } |
33 #else | 37 #else |
34 return false; | 38 // TODO(hbos): OpenH264 defines? |
| 39 return true; |
35 #endif | 40 #endif |
36 } | 41 } |
37 | 42 |
38 H264Encoder* H264Encoder::Create() { | 43 H264Encoder* H264Encoder::Create() { |
39 DCHECK(H264Encoder::IsSupported()); | 44 DCHECK(H264Encoder::IsSupported()); |
40 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 45 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
41 return new H264VideoToolboxEncoder(); | 46 if (IsH264CodecSupportedObjC()) { |
| 47 return new H264VideoToolboxEncoder(); |
| 48 } |
42 #else | 49 #else |
43 RTC_NOTREACHED(); | 50 // TODO(hbos): OpenH264 defines? |
44 return nullptr; | 51 return new H264EncoderImpl(); |
45 #endif | 52 #endif |
46 } | 53 } |
47 | 54 |
48 bool H264Encoder::IsSupported() { | 55 bool H264Encoder::IsSupported() { |
49 return IsH264CodecSupported(); | 56 return IsH264CodecSupported(); |
50 } | 57 } |
51 | 58 |
52 H264Decoder* H264Decoder::Create() { | 59 H264Decoder* H264Decoder::Create() { |
53 DCHECK(H264Decoder::IsSupported()); | 60 DCHECK(H264Decoder::IsSupported()); |
54 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 61 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
55 return new H264VideoToolboxDecoder(); | 62 if (IsH264CodecSupportedObjC()) { |
| 63 return new H264VideoToolboxDecoder(); |
| 64 } |
56 #else | 65 #else |
57 RTC_NOTREACHED(); | 66 // TODO(hbos): OpenH264 defines? |
58 return nullptr; | 67 return new H264DecoderImpl(); |
59 #endif | 68 #endif |
60 } | 69 } |
61 | 70 |
62 bool H264Decoder::IsSupported() { | 71 bool H264Decoder::IsSupported() { |
63 return IsH264CodecSupported(); | 72 return IsH264CodecSupported(); |
64 } | 73 } |
65 | 74 |
66 } // namespace webrtc | 75 } // namespace webrtc |
OLD | NEW |