OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import static org.webrtc.MediaCodecUtils.EXYNOS_PREFIX; | 13 import static org.webrtc.MediaCodecUtils.EXYNOS_PREFIX; |
14 import static org.webrtc.MediaCodecUtils.INTEL_PREFIX; | 14 import static org.webrtc.MediaCodecUtils.INTEL_PREFIX; |
15 import static org.webrtc.MediaCodecUtils.NVIDIA_PREFIX; | 15 import static org.webrtc.MediaCodecUtils.NVIDIA_PREFIX; |
16 import static org.webrtc.MediaCodecUtils.QCOM_PREFIX; | 16 import static org.webrtc.MediaCodecUtils.QCOM_PREFIX; |
17 | 17 |
18 import android.media.MediaCodec; | 18 import android.media.MediaCodec; |
19 import android.media.MediaCodecInfo; | 19 import android.media.MediaCodecInfo; |
20 import android.media.MediaCodecInfo.CodecCapabilities; | 20 import android.media.MediaCodecInfo.CodecCapabilities; |
21 import android.media.MediaCodecList; | 21 import android.media.MediaCodecList; |
22 import android.os.Build; | 22 import android.os.Build; |
23 | 23 |
24 /** Factory for Android hardware VideoDecoders. */ | 24 /** Factory for Android hardware VideoDecoders. */ |
25 @SuppressWarnings("deprecation") // API level 16 requires use of deprecated meth ods. | 25 @SuppressWarnings("deprecation") // API level 16 requires use of deprecated meth ods. |
26 public class HardwareVideoDecoderFactory implements VideoDecoderFactory { | 26 public class HardwareVideoDecoderFactory implements VideoDecoderFactory { |
27 private static final String TAG = "HardwareVideoDecoderFactory"; | 27 private static final String TAG = "HardwareVideoDecoderFactory"; |
28 | 28 |
29 private final SurfaceTextureHelper helper; | |
30 | |
31 /** Creates a HardwareVideoDecoderFactory that does not use surface textures. */ | |
32 @Deprecated // Not removed yet to avoid breaking callers. Remove once Duo is ready. | |
sakal
2017/07/17 13:44:56
I don't think we should reference internal project
mellem
2017/07/17 21:57:15
Done.
| |
33 public HardwareVideoDecoderFactory() { | |
34 this(null); | |
35 } | |
36 | |
37 /** | |
38 * Creates a HardwareVideoDecoderFactory that supports surface texture renderi ng using the given | |
39 * SurfaceTextureHelper. SurfaceTextureHelper may be null. If it is null, th en surface support | |
40 * is disabled. | |
41 */ | |
42 public HardwareVideoDecoderFactory(SurfaceTextureHelper helper) { | |
43 this.helper = helper; | |
44 } | |
45 | |
29 @Override | 46 @Override |
30 public VideoDecoder createDecoder(String codecType) { | 47 public VideoDecoder createDecoder(String codecType) { |
pthatcher1
2017/07/11 18:30:24
Would it make more sense to pass the helper into c
mellem
2017/07/11 20:51:41
I don't think we want to change the factory interf
| |
31 VideoCodecType type = VideoCodecType.valueOf(codecType); | 48 VideoCodecType type = VideoCodecType.valueOf(codecType); |
32 MediaCodecInfo info = findCodecForType(type); | 49 MediaCodecInfo info = findCodecForType(type); |
33 | 50 |
34 if (info == null) { | 51 if (info == null) { |
35 return null; // No support for this codec type. | 52 return null; // No support for this codec type. |
36 } | 53 } |
37 | 54 |
38 CodecCapabilities capabilities = info.getCapabilitiesForType(type.mimeType() ); | 55 CodecCapabilities capabilities = info.getCapabilitiesForType(type.mimeType() ); |
39 return new HardwareVideoDecoder(info.getName(), type, | 56 return new HardwareVideoDecoder(info.getName(), type, |
40 MediaCodecUtils.selectColorFormat(MediaCodecUtils.DECODER_COLOR_FORMATS, capabilities)); | 57 MediaCodecUtils.selectColorFormat(MediaCodecUtils.DECODER_COLOR_FORMATS, capabilities), |
58 helper); | |
41 } | 59 } |
42 | 60 |
43 private MediaCodecInfo findCodecForType(VideoCodecType type) { | 61 private MediaCodecInfo findCodecForType(VideoCodecType type) { |
44 // HW decoding is not supported on builds before KITKAT. | 62 // HW decoding is not supported on builds before KITKAT. |
45 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { | 63 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { |
46 return null; | 64 return null; |
47 } | 65 } |
48 | 66 |
49 for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { | 67 for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { |
50 MediaCodecInfo info = null; | 68 MediaCodecInfo info = null; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 return name.startsWith(QCOM_PREFIX) || name.startsWith(EXYNOS_PREFIX); | 109 return name.startsWith(QCOM_PREFIX) || name.startsWith(EXYNOS_PREFIX); |
92 case H264: | 110 case H264: |
93 // QCOM, Intel, and Exynos supported for H264. | 111 // QCOM, Intel, and Exynos supported for H264. |
94 return name.startsWith(QCOM_PREFIX) || name.startsWith(INTEL_PREFIX) | 112 return name.startsWith(QCOM_PREFIX) || name.startsWith(INTEL_PREFIX) |
95 || name.startsWith(EXYNOS_PREFIX); | 113 || name.startsWith(EXYNOS_PREFIX); |
96 default: | 114 default: |
97 return false; | 115 return false; |
98 } | 116 } |
99 } | 117 } |
100 } | 118 } |
OLD | NEW |