blob: 471ca249841ca4bd85140613d80325407beef624 [file] [log] [blame]
Zeke Chin71f6f442015-06-29 14:34:58 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020012#include "modules/video_coding/codecs/h264/include/h264.h"
Zeke Chin71f6f442015-06-29 14:34:58 -070013
hbos9dc59282016-02-03 05:09:37 -080014#if defined(WEBRTC_USE_H264)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "modules/video_coding/codecs/h264/h264_decoder_impl.h"
16#include "modules/video_coding/codecs/h264/h264_encoder_impl.h"
hbosbab934b2016-01-27 01:36:03 -080017#endif
Zeke Chin71f6f442015-06-29 14:34:58 -070018
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/checks.h"
20#include "rtc_base/logging.h"
Zeke Chin71f6f442015-06-29 14:34:58 -070021
22namespace webrtc {
23
hbos9dc59282016-02-03 05:09:37 -080024namespace {
25
26#if defined(WEBRTC_USE_H264)
27bool g_rtc_use_h264 = true;
28#endif
29
30} // namespace
31
32void DisableRtcUseH264() {
33#if defined(WEBRTC_USE_H264)
34 g_rtc_use_h264 = false;
35#endif
36}
37
hbosbab934b2016-01-27 01:36:03 -080038// If any H.264 codec is supported (iOS HW or OpenH264/FFmpeg).
Zeke Chin71f6f442015-06-29 14:34:58 -070039bool IsH264CodecSupported() {
hbos9dc59282016-02-03 05:09:37 -080040#if defined(WEBRTC_USE_H264)
41 return g_rtc_use_h264;
Zeke Chin71f6f442015-06-29 14:34:58 -070042#else
43 return false;
44#endif
45}
46
magjedceecea42016-11-28 07:20:21 -080047H264Encoder* H264Encoder::Create(const cricket::VideoCodec& codec) {
henrikg91d6ede2015-09-17 00:24:34 -070048 RTC_DCHECK(H264Encoder::IsSupported());
hbos9dc59282016-02-03 05:09:37 -080049#if defined(WEBRTC_USE_H264)
50 RTC_CHECK(g_rtc_use_h264);
hbosbab934b2016-01-27 01:36:03 -080051 LOG(LS_INFO) << "Creating H264EncoderImpl.";
hta9aa96882016-12-06 05:36:03 -080052 return new H264EncoderImpl(codec);
Zeke Chin71f6f442015-06-29 14:34:58 -070053#else
54 RTC_NOTREACHED();
55 return nullptr;
56#endif
57}
58
59bool H264Encoder::IsSupported() {
60 return IsH264CodecSupported();
61}
62
63H264Decoder* H264Decoder::Create() {
henrikg91d6ede2015-09-17 00:24:34 -070064 RTC_DCHECK(H264Decoder::IsSupported());
hbos9dc59282016-02-03 05:09:37 -080065#if defined(WEBRTC_USE_H264)
66 RTC_CHECK(g_rtc_use_h264);
hbosbab934b2016-01-27 01:36:03 -080067 LOG(LS_INFO) << "Creating H264DecoderImpl.";
68 return new H264DecoderImpl();
Zeke Chin71f6f442015-06-29 14:34:58 -070069#else
70 RTC_NOTREACHED();
71 return nullptr;
72#endif
73}
74
75bool H264Decoder::IsSupported() {
76 return IsH264CodecSupported();
77}
78
79} // namespace webrtc