當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaCodec.getInputBuffer方法代碼示例

本文整理匯總了Java中android.media.MediaCodec.getInputBuffer方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaCodec.getInputBuffer方法的具體用法?Java MediaCodec.getInputBuffer怎麽用?Java MediaCodec.getInputBuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.MediaCodec的用法示例。


在下文中一共展示了MediaCodec.getInputBuffer方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getInputBuffer

import android.media.MediaCodec; //導入方法依賴的package包/類
private ByteBuffer getInputBuffer(MediaCodec codec, int index){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return codec.getInputBuffer(index);
    }else{
        return codec.getInputBuffers()[index];
    }
}
 
開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:8,代碼來源:Mp4Processor.java

示例2: getInputBuffer

import android.media.MediaCodec; //導入方法依賴的package包/類
public static ByteBuffer getInputBuffer(MediaCodec codec, int index){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return codec.getInputBuffer(index);
    }else{
        return codec.getInputBuffers()[index];
    }
}
 
開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:8,代碼來源:CodecUtil.java

示例3: queueInputBuffer

import android.media.MediaCodec; //導入方法依賴的package包/類
private int queueInputBuffer(MediaCodec codec, int inputBufferId) throws IOException {
    ByteBuffer inputBuffer = codec.getInputBuffer(inputBufferId);
    inputBuffer.clear();

    int bytesAvailable = audioRecorderInputStream.available();
    int bytesRead = bytesAvailable < inputBuffer.limit() ? bytesAvailable : inputBuffer.limit();
    byte[] audioRecorderBytes = new byte[bytesRead];
    audioRecorderInputStream.read(audioRecorderBytes);
    inputBuffer.put(audioRecorderBytes);
    codec.queueInputBuffer(inputBufferId, 0, bytesRead, 0, 0);
    return bytesRead;
}
 
開發者ID:aschober,項目名稱:vinyl-cast,代碼行數:13,代碼來源:ConvertAudioTask.java

示例4: getInputBuffer

import android.media.MediaCodec; //導入方法依賴的package包/類
private ByteBuffer getInputBuffer(MediaCodec codec, int bufferIndex) {
    ByteBuffer buffer;

    if (Build.VERSION.SDK_INT < 21) {
        buffer = codec.getInputBuffers()[bufferIndex];
        buffer.clear();
    } else {
        buffer = codec.getInputBuffer(bufferIndex);
    }

    return buffer;
}
 
開發者ID:ficklerobot,項目名稱:grid-video-viewer,代碼行數:13,代碼來源:DecodeThread.java

示例5: getInputBuffer

import android.media.MediaCodec; //導入方法依賴的package包/類
/**
 * 防止出現 http://stackoverflow.com/q/30646885 的問題
 *
 * @param codec
 * @param index
 * @return
 */
public static ByteBuffer getInputBuffer(MediaCodec codec, int index) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return codec.getInputBuffer(index);
    } else {
        return codec.getInputBuffers()[index];
    }
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:15,代碼來源:MediaUtil.java

示例6: renderHevcImage

import android.media.MediaCodec; //導入方法依賴的package包/類
private static void renderHevcImage(ByteBuffer bitstream, ImageInfo info, Surface surface) {
    long beginTime = SystemClock.elapsedRealtimeNanos();

    // configure HEVC decoder
    MediaCodec decoder = configureDecoder(info, bitstream.limit(), surface);
    MediaFormat outputFormat = decoder.getOutputFormat();
    Log.d(TAG, "HEVC output-format=" + outputFormat);

    decoder.start();
    try {
        // set bitstream to decoder
        int inputBufferId = decoder.dequeueInputBuffer(-1);
        if (inputBufferId < 0) {
            throw new IllegalStateException("dequeueInputBuffer return " + inputBufferId);
        }
        ByteBuffer inBuffer = decoder.getInputBuffer(inputBufferId);
        inBuffer.put(bitstream);
        decoder.queueInputBuffer(inputBufferId, 0, bitstream.limit(), 0, 0);

        // notify end of stream
        inputBufferId = decoder.dequeueInputBuffer(-1);
        if (inputBufferId < 0) {
            throw new IllegalStateException("dequeueInputBuffer return " + inputBufferId);
        }
        decoder.queueInputBuffer(inputBufferId, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);

        // get decoded image
        MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
        while (true) {
            int outputBufferId = decoder.dequeueOutputBuffer(bufferInfo, -1);
            if (outputBufferId >= 0) {
                decoder.releaseOutputBuffer(outputBufferId, true);
                break;
            } else if (outputBufferId == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
                outputFormat = decoder.getOutputFormat();
                Log.d(TAG, "HEVC output-format=" + outputFormat);
            } else {
                Log.d(TAG, "HEVC dequeueOutputBuffer return " + outputBufferId);
            }
        }
        decoder.flush();
    } finally {
        decoder.stop();
        decoder.release();
    }
    long endTime = SystemClock.elapsedRealtimeNanos();
    Log.i(TAG, "HEVC decoding elapsed=" + (endTime - beginTime) / 1000000.f + "[msec]");
}
 
開發者ID:yohhoy,項目名稱:heifreader,代碼行數:49,代碼來源:HeifReader.java


注:本文中的android.media.MediaCodec.getInputBuffer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。