Search in sources :

Example 1 with BufferInfo

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;
}
Also used : BufferInfo(android.media.MediaCodec.BufferInfo)

Example 2 with BufferInfo

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;
}
Also used : BufferInfo(android.media.MediaCodec.BufferInfo)

Example 3 with BufferInfo

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;
}
Also used : BufferInfo(android.media.MediaCodec.BufferInfo)

Example 4 with BufferInfo

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();
            }
        });
    }
}
Also used : MediaFormat(android.media.MediaFormat) Rect(android.graphics.Rect) BufferInfo(android.media.MediaCodec.BufferInfo) IOException(java.io.IOException) Surface(android.view.Surface)

Example 5 with BufferInfo

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;
}
Also used : BufferInfo(android.media.MediaCodec.BufferInfo)

Aggregations

BufferInfo (android.media.MediaCodec.BufferInfo)26 ByteBuffer (java.nio.ByteBuffer)10 MediaCodec (android.media.MediaCodec)8 MediaFormat (android.media.MediaFormat)8 Test (org.junit.Test)7 IOException (java.io.IOException)6 SuppressLint (android.annotation.SuppressLint)5 Rect (android.graphics.Rect)4 Surface (android.view.Surface)4 MediaExtractor (android.media.MediaExtractor)2 Implementation (org.robolectric.annotation.Implementation)2 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 MediaMuxer (android.media.MediaMuxer)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 IsoFile (com.coremedia.iso.IsoFile)1 File (java.io.File)1 RandomAccessFile (java.io.RandomAccessFile)1 Buffer (java.nio.Buffer)1 HashMap (java.util.HashMap)1 CalledByNative (org.chromium.base.CalledByNative)1