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;
}
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;
}
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;
}
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;
}
}
}
}
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();
}
Aggregations