本文整理匯總了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);
}
}
}
示例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);
}
示例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);
}
示例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);
}