Chromium Code Reviews| 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" |
|
tommi
2016/02/02 16:33:13
for what do we need the encoder header?
hbos
2016/02/02 17:08:19
H264Encoder::Create() and H264Decoder::Create().
tommi
2016/02/02 17:11:19
ah sorry, I was thinking openh264 encode. never mi
| |
| 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) | |
|
tommi
2016/02/02 16:33:13
Is this flag for h264 in general or specific to op
hbos
2016/02/02 17:08:19
It's for OpenH264 encoding + FFmpeg decoding both.
tommi
2016/02/02 17:11:19
Acknowledged.
| |
| 31 bool rtc_use_h264 = true; | |
|
tommi
2016/02/02 16:33:13
since this is a global variable, should have the g
hbos
2016/02/02 17:08:19
Done.
| |
| 32 #endif | |
| 33 | |
| 34 } // namespace | |
| 35 | |
| 36 void SetRtcUseH264(bool enable) { | |
|
tommi
2016/02/02 16:33:13
I'm assuming we do not want to allow flipping this
hbos
2016/02/02 17:08:19
Done. (Calling it DisableRtcUseH264() after |rtc_u
tommi
2016/02/02 17:11:19
Acknowledged.
| |
| 37 #if defined(WEBRTC_USE_H264) | |
| 38 rtc_use_h264 = enable; | |
|
tommi
2016/02/02 16:33:13
how do we guarantee thread safety? Wondering if w
hbos
2016/02/02 17:08:19
It's not, as per function comment in header.
| |
| 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 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()) { |
|
tommi
2016/02/02 16:33:13
since h264 is supported in this case, I think we s
hbos
2016/02/02 17:08:19
(TODO for name changes.)
| |
| 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) |
| 58 LOG(LS_INFO) << "Creating H264EncoderImpl."; | 72 if (rtc_use_h264) { |
|
tommi
2016/02/02 16:33:13
here, I would rather do:
RTC_[D]CHECK(rtc_use_h26
hbos
2016/02/02 17:08:19
Done.
| |
| 59 return new H264EncoderImpl(); | 73 LOG(LS_INFO) << "Creating H264EncoderImpl."; |
| 60 #else | 74 return new H264EncoderImpl(); |
| 75 } | |
| 76 #endif | |
| 61 RTC_NOTREACHED(); | 77 RTC_NOTREACHED(); |
| 62 return nullptr; | 78 return nullptr; |
| 63 #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) |
| 79 LOG(LS_INFO) << "Creating H264DecoderImpl."; | 94 if (rtc_use_h264) { |
|
tommi
2016/02/02 16:33:13
RTC_CHECK(rtc_use_h264)
hbos
2016/02/02 17:08:19
Done.
| |
| 80 return new H264DecoderImpl(); | 95 LOG(LS_INFO) << "Creating H264DecoderImpl."; |
| 81 #else | 96 return new H264DecoderImpl(); |
| 97 } | |
| 98 #endif | |
| 82 RTC_NOTREACHED(); | 99 RTC_NOTREACHED(); |
| 83 return nullptr; | 100 return nullptr; |
| 84 #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 |