Search in sources :

Example 6 with MediaCodec

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

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 7 with MediaCodec

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

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 8 with MediaCodec

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

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 9 with MediaCodec

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

the class EncodedAudioRecorder method recorderLoop.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void recorderLoop(SpeechRecord speechRecord) {
    mNumBytesSubmitted = 0;
    mNumBytesDequeued = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, getSampleRate());
        List<String> componentNames = AudioUtils.getEncoderNamesForType(format.getString(MediaFormat.KEY_MIME));
        for (String componentName : componentNames) {
            Log.i("component/format: " + componentName + "/" + format);
            MediaCodec codec = AudioUtils.createCodec(componentName, format);
            if (codec != null) {
                recorderEncoderLoop(codec, speechRecord);
                if (Log.DEBUG) {
                    AudioUtils.showMetrics(format, mNumBytesSubmitted, mNumBytesDequeued);
                }
                // TODO: we use the first one that is suitable
                break;
            }
        }
    }
}
Also used : MediaFormat(android.media.MediaFormat) MediaCodec(android.media.MediaCodec) TargetApi(android.annotation.TargetApi)

Example 10 with MediaCodec

use of android.media.MediaCodec in project ExoPlayer by google.

the class MediaCodecVideoRenderer method setSurface.

private void setSurface(Surface surface) throws ExoPlaybackException {
    // We only need to update the codec if the surface has changed.
    if (this.surface != surface) {
        this.surface = surface;
        int state = getState();
        if (state == STATE_ENABLED || state == STATE_STARTED) {
            MediaCodec codec = getCodec();
            if (Util.SDK_INT >= 23 && codec != null && surface != null) {
                setOutputSurfaceV23(codec, surface);
            } else {
                releaseCodec();
                maybeInitCodec();
            }
        }
    }
    // Clear state so that we always call the event listener with the video size and when a frame
    // is rendered, even if the surface hasn't changed.
    clearRenderedFirstFrame();
    clearLastReportedVideoSize();
}
Also used : MediaCodec(android.media.MediaCodec) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

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