mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Fix packet type for legacy controller packets and privatize some constants to prevent this bug from happening again
This commit is contained in:
parent
51343a171d
commit
ec39f22ad8
@ -13,11 +13,10 @@ import com.limelight.nvstream.av.RtpPacket;
|
||||
import com.limelight.nvstream.av.RtpReorderQueue;
|
||||
|
||||
public class AudioStream {
|
||||
public static final int RTP_PORT = 48000;
|
||||
public static final int RTCP_PORT = 47999;
|
||||
private static final int RTP_PORT = 48000;
|
||||
|
||||
public static final int RTP_RECV_BUFFER = 64 * 1024;
|
||||
public static final int MAX_PACKET_SIZE = 100;
|
||||
private static final int RTP_RECV_BUFFER = 64 * 1024;
|
||||
private static final int MAX_PACKET_SIZE = 100;
|
||||
|
||||
private DatagramSocket rtp;
|
||||
|
||||
|
@ -15,22 +15,21 @@ import com.limelight.nvstream.av.RtpPacket;
|
||||
import com.limelight.nvstream.av.RtpReorderQueue;
|
||||
|
||||
public class VideoStream {
|
||||
public static final int RTP_PORT = 47998;
|
||||
public static final int RTCP_PORT = 47999;
|
||||
public static final int FIRST_FRAME_PORT = 47996;
|
||||
private static final int RTP_PORT = 47998;
|
||||
private static final int FIRST_FRAME_PORT = 47996;
|
||||
|
||||
public static final int FIRST_FRAME_TIMEOUT = 5000;
|
||||
public static final int RTP_RECV_BUFFER = 256 * 1024;
|
||||
private static final int FIRST_FRAME_TIMEOUT = 5000;
|
||||
private static final int RTP_RECV_BUFFER = 256 * 1024;
|
||||
|
||||
// We can't request an IDR frame until the depacketizer knows
|
||||
// that a packet was lost. This timeout bounds the time that
|
||||
// the RTP queue will wait for missing/reordered packets.
|
||||
public static final int MAX_RTP_QUEUE_DELAY_MS = 10;
|
||||
private static final int MAX_RTP_QUEUE_DELAY_MS = 10;
|
||||
|
||||
// The ring size MUST be greater than or equal to
|
||||
// the maximum number of packets in a fully
|
||||
// presentable frame
|
||||
public static final int VIDEO_RING_SIZE = 384;
|
||||
private static final int VIDEO_RING_SIZE = 384;
|
||||
|
||||
private DatagramSocket rtp;
|
||||
private Socket firstFrameSocket;
|
||||
|
@ -15,9 +15,9 @@ import com.limelight.nvstream.av.ConnectionStatusListener;
|
||||
|
||||
public class ControlStream implements ConnectionStatusListener {
|
||||
|
||||
public static final int PORT = 47995;
|
||||
private static final int PORT = 47995;
|
||||
|
||||
public static final int CONTROL_TIMEOUT = 5000;
|
||||
private static final int CONTROL_TIMEOUT = 5000;
|
||||
|
||||
private static final int IDX_START_A = 0;
|
||||
private static final int IDX_START_B = 1;
|
||||
|
@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class ControllerPacket extends MultiControllerPacket {
|
||||
public static final byte[] HEADER =
|
||||
private static final byte[] HEADER =
|
||||
{
|
||||
0x0A,
|
||||
0x00,
|
||||
@ -14,7 +14,7 @@ public class ControllerPacket extends MultiControllerPacket {
|
||||
0x14
|
||||
};
|
||||
|
||||
public static final byte[] TAIL =
|
||||
private static final byte[] TAIL =
|
||||
{
|
||||
(byte)0x9C,
|
||||
0x00,
|
||||
@ -24,7 +24,7 @@ public class ControllerPacket extends MultiControllerPacket {
|
||||
0x00
|
||||
};
|
||||
|
||||
public static final int PACKET_TYPE = 0x18;
|
||||
private static final int PACKET_TYPE = 0x18;
|
||||
|
||||
public static final short A_FLAG = 0x1000;
|
||||
public static final short B_FLAG = 0x2000;
|
||||
@ -42,15 +42,15 @@ public class ControllerPacket extends MultiControllerPacket {
|
||||
public static final short RS_CLK_FLAG = 0x0080;
|
||||
public static final short SPECIAL_BUTTON_FLAG = 0x0400;
|
||||
|
||||
public static final short PAYLOAD_LENGTH = 24;
|
||||
public static final short PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
private static final short PAYLOAD_LENGTH = 24;
|
||||
private static final short PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
InputPacket.HEADER_LENGTH;
|
||||
|
||||
public ControllerPacket(short buttonFlags, byte leftTrigger, byte rightTrigger,
|
||||
short leftStickX, short leftStickY,
|
||||
short rightStickX, short rightStickY)
|
||||
{
|
||||
super((short) 0, buttonFlags, leftTrigger, rightTrigger, leftStickX,
|
||||
super(PACKET_TYPE, (short) 0, buttonFlags, leftTrigger, rightTrigger, leftStickX,
|
||||
leftStickY, rightStickX, rightStickY);
|
||||
|
||||
this.buttonFlags = buttonFlags;
|
||||
|
@ -20,9 +20,9 @@ import com.limelight.nvstream.ConnectionContext;
|
||||
|
||||
public class ControllerStream {
|
||||
|
||||
public final static int PORT = 35043;
|
||||
private final static int PORT = 35043;
|
||||
|
||||
public final static int CONTROLLER_TIMEOUT = 3000;
|
||||
private final static int CONTROLLER_TIMEOUT = 3000;
|
||||
|
||||
private ConnectionContext context;
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.nio.ByteOrder;
|
||||
|
||||
public class KeyboardPacket extends InputPacket {
|
||||
private static final int PACKET_TYPE = 0x0A;
|
||||
public static final int PACKET_LENGTH = 14;
|
||||
private static final int PACKET_LENGTH = 14;
|
||||
|
||||
public static final byte KEY_DOWN = 0x03;
|
||||
public static final byte KEY_UP = 0x04;
|
||||
|
@ -8,13 +8,13 @@ public class MouseButtonPacket extends InputPacket {
|
||||
byte buttonEventType;
|
||||
byte mouseButton;
|
||||
|
||||
public static final int PACKET_TYPE = 0x5;
|
||||
public static final int PAYLOAD_LENGTH = 5;
|
||||
public static final int PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
private static final int PACKET_TYPE = 0x5;
|
||||
private static final int PAYLOAD_LENGTH = 5;
|
||||
private static final int PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
InputPacket.HEADER_LENGTH;
|
||||
|
||||
public static final byte PRESS_EVENT = 0x07;
|
||||
public static final byte RELEASE_EVENT = 0x08;
|
||||
private static final byte PRESS_EVENT = 0x07;
|
||||
private static final byte RELEASE_EVENT = 0x08;
|
||||
|
||||
public static final byte BUTTON_LEFT = 0x01;
|
||||
public static final byte BUTTON_MIDDLE = 0x02;
|
||||
|
@ -4,9 +4,9 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class MouseScrollPacket extends InputPacket {
|
||||
public static final int PACKET_TYPE = 0xa;
|
||||
public static final int PAYLOAD_LENGTH = 10;
|
||||
public static final int PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
private static final int PACKET_TYPE = 0xa;
|
||||
private static final int PAYLOAD_LENGTH = 10;
|
||||
private static final int PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
InputPacket.HEADER_LENGTH;
|
||||
|
||||
short scroll;
|
||||
|
@ -4,7 +4,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class MultiControllerPacket extends InputPacket {
|
||||
public static final byte[] TAIL =
|
||||
private static final byte[] TAIL =
|
||||
{
|
||||
(byte)0x9C,
|
||||
0x00,
|
||||
@ -14,10 +14,10 @@ public class MultiControllerPacket extends InputPacket {
|
||||
0x00
|
||||
};
|
||||
|
||||
public static final int PACKET_TYPE = 0x1e;
|
||||
private static final int PACKET_TYPE = 0x1e;
|
||||
|
||||
public static final short PAYLOAD_LENGTH = 30;
|
||||
public static final short PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
private static final short PAYLOAD_LENGTH = 30;
|
||||
private static final short PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
InputPacket.HEADER_LENGTH;
|
||||
|
||||
short controllerNumber;
|
||||
@ -47,6 +47,27 @@ public class MultiControllerPacket extends InputPacket {
|
||||
this.rightStickX = rightStickX;
|
||||
this.rightStickY = rightStickY;
|
||||
}
|
||||
|
||||
public MultiControllerPacket(int packetType,
|
||||
short controllerNumber, short buttonFlags,
|
||||
byte leftTrigger, byte rightTrigger,
|
||||
short leftStickX, short leftStickY,
|
||||
short rightStickX, short rightStickY)
|
||||
{
|
||||
super(packetType);
|
||||
|
||||
this.controllerNumber = controllerNumber;
|
||||
|
||||
this.buttonFlags = buttonFlags;
|
||||
this.leftTrigger = leftTrigger;
|
||||
this.rightTrigger = rightTrigger;
|
||||
|
||||
this.leftStickX = leftStickX;
|
||||
this.leftStickY = leftStickY;
|
||||
|
||||
this.rightStickX = rightStickX;
|
||||
this.rightStickY = rightStickY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toWirePayload(ByteBuffer bb) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user