| 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 |
| 18 | 22 |
| 19 #include "webrtc/base/checks.h" | 23 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/logging.h" | 24 #include "webrtc/base/logging.h" |
| 21 | 25 |
| 22 namespace webrtc { | 26 namespace webrtc { |
| 23 | 27 |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 #if defined(WEBRTC_USE_H264) | 30 #if defined(WEBRTC_USE_H264) |
| 27 bool g_rtc_use_h264 = true; | 31 bool g_rtc_use_h264 = true; |
| 28 #endif | 32 #endif |
| 29 | 33 |
| 30 } // namespace | 34 } // namespace |
| 31 | 35 |
| 32 void DisableRtcUseH264() { | 36 void DisableRtcUseH264() { |
| 33 #if defined(WEBRTC_USE_H264) | 37 #if defined(WEBRTC_USE_H264) |
| 34 g_rtc_use_h264 = false; | 38 g_rtc_use_h264 = false; |
| 35 #endif | 39 #endif |
| 36 } | 40 } |
| 37 | 41 |
| 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 |
| 38 // 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). |
| 39 bool IsH264CodecSupported() { | 50 bool IsH264CodecSupported() { |
| 51 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
| 52 if (IsH264CodecSupportedObjC()) { |
| 53 return true; |
| 54 } |
| 55 #endif |
| 40 #if defined(WEBRTC_USE_H264) | 56 #if defined(WEBRTC_USE_H264) |
| 41 return g_rtc_use_h264; | 57 return g_rtc_use_h264; |
| 42 #else | 58 #else |
| 43 return false; | 59 return false; |
| 44 #endif | 60 #endif |
| 45 } | 61 } |
| 46 | 62 |
| 47 H264Encoder* H264Encoder::Create() { | 63 H264Encoder* H264Encoder::Create() { |
| 48 RTC_DCHECK(H264Encoder::IsSupported()); | 64 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 |
| 49 #if defined(WEBRTC_USE_H264) | 71 #if defined(WEBRTC_USE_H264) |
| 50 RTC_CHECK(g_rtc_use_h264); | 72 RTC_CHECK(g_rtc_use_h264); |
| 51 LOG(LS_INFO) << "Creating H264EncoderImpl."; | 73 LOG(LS_INFO) << "Creating H264EncoderImpl."; |
| 52 return new H264EncoderImpl(); | 74 return new H264EncoderImpl(); |
| 53 #else | 75 #else |
| 54 RTC_NOTREACHED(); | 76 RTC_NOTREACHED(); |
| 55 return nullptr; | 77 return nullptr; |
| 56 #endif | 78 #endif |
| 57 } | 79 } |
| 58 | 80 |
| 59 bool H264Encoder::IsSupported() { | 81 bool H264Encoder::IsSupported() { |
| 60 return IsH264CodecSupported(); | 82 return IsH264CodecSupported(); |
| 61 } | 83 } |
| 62 | 84 |
| 63 H264Decoder* H264Decoder::Create() { | 85 H264Decoder* H264Decoder::Create() { |
| 64 RTC_DCHECK(H264Decoder::IsSupported()); | 86 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 |
| 65 #if defined(WEBRTC_USE_H264) | 93 #if defined(WEBRTC_USE_H264) |
| 66 RTC_CHECK(g_rtc_use_h264); | 94 RTC_CHECK(g_rtc_use_h264); |
| 67 LOG(LS_INFO) << "Creating H264DecoderImpl."; | 95 LOG(LS_INFO) << "Creating H264DecoderImpl."; |
| 68 return new H264DecoderImpl(); | 96 return new H264DecoderImpl(); |
| 69 #else | 97 #else |
| 70 RTC_NOTREACHED(); | 98 RTC_NOTREACHED(); |
| 71 return nullptr; | 99 return nullptr; |
| 72 #endif | 100 #endif |
| 73 } | 101 } |
| 74 | 102 |
| 75 bool H264Decoder::IsSupported() { | 103 bool H264Decoder::IsSupported() { |
| 76 return IsH264CodecSupported(); | 104 return IsH264CodecSupported(); |
| 77 } | 105 } |
| 78 | 106 |
| 79 } // namespace webrtc | 107 } // namespace webrtc |
| OLD | NEW |