当前位置: 首页>>代码示例>>Java>>正文


Java MediaCodec.BUFFER_FLAG_KEY_FRAME属性代码示例

本文整理汇总了Java中android.media.MediaCodec.BUFFER_FLAG_KEY_FRAME属性的典型用法代码示例。如果您正苦于以下问题:Java MediaCodec.BUFFER_FLAG_KEY_FRAME属性的具体用法?Java MediaCodec.BUFFER_FLAG_KEY_FRAME怎么用?Java MediaCodec.BUFFER_FLAG_KEY_FRAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.MediaCodec的用法示例。


在下文中一共展示了MediaCodec.BUFFER_FLAG_KEY_FRAME属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: output

@Override
    protected void output(int outputBufIndex, MediaCodec.BufferInfo bufferInfo) {
        if (mMediaCodec == null) return;
//        Log.d(TAG, "Presentation: " + mBufferInfo.presentationTimeUs);
//        Log.d(TAG, "Now: " + System.nanoTime());
        if (mState != STATE_SEEKING)
            mStartTime = adjustPresentationTime(mStartTime, (long) ((double) bufferInfo.presentationTimeUs / mWeakPlayer.get().getPlayRate()));
        if (mState != STATE_SEEKING) {
            mMediaCodec.releaseOutputBuffer(outputBufIndex, true);
        } else {
            boolean isSyncFrame = (bufferInfo.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0;
            long presentationTimeDiff = mSeekTargetTime - bufferInfo.presentationTimeUs;
            Log.d(TAG, "time diff: " + presentationTimeDiff);
            boolean isCloseEnoughToTargetTime = (Math.abs(presentationTimeDiff) < CLOSE_ENOUGH_TIME);
            if (isSyncFrame) {
                synchronized (mDecoderSync) {
                    mLastSyncFrameTime = bufferInfo.presentationTimeUs;
                    mDecoderSync.notify();
                }
            }
            if (isCloseEnoughToTargetTime) {
                mMediaCodec.releaseOutputBuffer(outputBufIndex, true);
                if (mSeekDirection == SEEK_DIRECTION_BACKWARD)
                    Log.d(TAG, "backward render at: " + bufferInfo.presentationTimeUs + " target at: " + mSeekTargetTime);
                synchronized (mDecoderSync) {
                    if (isSyncFrame) {
                        mLastSyncFrameTime = bufferInfo.presentationTimeUs;
                    }
                    if (isCloseEnoughToTargetTime) {
                        Log.d(TAG, "close enough to direction " + mSeekDirection);
                        mIsSeeking = false;
                    }
                    mDecoderSync.notify();
                }
            } else {
                mMediaCodec.releaseOutputBuffer(outputBufIndex, false);
            }
        }
    }
 
开发者ID:Tai-Kimura,项目名称:VideoApplication,代码行数:39,代码来源:VideoDecoder.java

示例2: getH264Data

@Override
public void getH264Data(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
  if (recording) {
    if (info.flags == MediaCodec.BUFFER_FLAG_KEY_FRAME) canRecord = true;
    if (canRecord) {
      mediaMuxer.writeSampleData(videoTrack, h264Buffer, info);
    }
  }
  getH264DataRtp(h264Buffer, info);
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:10,代码来源:DisplayBase.java

示例3: getH264Data

@Override
public void getH264Data(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
  if (recording && videoTrack != -1) {
    if (info.flags == MediaCodec.BUFFER_FLAG_KEY_FRAME) canRecord = true;
    if (canRecord) {
      mediaMuxer.writeSampleData(videoTrack, h264Buffer, info);
    }
  }
  getH264DataRtp(h264Buffer, info);
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:10,代码来源:Camera2Base.java

示例4: getH264Data

@Override
public void getH264Data(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
      && recording
      && videoTrack != -1) {
    if (info.flags == MediaCodec.BUFFER_FLAG_KEY_FRAME) canRecord = true;
    if (canRecord) {
      mediaMuxer.writeSampleData(videoTrack, h264Buffer, info);
    }
  }
  getH264DataRtp(h264Buffer, info);
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:12,代码来源:Camera1Base.java


注:本文中的android.media.MediaCodec.BUFFER_FLAG_KEY_FRAME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。