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