mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Use packet flags to determine where frames end and begin instead of the packet index
This commit is contained in:
parent
c93812179f
commit
a96de39b28
@ -14,7 +14,6 @@ public class VideoDepacketizer {
|
|||||||
private LinkedList<ByteBufferDescriptor> avcNalDataChain = null;
|
private LinkedList<ByteBufferDescriptor> avcNalDataChain = null;
|
||||||
private int avcNalDataLength = 0;
|
private int avcNalDataLength = 0;
|
||||||
private int currentlyDecoding = DecodeUnit.TYPE_UNKNOWN;
|
private int currentlyDecoding = DecodeUnit.TYPE_UNKNOWN;
|
||||||
private boolean splitFrame = false;
|
|
||||||
|
|
||||||
// Sequencing state
|
// Sequencing state
|
||||||
private short lastSequenceNumber;
|
private short lastSequenceNumber;
|
||||||
@ -175,13 +174,7 @@ public class VideoDepacketizer {
|
|||||||
// Remove extra padding
|
// Remove extra padding
|
||||||
location.length = packet.getPayloadLength();
|
location.length = packet.getPayloadLength();
|
||||||
|
|
||||||
boolean firstPacket = !splitFrame && packetIndex == 0;
|
boolean firstPacket = (packet.getFlags() & VideoPacket.FLAG_SOF) != 0;
|
||||||
|
|
||||||
// Reset split frame state on next frame start
|
|
||||||
if (packetIndex == 0) {
|
|
||||||
splitFrame = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstPacket)
|
if (firstPacket)
|
||||||
{
|
{
|
||||||
if (NAL.getSpecialSequenceDescriptor(location, cachedDesc) && NAL.isAvcFrameStart(cachedDesc)
|
if (NAL.getSpecialSequenceDescriptor(location, cachedDesc) && NAL.isAvcFrameStart(cachedDesc)
|
||||||
@ -195,11 +188,7 @@ public class VideoDepacketizer {
|
|||||||
|
|
||||||
addInputDataFast(packet, location, firstPacket);
|
addInputDataFast(packet, location, firstPacket);
|
||||||
|
|
||||||
if (!splitFrame && packetIndex + 1 == packetsInFrame) {
|
if ((packet.getFlags() & VideoPacket.FLAG_EOF) != 0) {
|
||||||
// Reassemble the frame if this was the last packet and it's not a split frame
|
|
||||||
if (packet.getPayloadLength() == 968)
|
|
||||||
splitFrame = true;
|
|
||||||
else
|
|
||||||
reassembleAvcNal();
|
reassembleAvcNal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ public class VideoPacket {
|
|||||||
private int packetIndex;
|
private int packetIndex;
|
||||||
private int totalPackets;
|
private int totalPackets;
|
||||||
private int payloadLength;
|
private int payloadLength;
|
||||||
|
private int flags;
|
||||||
|
|
||||||
|
public static final int FLAG_EOF = 0x2;
|
||||||
|
public static final int FLAG_SOF = 0x4;
|
||||||
|
|
||||||
public VideoPacket(ByteBufferDescriptor rtpPayload)
|
public VideoPacket(ByteBufferDescriptor rtpPayload)
|
||||||
{
|
{
|
||||||
@ -23,12 +27,15 @@ public class VideoPacket {
|
|||||||
frameIndex = bb.getInt();
|
frameIndex = bb.getInt();
|
||||||
packetIndex = bb.getInt();
|
packetIndex = bb.getInt();
|
||||||
totalPackets = bb.getInt();
|
totalPackets = bb.getInt();
|
||||||
|
flags = bb.getInt();
|
||||||
bb.position(bb.position()+4);
|
|
||||||
|
|
||||||
payloadLength = bb.getInt();
|
payloadLength = bb.getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFlags()
|
||||||
|
{
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
public int getFrameIndex()
|
public int getFrameIndex()
|
||||||
{
|
{
|
||||||
return frameIndex;
|
return frameIndex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user