本文整理汇总了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);
}