mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Slightly reduce memory/GC pressure by using a smaller per-packet buffer of 1050 bytes instead of 1500 bytes
This commit is contained in:
parent
3af3df0544
commit
239dffcbdf
@ -24,6 +24,7 @@ public class VideoStream {
|
|||||||
|
|
||||||
public static final int FIRST_FRAME_TIMEOUT = 5000;
|
public static final int FIRST_FRAME_TIMEOUT = 5000;
|
||||||
public static final int RTP_RECV_BUFFER = 128 * 1024;
|
public static final int RTP_RECV_BUFFER = 128 * 1024;
|
||||||
|
public static final int MAX_PACKET_SIZE = 1050;
|
||||||
|
|
||||||
private InetAddress host;
|
private InetAddress host;
|
||||||
private DatagramSocket rtp;
|
private DatagramSocket rtp;
|
||||||
@ -92,7 +93,7 @@ public class VideoStream {
|
|||||||
|
|
||||||
private void readFirstFrame() throws IOException
|
private void readFirstFrame() throws IOException
|
||||||
{
|
{
|
||||||
byte[] firstFrame = new byte[1500];
|
byte[] firstFrame = new byte[MAX_PACKET_SIZE];
|
||||||
|
|
||||||
firstFrameSocket = new Socket();
|
firstFrameSocket = new Socket();
|
||||||
firstFrameSocket.setSoTimeout(FIRST_FRAME_TIMEOUT);
|
firstFrameSocket.setSoTimeout(FIRST_FRAME_TIMEOUT);
|
||||||
@ -210,7 +211,7 @@ public class VideoStream {
|
|||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ByteBufferDescriptor desc = new ByteBufferDescriptor(new byte[1500], 0, 1500);
|
ByteBufferDescriptor desc = new ByteBufferDescriptor(new byte[MAX_PACKET_SIZE], 0, MAX_PACKET_SIZE);
|
||||||
DatagramPacket packet = new DatagramPacket(desc.data, desc.length);
|
DatagramPacket packet = new DatagramPacket(desc.data, desc.length);
|
||||||
|
|
||||||
while (!isInterrupted())
|
while (!isInterrupted())
|
||||||
@ -219,7 +220,7 @@ public class VideoStream {
|
|||||||
rtp.receive(packet);
|
rtp.receive(packet);
|
||||||
desc.length = packet.getLength();
|
desc.length = packet.getLength();
|
||||||
depacketizer.addInputData(new RtpPacket(desc));
|
depacketizer.addInputData(new RtpPacket(desc));
|
||||||
desc.reinitialize(new byte[1500], 0, 1500);
|
desc.reinitialize(new byte[MAX_PACKET_SIZE], 0, MAX_PACKET_SIZE);
|
||||||
packet.setData(desc.data, desc.offset, desc.length);
|
packet.setData(desc.data, desc.offset, desc.length);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
listener.connectionTerminated(e);
|
listener.connectionTerminated(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user