Scrcpy wire-protocol types and control primitives for Rust.
This crate owns the protocol layer only: packet types, H.264 stream parsing, and the control-message sender.
[dependencies]
scrcpy = "0.1"| Type | Description |
|---|---|
[VideoPacket] |
One compressed video frame from the server stream |
[AudioPacket] |
One compressed audio frame from the server stream |
VideoPacket::read_from(reader) reads a packet from any std::io::Read
source. AudioPacket::from_bytes(data) parses a packet from a byte slice;
codec_id is always 0 on construction and must be filled in by the caller
after reading the preceding codec-metadata packet.
scrcpy::h264::extract_resolution_from_stream(data) — scan a raw H.264
byte-stream for an SPS NAL unit and return (width, height). Accounts for
frame_cropping_flag so the result matches the true display size (e.g. 1080,
not 1088).
[ControlSender] serialises and sends scrcpy control messages over a
TcpStream. All clones share the same underlying socket (guarded by a
Mutex).
use scrcpy::ControlSender;
let sender = ControlSender::new(tcp_stream, screen_width, screen_height);
sender.send_touch_down(x, y)?;
sender.send_touch_up(x, y)?;
sender.send_key_press(keycode, metastate)?;
sender.send_text("hello")?;
sender.send_screen_off()?;
sender.send_scroll(x, y, 0.0, -1.0)?;[ScrcpyError] / [Result] — crate-level error and result aliases.
| Constant | Value |
|---|---|
SCRCPY_SERVER_VERSION |
"3.3.3" |
SCRCPY_SERVER_CLASS_NAME |
"com.genymobile.scrcpy.Server" |
SCRCPY_SERVER_PATH |
"/data/local/tmp/scrcpy-server.jar" |
MAX_PACKET_SIZE |
10 MB |
GRACEFUL_WAIT_MS |
250 ms |
See PROTOCOL.md for a detailed description of the scrcpy
wire protocol (handshake, stream framing, control message encoding).
3.3.3 — the matching server JAR must be pushed to the device before connecting.
Licensed under either of
at your option.