mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-21 20:15:05 +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;
|
||||
}
|
||||
|
||||
// for udt
|
||||
public static final int TYPE_REQ_IDR = 100;
|
||||
public static final int TYPE_SET_BITRATE = 101;
|
||||
|
||||
private int bitRate;
|
||||
|
||||
public int getBitRate() {
|
||||
return bitRate;
|
||||
}
|
||||
|
|
|
@ -53,13 +53,14 @@ public class ControlMessageReader {
|
|||
}
|
||||
int savedPosition = buffer.position();
|
||||
|
||||
int type = buffer.get();
|
||||
byte _type = buffer.get();
|
||||
int type = (int) _type;
|
||||
ControlMessage msg;
|
||||
|
||||
msg = preParseMsg(type);
|
||||
if (msg != null) {
|
||||
Ln.i("pre parsed msg: " + msg.getType());
|
||||
return msg;
|
||||
Ln.i("receiving msg, type:" + String.format("0x%02x", _type) + " pos:" + buffer.position());
|
||||
msg = parseUdtEvent(type);
|
||||
if (msg != null) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
@ -220,13 +221,13 @@ public class ControlMessageReader {
|
|||
|
||||
static final int SET_BITRATE_LENGTH = 4;
|
||||
|
||||
private ControlMessage preParseMsg(int type) {
|
||||
private ControlMessage parseUdtEvent(int type) {
|
||||
switch(type) {
|
||||
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);
|
||||
case ControlMessage.TYPE_SET_BITRATE:
|
||||
Ln.v("pre get msg TYPE_SET_BITRATE event" );
|
||||
Ln.v("udt: event: TYPE_SET_BITRATE");
|
||||
return parseSetBitrate();
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -80,10 +80,10 @@ public class Controller {
|
|||
|
||||
private void handleEvent() throws IOException {
|
||||
ControlMessage msg = connection.receiveControlMessage();
|
||||
if (preHandlerEvent(msg)) {
|
||||
Ln.i("pre handled event: " + msg.getType());
|
||||
if (handleUdtEvent(msg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg.getType()) {
|
||||
case ControlMessage.TYPE_INJECT_KEYCODE:
|
||||
if (device.supportsInputEvents()) {
|
||||
|
@ -317,22 +317,19 @@ public class Controller {
|
|||
return ok;
|
||||
}
|
||||
|
||||
private boolean preHandlerEvent(ControlMessage msg) {
|
||||
boolean handled = true;
|
||||
switch(msg.getType()) {
|
||||
private boolean handleUdtEvent(ControlMessage msg) {
|
||||
switch (msg.getType()) {
|
||||
case ControlMessage.TYPE_REQ_IDR:
|
||||
Ln.i("Device ControlMessage.TYPE_REQ_IDR ");
|
||||
Ln.i("udt: handle ControlMessage.TYPE_REQ_IDR");
|
||||
device.reqIDRFrame();
|
||||
break;
|
||||
return true;
|
||||
case ControlMessage.TYPE_SET_BITRATE:
|
||||
int bitrate = msg.getBitRate();
|
||||
Ln.i("Device ControlMessage.TYPE_SET_BITRATE ");
|
||||
Ln.i("udt: handle ControlMessage.TYPE_SET_BITRATE: " + bitrate);
|
||||
device.setBitRate(bitrate);
|
||||
break;
|
||||
return true;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue