Search in sources :

Example 16 with MediaCodec

use of android.media.MediaCodec in project android_frameworks_base by DirtyUnicorns.

the class GpuVideoTrackDecoder method initMediaCodec.

@Override
protected MediaCodec initMediaCodec(MediaFormat format) {
    MediaCodec mediaCodec;
    try {
        mediaCodec = MediaCodec.createDecoderByType(format.getString(MediaFormat.KEY_MIME));
    } catch (IOException e) {
        throw new RuntimeException("failed to create decoder for " + format.getString(MediaFormat.KEY_MIME), e);
    }
    Surface surface = new Surface(mSurfaceTexture);
    mediaCodec.configure(format, surface, null, 0);
    surface.release();
    return mediaCodec;
}
Also used : MediaCodec(android.media.MediaCodec) IOException(java.io.IOException) Surface(android.view.Surface)

Example 17 with MediaCodec

use of android.media.MediaCodec in project android_frameworks_base by DirtyUnicorns.

the class AudioTrackDecoder method initMediaCodec.

@Override
protected MediaCodec initMediaCodec(MediaFormat format) {
    MediaCodec mediaCodec;
    try {
        mediaCodec = MediaCodec.createDecoderByType(format.getString(MediaFormat.KEY_MIME));
    } catch (IOException e) {
        throw new RuntimeException("failed to create decoder for " + format.getString(MediaFormat.KEY_MIME), e);
    }
    mediaCodec.configure(format, null, null, 0);
    return mediaCodec;
}
Also used : MediaCodec(android.media.MediaCodec) IOException(java.io.IOException)

Example 18 with MediaCodec

use of android.media.MediaCodec in project speechutils by Kaljurand.

the class AudioUtils method createCodec.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static MediaCodec createCodec(String componentName, MediaFormat format) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        try {
            MediaCodec codec = MediaCodec.createByCodecName(componentName);
            codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
            return codec;
        } catch (IllegalStateException e) {
            Log.e("codec '" + componentName + "' failed configuration.");
        } catch (IOException e) {
            Log.e("codec '" + componentName + "' failed configuration.");
        }
    }
    return null;
}
Also used : MediaCodec(android.media.MediaCodec) IOException(java.io.IOException) TargetApi(android.annotation.TargetApi)

Example 19 with MediaCodec

use of android.media.MediaCodec in project android_frameworks_base by ResurrectionRemix.

the class CpuVideoTrackDecoder method initMediaCodec.

@Override
protected MediaCodec initMediaCodec(MediaFormat format) {
    // Find a codec for our video that can output to one of our supported color-spaces
    MediaCodec mediaCodec = findDecoderCodec(format, new int[] { CodecCapabilities.COLOR_Format32bitARGB8888, CodecCapabilities.COLOR_FormatYUV420Planar });
    if (mediaCodec == null) {
        throw new RuntimeException("Could not find a suitable decoder for format: " + format + "!");
    }
    mediaCodec.configure(format, null, null, 0);
    return mediaCodec;
}
Also used : MediaCodec(android.media.MediaCodec)

Example 20 with MediaCodec

use of android.media.MediaCodec in project android_frameworks_base by crdroidandroid.

the class GpuVideoTrackDecoder method initMediaCodec.

@Override
protected MediaCodec initMediaCodec(MediaFormat format) {
    MediaCodec mediaCodec;
    try {
        mediaCodec = MediaCodec.createDecoderByType(format.getString(MediaFormat.KEY_MIME));
    } catch (IOException e) {
        throw new RuntimeException("failed to create decoder for " + format.getString(MediaFormat.KEY_MIME), e);
    }
    Surface surface = new Surface(mSurfaceTexture);
    mediaCodec.configure(format, surface, null, 0);
    surface.release();
    return mediaCodec;
}
Also used : MediaCodec(android.media.MediaCodec) IOException(java.io.IOException) Surface(android.view.Surface)

Aggregations

MediaCodec (android.media.MediaCodec)21 IOException (java.io.IOException)10 MediaFormat (android.media.MediaFormat)7 Surface (android.view.Surface)5 TargetApi (android.annotation.TargetApi)2 MediaExtractor (android.media.MediaExtractor)2 MediaMuxer (android.media.MediaMuxer)2 SuppressLint (android.annotation.SuppressLint)1 Point (android.graphics.Point)1 BufferInfo (android.media.MediaCodec.BufferInfo)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 EglCore (com.android.grafika.gles.EglCore)1 WindowSurface (com.android.grafika.gles.WindowSurface)1 FileNotFoundException (java.io.FileNotFoundException)1 ByteBuffer (java.nio.ByteBuffer)1 CalledByNative (org.chromium.base.CalledByNative)1