Chromium Code Reviews| Index: webrtc/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java |
| diff --git a/webrtc/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/webrtc/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java |
| index 9b904431b567e352740ae76b8ffa25c83bd26857..1e203cad1e6724b93a57da8018185b6168e89d69 100644 |
| --- a/webrtc/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java |
| +++ b/webrtc/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java |
| @@ -55,14 +55,27 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { |
| private static final String H264_CONSTRAINED_HIGH_3_1 = |
| H264_PROFILE_CONSTRAINED_HIGH + H264_LEVEL_3_1; |
| + private final EglBase14.Context sharedContext; |
| private final boolean enableIntelVp8Encoder; |
| private final boolean enableH264HighProfile; |
| - public HardwareVideoEncoderFactory(boolean enableIntelVp8Encoder, boolean enableH264HighProfile) { |
| + public HardwareVideoEncoderFactory( |
| + EglBase.Context sharedContext, boolean enableIntelVp8Encoder, boolean enableH264HighProfile) { |
| + // Texture mode requires EglBase14. |
| + if (sharedContext instanceof EglBase14.Context) { |
|
sakal
2017/07/17 12:25:41
I would prefer this just taking in EglBase14.Conte
mellem
2017/07/17 17:49:29
EglBase14 is not part of the api (it's a package-p
|
| + this.sharedContext = (EglBase14.Context) sharedContext; |
| + } else { |
| + this.sharedContext = null; |
| + } |
| this.enableIntelVp8Encoder = enableIntelVp8Encoder; |
| this.enableH264HighProfile = enableH264HighProfile; |
| } |
| + @Deprecated |
| + public HardwareVideoEncoderFactory(boolean enableIntelVp8Encoder, boolean enableH264HighProfile) { |
| + this(null, enableIntelVp8Encoder, enableH264HighProfile); |
| + } |
| + |
| @Override |
| public VideoEncoder createEncoder(VideoCodecInfo input) { |
| VideoCodecType type = VideoCodecType.valueOf(input.name); |
| @@ -74,11 +87,14 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { |
| String codecName = info.getName(); |
| String mime = type.mimeType(); |
| - int colorFormat = MediaCodecUtils.selectColorFormat( |
| - MediaCodecUtils.ENCODER_COLOR_FORMATS, info.getCapabilitiesForType(mime)); |
| + int colorFormat = MediaCodecUtils.selectColorFormat(sharedContext == null |
| + ? MediaCodecUtils.ENCODER_COLOR_FORMATS |
| + : MediaCodecUtils.TEXTURE_COLOR_FORMATS, |
| + info.getCapabilitiesForType(mime)); |
| return new HardwareVideoEncoder(codecName, type, colorFormat, getKeyFrameIntervalSec(type), |
| - getForcedKeyFrameIntervalMs(type, codecName), createBitrateAdjuster(type, codecName)); |
| + getForcedKeyFrameIntervalMs(type, codecName), createBitrateAdjuster(type, codecName), |
| + sharedContext); |
| } |
| @Override |
| @@ -127,8 +143,10 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { |
| return false; |
| } |
| // Check for a supported color format. |
| - if (MediaCodecUtils.selectColorFormat( |
| - MediaCodecUtils.ENCODER_COLOR_FORMATS, info.getCapabilitiesForType(type.mimeType())) |
| + if (MediaCodecUtils.selectColorFormat(sharedContext == null |
| + ? MediaCodecUtils.ENCODER_COLOR_FORMATS |
| + : MediaCodecUtils.TEXTURE_COLOR_FORMATS, |
| + info.getCapabilitiesForType(type.mimeType())) |
| == null) { |
| return false; |
| } |