当前位置: 首页>>代码示例>>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;未经允许,请勿转载。