mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
refine log and function api
This commit is contained in:
parent
a86653b0c0
commit
d3a74b8e8b
3 changed files with 19 additions and 22 deletions
|
@ -180,11 +180,10 @@ public final class ControlMessage {
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for udt
|
||||||
public static final int TYPE_REQ_IDR = 100;
|
public static final int TYPE_REQ_IDR = 100;
|
||||||
public static final int TYPE_SET_BITRATE = 101;
|
public static final int TYPE_SET_BITRATE = 101;
|
||||||
|
|
||||||
private int bitRate;
|
private int bitRate;
|
||||||
|
|
||||||
public int getBitRate() {
|
public int getBitRate() {
|
||||||
return bitRate;
|
return bitRate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,12 +53,13 @@ public class ControlMessageReader {
|
||||||
}
|
}
|
||||||
int savedPosition = buffer.position();
|
int savedPosition = buffer.position();
|
||||||
|
|
||||||
int type = buffer.get();
|
byte _type = buffer.get();
|
||||||
|
int type = (int) _type;
|
||||||
ControlMessage msg;
|
ControlMessage msg;
|
||||||
|
|
||||||
msg = preParseMsg(type);
|
Ln.i("receiving msg, type:" + String.format("0x%02x", _type) + " pos:" + buffer.position());
|
||||||
|
msg = parseUdtEvent(type);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
Ln.i("pre parsed msg: " + msg.getType());
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,13 +221,13 @@ public class ControlMessageReader {
|
||||||
|
|
||||||
static final int SET_BITRATE_LENGTH = 4;
|
static final int SET_BITRATE_LENGTH = 4;
|
||||||
|
|
||||||
private ControlMessage preParseMsg(int type) {
|
private ControlMessage parseUdtEvent(int type) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case ControlMessage.TYPE_REQ_IDR:
|
case ControlMessage.TYPE_REQ_IDR:
|
||||||
Ln.v("pre get msg TYPE_REQ_IDR event");
|
Ln.v("udt: event: TYPE_REQ_IDR");
|
||||||
return ControlMessage.createEmpty(type);
|
return ControlMessage.createEmpty(type);
|
||||||
case ControlMessage.TYPE_SET_BITRATE:
|
case ControlMessage.TYPE_SET_BITRATE:
|
||||||
Ln.v("pre get msg TYPE_SET_BITRATE event" );
|
Ln.v("udt: event: TYPE_SET_BITRATE");
|
||||||
return parseSetBitrate();
|
return parseSetBitrate();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -80,10 +80,10 @@ public class Controller {
|
||||||
|
|
||||||
private void handleEvent() throws IOException {
|
private void handleEvent() throws IOException {
|
||||||
ControlMessage msg = connection.receiveControlMessage();
|
ControlMessage msg = connection.receiveControlMessage();
|
||||||
if (preHandlerEvent(msg)) {
|
if (handleUdtEvent(msg)) {
|
||||||
Ln.i("pre handled event: " + msg.getType());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (msg.getType()) {
|
switch (msg.getType()) {
|
||||||
case ControlMessage.TYPE_INJECT_KEYCODE:
|
case ControlMessage.TYPE_INJECT_KEYCODE:
|
||||||
if (device.supportsInputEvents()) {
|
if (device.supportsInputEvents()) {
|
||||||
|
@ -317,22 +317,19 @@ public class Controller {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean preHandlerEvent(ControlMessage msg) {
|
private boolean handleUdtEvent(ControlMessage msg) {
|
||||||
boolean handled = true;
|
|
||||||
switch (msg.getType()) {
|
switch (msg.getType()) {
|
||||||
case ControlMessage.TYPE_REQ_IDR:
|
case ControlMessage.TYPE_REQ_IDR:
|
||||||
Ln.i("Device ControlMessage.TYPE_REQ_IDR ");
|
Ln.i("udt: handle ControlMessage.TYPE_REQ_IDR");
|
||||||
device.reqIDRFrame();
|
device.reqIDRFrame();
|
||||||
break;
|
return true;
|
||||||
case ControlMessage.TYPE_SET_BITRATE:
|
case ControlMessage.TYPE_SET_BITRATE:
|
||||||
int bitrate = msg.getBitRate();
|
int bitrate = msg.getBitRate();
|
||||||
Ln.i("Device ControlMessage.TYPE_SET_BITRATE ");
|
Ln.i("udt: handle ControlMessage.TYPE_SET_BITRATE: " + bitrate);
|
||||||
device.setBitRate(bitrate);
|
device.setBitRate(bitrate);
|
||||||
break;
|
return true;
|
||||||
default:
|
default:
|
||||||
handled = false;
|
return false;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
return handled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue