use of android.media.MediaCodec.BufferInfo in project android_frameworks_base by ResurrectionRemix.
the class TrackDecoder method drainOutputBuffer.
public boolean drainOutputBuffer() {
BufferInfo outputInfo = new BufferInfo();
int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(outputInfo, TIMEOUT_US);
if ((outputInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mListener.onEndOfStream(this);
return false;
}
if (mShouldEnqueueEndOfStream) {
tryEnqueueEndOfStream();
}
if (outputBufferIndex >= 0) {
return onDataAvailable(mMediaCodec, mCodecOutputBuffers, outputBufferIndex, outputInfo);
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
mCodecOutputBuffers = mMediaCodec.getOutputBuffers();
return true;
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
mOutputFormat = mMediaCodec.getOutputFormat();
Log.d(LOG_TAG, "Output format has changed to " + mOutputFormat);
return true;
}
return false;
}
use of android.media.MediaCodec.BufferInfo in project android_frameworks_base by DirtyUnicorns.
the class TrackDecoder method drainOutputBuffer.
public boolean drainOutputBuffer() {
BufferInfo outputInfo = new BufferInfo();
int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(outputInfo, TIMEOUT_US);
if ((outputInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mListener.onEndOfStream(this);
return false;
}
if (mShouldEnqueueEndOfStream) {
tryEnqueueEndOfStream();
}
if (outputBufferIndex >= 0) {
return onDataAvailable(mMediaCodec, mCodecOutputBuffers, outputBufferIndex, outputInfo);
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
mCodecOutputBuffers = mMediaCodec.getOutputBuffers();
return true;
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
mOutputFormat = mMediaCodec.getOutputFormat();
Log.d(LOG_TAG, "Output format has changed to " + mOutputFormat);
return true;
}
return false;
}
use of android.media.MediaCodec.BufferInfo in project platform_frameworks_base by android.
the class TrackDecoder method drainOutputBuffer.
public boolean drainOutputBuffer() {
BufferInfo outputInfo = new BufferInfo();
int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(outputInfo, TIMEOUT_US);
if ((outputInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mListener.onEndOfStream(this);
return false;
}
if (mShouldEnqueueEndOfStream) {
tryEnqueueEndOfStream();
}
if (outputBufferIndex >= 0) {
return onDataAvailable(mMediaCodec, mCodecOutputBuffers, outputBufferIndex, outputInfo);
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
mCodecOutputBuffers = mMediaCodec.getOutputBuffers();
return true;
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
mOutputFormat = mMediaCodec.getOutputFormat();
Log.d(LOG_TAG, "Output format has changed to " + mOutputFormat);
return true;
}
return false;
}
use of android.media.MediaCodec.BufferInfo in project platform_frameworks_base by android.
the class DisplaySinkService method updateSurfaceFromUi.
private void updateSurfaceFromUi(SurfaceHolder holder) {
Surface surface = null;
int width = 0, height = 0;
if (holder != null && !holder.isCreating()) {
surface = holder.getSurface();
if (surface.isValid()) {
final Rect frame = holder.getSurfaceFrame();
width = frame.width();
height = frame.height();
} else {
surface = null;
}
}
synchronized (mSurfaceAndCodecLock) {
if (mSurface == surface && mSurfaceWidth == width && mSurfaceHeight == height) {
return;
}
mSurface = surface;
mSurfaceWidth = width;
mSurfaceHeight = height;
if (mCodec != null) {
mCodec.stop();
mCodec = null;
mCodecInputBuffers = null;
mCodecBufferInfo = null;
}
if (mSurface != null) {
MediaFormat format = MediaFormat.createVideoFormat("video/avc", mSurfaceWidth, mSurfaceHeight);
try {
mCodec = MediaCodec.createDecoderByType("video/avc");
} catch (IOException e) {
throw new RuntimeException("failed to create video/avc decoder", e);
}
mCodec.configure(format, mSurface, null, 0);
mCodec.start();
mCodecBufferInfo = new BufferInfo();
}
mTransportHandler.post(new Runnable() {
@Override
public void run() {
sendSinkStatus();
}
});
}
}
use of android.media.MediaCodec.BufferInfo in project android_frameworks_base by crdroidandroid.
the class TrackDecoder method drainOutputBuffer.
public boolean drainOutputBuffer() {
BufferInfo outputInfo = new BufferInfo();
int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(outputInfo, TIMEOUT_US);
if ((outputInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
mListener.onEndOfStream(this);
return false;
}
if (mShouldEnqueueEndOfStream) {
tryEnqueueEndOfStream();
}
if (outputBufferIndex >= 0) {
return onDataAvailable(mMediaCodec, mCodecOutputBuffers, outputBufferIndex, outputInfo);
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
mCodecOutputBuffers = mMediaCodec.getOutputBuffers();
return true;
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
mOutputFormat = mMediaCodec.getOutputFormat();
Log.d(LOG_TAG, "Output format has changed to " + mOutputFormat);
return true;
}
return false;
}
Aggregations