Index: webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java |
diff --git a/webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java b/webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java |
index 41fd0791dccd8249f79b600b0951d373a04e52e4..cab9a3f6e0bb85db70fe058f0f51cc9b3191382d 100644 |
--- a/webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java |
+++ b/webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java |
@@ -238,12 +238,14 @@ public class MediaCodecVideoDecoder { |
// Pass null in |surfaceTextureHelper| to configure the codec for ByteBuffer output. |
private boolean initDecode( |
- VideoCodecType type, int width, int height, SurfaceTextureHelper surfaceTextureHelper) { |
+ VideoCodecType type, int width, int height, |
+ SurfaceTextureHelper surfaceTextureHelper) { |
if (mediaCodecThread != null) { |
- throw new RuntimeException("Forgot to release()?"); |
+ throw new RuntimeException("initDecode: forgot to release()?"); |
} |
- useSurface = (surfaceTextureHelper != null); |
+ |
String mime = null; |
+ useSurface = (surfaceTextureHelper != null); |
String[] supportedCodecPrefixes = null; |
if (type == VideoCodecType.VIDEO_CODEC_VP8) { |
mime = VP8_MIME_TYPE; |
@@ -255,15 +257,17 @@ public class MediaCodecVideoDecoder { |
mime = H264_MIME_TYPE; |
supportedCodecPrefixes = supportedH264HwCodecPrefixes; |
} else { |
- throw new RuntimeException("Non supported codec " + type); |
+ throw new RuntimeException("initDecode: non supported codec " + type); |
} |
DecoderProperties properties = findDecoder(mime, supportedCodecPrefixes); |
if (properties == null) { |
throw new RuntimeException("Cannot find HW decoder for " + type); |
} |
+ |
Logging.d(TAG, "Java initDecode: " + type + " : "+ width + " x " + height + |
". Color: 0x" + Integer.toHexString(properties.colorFormat) + |
". Use Surface: " + useSurface); |
+ |
runningInstance = this; // Decoder is now running and can be queried for stack traces. |
mediaCodecThread = Thread.currentThread(); |
try { |
@@ -282,14 +286,14 @@ public class MediaCodecVideoDecoder { |
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, properties.colorFormat); |
} |
Logging.d(TAG, " Format: " + format); |
- mediaCodec = |
- MediaCodecVideoEncoder.createByCodecName(properties.codecName); |
+ mediaCodec = MediaCodecVideoEncoder.createByCodecName(properties.codecName); |
if (mediaCodec == null) { |
Logging.e(TAG, "Can not create media decoder"); |
return false; |
} |
mediaCodec.configure(format, surface, null, 0); |
mediaCodec.start(); |
+ |
colorFormat = properties.colorFormat; |
outputBuffers = mediaCodec.getOutputBuffers(); |
inputBuffers = mediaCodec.getInputBuffers(); |
@@ -306,6 +310,22 @@ public class MediaCodecVideoDecoder { |
} |
} |
+ private void softResetDecode(int width, int height) { |
perkj_webrtc
2016/03/02 12:33:22
call this just reset() and please add a comment wh
AlexG
2016/03/04 01:20:21
Done.
|
+ if (mediaCodecThread == null || mediaCodec == null) { |
+ throw new RuntimeException("softResetDecode for non initialized decoder."); |
+ } |
+ Logging.d(TAG, "Java soft reset: " + width + " x " + height); |
+ |
+ mediaCodec.flush(); |
+ |
+ this.width = width; |
+ this.height = height; |
+ decodeStartTimeMs.clear(); |
+ dequeuedSurfaceOutputBuffers.clear(); |
+ hasDecodedFirstFrame = false; |
+ droppedFrames = 0; |
+ } |
+ |
private void release() { |
Logging.d(TAG, "Java releaseDecoder. Total number of dropped frames: " + droppedFrames); |
checkOnMediaCodecThread(); |