mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-24 01:06:39 +00:00
Allow configuration of maximum packet size
This commit is contained in:
@@ -29,13 +29,15 @@ public class VideoDepacketizer {
|
||||
private ByteBufferDescriptor cachedSpecialDesc = new ByteBufferDescriptor(null, 0, 0);
|
||||
|
||||
private ConnectionStatusListener controlListener;
|
||||
private int nominalPacketSize;
|
||||
|
||||
private static final int DU_LIMIT = 15;
|
||||
private LinkedBlockingQueue<DecodeUnit> decodedUnits = new LinkedBlockingQueue<DecodeUnit>(DU_LIMIT);
|
||||
|
||||
public VideoDepacketizer(ConnectionStatusListener controlListener)
|
||||
public VideoDepacketizer(ConnectionStatusListener controlListener, int nominalPacketSize)
|
||||
{
|
||||
this.controlListener = controlListener;
|
||||
this.nominalPacketSize = nominalPacketSize;
|
||||
}
|
||||
|
||||
private void clearAvcFrameState()
|
||||
@@ -175,7 +177,7 @@ public class VideoDepacketizer {
|
||||
// Runt packets get decoded using the slow path
|
||||
// These packets stand alone so there's no need to verify
|
||||
// sequencing before submitting
|
||||
if (cachedReassemblyDesc.length < 968) {
|
||||
if (cachedReassemblyDesc.length < nominalPacketSize - VideoPacket.HEADER_SIZE) {
|
||||
addInputDataSlow(packet, cachedReassemblyDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public class VideoPacket {
|
||||
public static final int FLAG_EOF = 0x2;
|
||||
public static final int FLAG_SOF = 0x4;
|
||||
|
||||
public static final int HEADER_SIZE = 56;
|
||||
|
||||
public VideoPacket(byte[] buffer)
|
||||
{
|
||||
this.buffer = new ByteBufferDescriptor(buffer, 0, buffer.length);
|
||||
@@ -39,7 +41,7 @@ public class VideoPacket {
|
||||
streamPacketIndex = byteBuffer.getInt();
|
||||
|
||||
// Data offset without the RTP header
|
||||
dataOffset = 56;
|
||||
dataOffset = HEADER_SIZE;
|
||||
|
||||
// Update descriptor length
|
||||
buffer.length = length;
|
||||
@@ -59,7 +61,7 @@ public class VideoPacket {
|
||||
streamPacketIndex = byteBuffer.getInt();
|
||||
|
||||
// Data offset includes the RTP header
|
||||
dataOffset = RtpPacket.HEADER_SIZE + 56;
|
||||
dataOffset = RtpPacket.HEADER_SIZE + HEADER_SIZE;
|
||||
|
||||
// Update descriptor length
|
||||
buffer.length = length;
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.LinkedList;
|
||||
import com.limelight.nvstream.NvConnectionListener;
|
||||
import com.limelight.nvstream.StreamConfiguration;
|
||||
import com.limelight.nvstream.av.ConnectionStatusListener;
|
||||
import com.limelight.nvstream.av.RtpPacket;
|
||||
|
||||
public class VideoStream {
|
||||
public static final int RTP_PORT = 47998;
|
||||
@@ -22,8 +23,6 @@ public class VideoStream {
|
||||
public static final int FIRST_FRAME_TIMEOUT = 5000;
|
||||
public static final int RTP_RECV_BUFFER = 256 * 1024;
|
||||
|
||||
public static final int MAX_PACKET_SIZE = 1050;
|
||||
|
||||
// The ring size MUST be greater than or equal to
|
||||
// the maximum number of packets in a fully
|
||||
// presentable frame
|
||||
@@ -96,7 +95,7 @@ public class VideoStream {
|
||||
|
||||
private void readFirstFrame() throws IOException
|
||||
{
|
||||
byte[] firstFrame = new byte[MAX_PACKET_SIZE];
|
||||
byte[] firstFrame = new byte[streamConfig.getMaxPacketSize()];
|
||||
|
||||
firstFrameSocket = new Socket();
|
||||
firstFrameSocket.setSoTimeout(FIRST_FRAME_TIMEOUT);
|
||||
@@ -139,7 +138,7 @@ public class VideoStream {
|
||||
decRend.setup(streamConfig.getWidth(), streamConfig.getHeight(),
|
||||
60, renderTarget, drFlags);
|
||||
|
||||
depacketizer = new VideoDepacketizer(avConnListener);
|
||||
depacketizer = new VideoDepacketizer(avConnListener, streamConfig.getMaxPacketSize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,8 +182,9 @@ public class VideoStream {
|
||||
int ringIndex = 0;
|
||||
|
||||
// Preinitialize the ring buffer
|
||||
int requiredBufferSize = streamConfig.getMaxPacketSize() + RtpPacket.HEADER_SIZE;
|
||||
for (int i = 0; i < VIDEO_RING_SIZE; i++) {
|
||||
ring[i] = new VideoPacket(new byte[MAX_PACKET_SIZE]);
|
||||
ring[i] = new VideoPacket(new byte[requiredBufferSize]);
|
||||
}
|
||||
|
||||
byte[] buffer;
|
||||
|
||||
Reference in New Issue
Block a user