mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-09-04 08:35:44 +00:00
Pass key frame flag from the device
MediaCodec indicates when a packet is a key frame. Transmit it to the client.
This commit is contained in:
parent
e3c2398aa2
commit
67068e4e3d
2 changed files with 15 additions and 5 deletions
|
@ -29,6 +29,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||
private static final int[] MAX_SIZE_FALLBACK = {2560, 1920, 1600, 1280, 1024, 800};
|
||||
|
||||
private static final long PACKET_FLAG_CONFIG = 1L << 63;
|
||||
private static final long PACKET_FLAG_KEY_FRAME = 1L << 62;
|
||||
|
||||
private final AtomicBoolean rotationChanged = new AtomicBoolean();
|
||||
private final ByteBuffer headerBuffer = ByteBuffer.allocate(12);
|
||||
|
@ -189,6 +190,9 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||
ptsOrigin = bufferInfo.presentationTimeUs;
|
||||
}
|
||||
pts = bufferInfo.presentationTimeUs - ptsOrigin;
|
||||
if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0) {
|
||||
pts |= PACKET_FLAG_KEY_FRAME;
|
||||
}
|
||||
}
|
||||
|
||||
headerBuffer.putLong(pts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue