Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264.cc

Issue 1306813009: H.264 video codec support using OpenH264/FFmpeg (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Misc (WebRtcVideoChannel2::...::ConfigureVideoEncoderSettings care about H264 case) Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_OPENH264)
15 #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
14 #if defined(WEBRTC_IOS) 18 #if defined(WEBRTC_IOS)
15 #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"
16 #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"
17 #endif 21 #endif
18 22
19 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
20 24
21 namespace webrtc { 25 namespace webrtc {
22 26
23 // We need this file to be C++ only so it will compile properly for all 27 // We need this file to be C++ only so it will compile properly for all
24 // platforms. In order to write ObjC specific implementations we use private 28 // platforms. In order to write ObjC specific implementations we use private
25 // externs. This function is defined in h264.mm. 29 // externs. This function is defined in h264.mm.
26 #if defined(WEBRTC_IOS) 30 #if defined(WEBRTC_IOS)
27 extern bool IsH264CodecSupportedObjC(); 31 extern bool IsH264CodecSupportedObjC();
28 #endif 32 #endif
29 33
34 // If any H.264 codec is supported (iOS HW or OpenH264).
30 bool IsH264CodecSupported() { 35 bool IsH264CodecSupported() {
31 #if defined(WEBRTC_IOS) 36 #if defined(WEBRTC_IOS)
32 return IsH264CodecSupportedObjC(); 37 if (IsH264CodecSupportedObjC()) {
38 return true;
39 }
40 #endif
41 #if defined(WEBRTC_OPENH264)
42 return true;
33 #else 43 #else
34 return false; 44 return false;
35 #endif 45 #endif
46 }
47
48 // If H.264 codec is supported and OpenH264 is the implementation used, meaning
49 // H264EncoderImpl and H264DecoderImpl.
50 bool IsOpenH264CodecSupported() {
51 #if defined(WEBRTC_OPENH264)
52 #if defined(WEBRTC_IOS)
53 // If on iOS and we have HW H.264 support we will prefer that over OpenH264
54 // and say that OpenH264 is not supported (even though some H264 is).
55 return !IsH264CodecSupportedObjC();
stefan-webrtc 2015/09/28 11:19:01 This seems a bit strange to me. Shouldn't we alway
hbos 2015/09/30 15:35:18 You're right. If we are able to support both HW an
stefan-webrtc 2015/10/01 08:19:30 But what I'm opposed to is that IsOpenH264CodecSup
hbos 2015/10/01 12:19:45 Poor name choice. It wasn't "do we support the Ope
56 #else
57 return true;
58 #endif
59 #else
60 return false;
61 #endif
36 } 62 }
37 63
38 H264Encoder* H264Encoder::Create() { 64 H264Encoder* H264Encoder::Create() {
39 DCHECK(H264Encoder::IsSupported()); 65 DCHECK(H264Encoder::IsSupported());
40 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) 66 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
41 return new H264VideoToolboxEncoder(); 67 if (IsH264CodecSupportedObjC()) {
42 #else 68 return new H264VideoToolboxEncoder();
69 }
70 #endif
71 #if defined(WEBRTC_OPENH264)
72 if (IsOpenH264CodecSupported()) {
73 return new H264EncoderImpl();
74 }
75 #endif
43 RTC_NOTREACHED(); 76 RTC_NOTREACHED();
44 return nullptr; 77 return nullptr;
45 #endif
46 } 78 }
47 79
48 bool H264Encoder::IsSupported() { 80 bool H264Encoder::IsSupported() {
49 return IsH264CodecSupported(); 81 return IsH264CodecSupported();
50 } 82 }
51 83
84 bool H264Encoder::IsSupportedOpenH264() {
85 return IsOpenH264CodecSupported();
86 }
87
52 H264Decoder* H264Decoder::Create() { 88 H264Decoder* H264Decoder::Create() {
53 DCHECK(H264Decoder::IsSupported()); 89 DCHECK(H264Decoder::IsSupported());
54 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) 90 #if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
55 return new H264VideoToolboxDecoder(); 91 if (IsH264CodecSupportedObjC()) {
56 #else 92 return new H264VideoToolboxDecoder();
93 }
94 #endif
95 #if defined(WEBRTC_OPENH264)
96 if (IsOpenH264CodecSupported()) {
97 return new H264DecoderImpl();
98 }
99 #endif
57 RTC_NOTREACHED(); 100 RTC_NOTREACHED();
58 return nullptr; 101 return nullptr;
59 #endif
60 } 102 }
61 103
62 bool H264Decoder::IsSupported() { 104 bool H264Decoder::IsSupported() {
63 return IsH264CodecSupported(); 105 return IsH264CodecSupported();
64 } 106 }
65 107
108 bool H264Decoder::IsSupportedOpenH264() {
109 return IsOpenH264CodecSupported();
110 }
111
66 } // namespace webrtc 112 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698