Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 13 | |
hbos | 9dc5928 | 2016-02-03 05:09:37 -0800 | [diff] [blame] | 14 | #if defined(WEBRTC_USE_H264) |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame] | 15 | #include "webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h" |
hbos | 9dc5928 | 2016-02-03 05:09:37 -0800 | [diff] [blame] | 16 | #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame] | 17 | #endif |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 18 | |
| 19 | #include "webrtc/base/checks.h" |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame] | 20 | #include "webrtc/base/logging.h" |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
hbos | 9dc5928 | 2016-02-03 05:09:37 -0800 | [diff] [blame] | 24 | namespace { |
| 25 | |
| 26 | #if defined(WEBRTC_USE_H264) |
| 27 | bool g_rtc_use_h264 = true; |
| 28 | #endif |
| 29 | |
| 30 | } // namespace |
| 31 | |
| 32 | void DisableRtcUseH264() { |
| 33 | #if defined(WEBRTC_USE_H264) |
| 34 | g_rtc_use_h264 = false; |
| 35 | #endif |
| 36 | } |
| 37 | |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame] | 38 | // If any H.264 codec is supported (iOS HW or OpenH264/FFmpeg). |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 39 | bool IsH264CodecSupported() { |
hbos | 9dc5928 | 2016-02-03 05:09:37 -0800 | [diff] [blame] | 40 | #if defined(WEBRTC_USE_H264) |
| 41 | return g_rtc_use_h264; |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 42 | #else |
| 43 | return false; |
| 44 | #endif |
| 45 | } |
| 46 | |
magjed | ceecea4 | 2016-11-28 07:20:21 -0800 | [diff] [blame] | 47 | H264Encoder* H264Encoder::Create(const cricket::VideoCodec& codec) { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 48 | RTC_DCHECK(H264Encoder::IsSupported()); |
hbos | 9dc5928 | 2016-02-03 05:09:37 -0800 | [diff] [blame] | 49 | #if defined(WEBRTC_USE_H264) |
| 50 | RTC_CHECK(g_rtc_use_h264); |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame] | 51 | LOG(LS_INFO) << "Creating H264EncoderImpl."; |
hta | 243a0a7 | 2016-12-06 04:21:58 -0800 | [diff] [blame] | 52 | return new H264EncoderImpl(); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 53 | #else |
| 54 | RTC_NOTREACHED(); |
| 55 | return nullptr; |
| 56 | #endif |
| 57 | } |
| 58 | |
| 59 | bool H264Encoder::IsSupported() { |
| 60 | return IsH264CodecSupported(); |
| 61 | } |
| 62 | |
| 63 | H264Decoder* H264Decoder::Create() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 64 | RTC_DCHECK(H264Decoder::IsSupported()); |
hbos | 9dc5928 | 2016-02-03 05:09:37 -0800 | [diff] [blame] | 65 | #if defined(WEBRTC_USE_H264) |
| 66 | RTC_CHECK(g_rtc_use_h264); |
hbos | bab934b | 2016-01-27 01:36:03 -0800 | [diff] [blame] | 67 | LOG(LS_INFO) << "Creating H264DecoderImpl."; |
| 68 | return new H264DecoderImpl(); |
Zeke Chin | 71f6f44 | 2015-06-29 14:34:58 -0700 | [diff] [blame] | 69 | #else |
| 70 | RTC_NOTREACHED(); |
| 71 | return nullptr; |
| 72 | #endif |
| 73 | } |
| 74 | |
| 75 | bool H264Decoder::IsSupported() { |
| 76 | return IsH264CodecSupported(); |
| 77 | } |
| 78 | |
| 79 | } // namespace webrtc |