mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Only set hadKeyframe flag to true if we end up muxing the frame.
If we throw away the first keyframe (because it does not contain any bytes to read), we shouldn't behave as if we had written a keyframe to our track. We should instead continue waiting for the first (valid) keyframe. PiperOrigin-RevId: 554579146
This commit is contained in:
parent
f43146718c
commit
7d6f02dc50
@ -364,6 +364,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeSampleData(ByteBuffer byteBuffer, BufferInfo bufferInfo) throws IOException {
|
public void writeSampleData(ByteBuffer byteBuffer, BufferInfo bufferInfo) throws IOException {
|
||||||
|
// TODO: b/279931840 - Confirm whether muxer should throw when writing empty samples.
|
||||||
|
// Skip empty samples.
|
||||||
|
if (bufferInfo.size == 0 || byteBuffer.remaining() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) > 0) {
|
if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) > 0) {
|
||||||
hadKeyframe = true;
|
hadKeyframe = true;
|
||||||
}
|
}
|
||||||
@ -372,17 +378,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufferInfo.size == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip empty samples.
|
|
||||||
// TODO: b/279931840 - Confirm whether muxer should throw when writing empty samples.
|
|
||||||
if (byteBuffer.remaining() > 0) {
|
|
||||||
pendingSamples.addLast(Pair.create(bufferInfo, byteBuffer));
|
pendingSamples.addLast(Pair.create(bufferInfo, byteBuffer));
|
||||||
doInterleave();
|
doInterleave();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int videoUnitTimebase() {
|
public int videoUnitTimebase() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user