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