Skip to content

Feature/device hub#1703

Open
doronz88 wants to merge 8 commits into
masterfrom
feature/device-hub
Open

Feature/device hub#1703
doronz88 wants to merge 8 commits into
masterfrom
feature/device-hub

Conversation

@doronz88

@doronz88 doronz88 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

No description provided.

Comment thread pymobiledevice3/remote/core_device/screen_stream.py Dismissed
Comment thread pymobiledevice3/remote/core_device/screen_stream.py Dismissed
@doronz88 doronz88 force-pushed the feature/device-hub branch 2 times, most recently from 5206d8a to 097d37b Compare June 9, 2026 17:17
doronz88 added 5 commits June 9, 2026 20:19
pymobiledevice3/osu/win_util.py imports win32security but pywin32 was
never declared. Previously the Windows CI happened to pull it in
transitively (via pywintunx-pmd3); since that dep was removed in
e0e5b20 the Windows job fails at conftest import time with:

  ModuleNotFoundError: No module named 'win32security'

Declare pywin32 directly, gated on platform_system == "Windows".
- PEP 723 shebang (uv run --script) so the sniffer is self-installing and
  no longer relies on the surrounding pyproject's env.
- XpcInt64Type / XpcUInt64Type repr override — pformat() now shows
  ``Int64(12)`` / ``UInt64(12)`` instead of bare ints, preserving the
  wire-type distinction that matters when reproducing the format from
  a client.
- log each decoded XPC frame as full raw hex too, not just hyperframe's
  truncated 10-byte preview — needed to actually decode the wire format
  byte-by-byte when writing a client.
- send_request: bump next_message_id[ROOT_CHANNEL] so fire-and-forget calls
  get distinct ids on the wire (devicectl always uses monotonic ids; many
  iOS daemons reject or drop duplicates).
- _do_handshake: emit Headers#3 between the two stream-1 init frames to
  match the order devicectl uses. dtuhidd's RemoteServiceDiscovery rejects
  out-of-order init with "Invalid or missing remote device connection
  version flags" + xpc_connection_cancel() otherwise.
- RemoteXPCConnection.local_address property: typed (host, port) of the
  local end of the connection — useful when telling the device a callback
  endpoint on this host's tunnel interface (e.g. RTP receiver port in
  mediastreamstart).
Some CoreDevice features take both a feature identifier and an action
identifier (e.g. com.apple.coredevice.feature.startmediastream is paired
with com.apple.coredevice.action.mediastreamstart). Pass it through as
CoreDevice.actionIdentifier when provided.

Also bump CORE_DEVICE_VERSION to "629.3" to match the version devicectl
on macOS Tahoe sends, and CoreDeviceDDIProtocolVersion to 2.
Wraps com.apple.coredevice.screencaptureservice / feature.capturescreenshot.
Returns the raw PNG bytes from CoreDevice.output["image"] together with the
display identifier and image format.

Wire CLI: pymobiledevice3 developer core-device screen-capture screenshot <path>
@doronz88 doronz88 force-pushed the feature/device-hub branch from 097d37b to 08a1176 Compare June 9, 2026 17:19
doronz88 added 3 commits June 9, 2026 20:34
Adds three RemoteXPC services and their CLI surface:

- IndigoHIDService (com.apple.coredevice.hid.indigo) — generic HID button,
  scroll, digitizer, and vendor-defined events. Buttons addressable both
  by raw (usagePage, usageCode) and by friendly name (home, power, sleep,
  volume-up, volume-down, mute, siri, lock). The wire envelope used here
  is the {messageType, payload, featureIdentifier} format consumed by
  dtuhidd's IndigoHIDServer.

- UniversalHIDService (com.apple.coredevice.hid.universalhid) — virtual
  HID device management (attach/detach by HIDDeviceType, send raw HID
  reports, list supported devices).

- UniversalHIDServiceService (com.apple.coredevice.hid.universalhidservice)
  — register/inspect virtual HID services. ``list-connected`` enumerates
  the device's currently active HID services (touchscreen, keyboard,
  mainScreenButtons, etc.).

- DeviceControlService (com.apple.coredevice.devicecontrol) — orientation
  control (portrait, portrait-upside-down, landscape-left, landscape-right).

Sample press: pymobiledevice3 developer core-device hid button home press
Three new modules and two CLI commands for the device's screen stream:

- display_service.py — DisplayService (com.apple.coredevice.displayservice)
  with start_video_stream() (mediastreamstart action) and stop_media_stream
  (best-effort: action identifier is a guess; we treat the device's
  IncompleteReadError-on-channel-close as success since it's empirically
  how a successful stop responds). Also get_media_support_info /
  get_media_stream_server_status.

- media_stream_offer.py — builds the negotiatorOffer bplist that
  mediastreamstart requires. Reproduces Apple's exact wire format
  including the zlib-compressed avcMediaStreamNegotiatorMediaBlob
  protobuf (codec descriptors, "Viceroy 1.7.0" decoder identification,
  bitrate ranges).

- screen_stream.py — pure-stdlib pipeline that sits above DisplayService:
    asyncio UDP receive -> RFC 7798 RTP/HEVC depacketize
    -> cache VPS/SPS/PPS+IDR + parse SPS for WebCodecs codec string
    -> HTTP chunked stream of framed access units
    -> built-in HTML viewer that decodes with WebCodecs VideoDecoder
  No external player or transcoder needed; the browser drives the OS
  hardware HEVC decoder (VideoToolbox on macOS).

- misc/rtp_dump.py — offline RTP capture -> Annex-B HEVC bitstream
  converter for the raw-capture mode. Handles RFC 7798 Aggregation
  Packets (nal_type 48) and Fragmentation Units (nal_type 49).

CLI:
  developer core-device display get-media-support-info
  developer core-device display get-media-stream-server-status
  developer core-device display start-video-stream <path>   # raw RTP capture
  developer core-device display serve-video-stream          # HTTP+WebCodecs viewer
Wraps com.apple.coredevice.locationservice / feature.simulatelocation.
``available-scenarios`` action returns the device's built-in scenarios
(City Run, City Bicycle Ride, Apple, Freeway Drive, ...).

CLI: pymobiledevice3 developer core-device location available-scenarios
@doronz88 doronz88 force-pushed the feature/device-hub branch from 08a1176 to e51801c Compare June 9, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants