當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。