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