henrike@webrtc.org
2014-10-06 17:56:43 +00:00
parent 9a742b4840
commit 528fc650d8
2 changed files with 13 additions and 2 deletions

View File

@ -333,7 +333,8 @@ class MediaCodecVideoDecoder {
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, properties.colorFormat);
}
Log.d(TAG, " Format: " + format);
mediaCodec = MediaCodec.createByCodecName(properties.codecName);
mediaCodec =
MediaCodecVideoEncoder.createByCodecName(properties.codecName);
if (mediaCodec == null) {
return false;
}

View File

@ -152,6 +152,16 @@ class MediaCodecVideoEncoder {
}
}
static MediaCodec createByCodecName(String codecName) {
try {
// In the L-SDK this call can throw IOException so in order to work in
// both cases catch an exception.
return MediaCodec.createByCodecName(codecName);
} catch (Exception e) {
return null;
}
}
// Return the array of input buffers, or null on failure.
private ByteBuffer[] initEncode(int width, int height, int kbps, int fps) {
Log.d(TAG, "Java initEncode: " + width + " x " + height +
@ -175,7 +185,7 @@ class MediaCodecVideoEncoder {
format.setInteger(MediaFormat.KEY_FRAME_RATE, fps);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 100);
Log.d(TAG, " Format: " + format);
mediaCodec = MediaCodec.createByCodecName(properties.codecName);
mediaCodec = createByCodecName(properties.codecName);
if (mediaCodec == null) {
return null;
}