Documentation ¶
Index ¶
- Constants
- func Correct24CharacterSerial(usbSerial string) string
- func OpenDevice(ctx *gousb.Context, iosDevice IosDevice) (*gousb.Device, error)
- func PrintDeviceDetails(devices []IosDevice) []map[string]interface{}
- func ValidateUdid(udid string) (string, error)
- type CmSampleBufConsumer
- type IosDevice
- type MessageProcessor
- type UsbAdapter
- type UsbDataReceiver
- type UsbWriter
Constants ¶
const ( //UsbMuxSubclass is the subclass used for USBMux USB configuration. UsbMuxSubclass = gousb.ClassApplication //QuicktimeSubclass is the subclass used for the Quicktime USB configuration. QuicktimeSubclass gousb.Class = 0x2A )
Variables ¶
This section is empty.
Functions ¶
func Correct24CharacterSerial ¶
Usually iosDevices have a 40 character USB serial which equals the usbSerial used in usbmuxd, Xcode etc. There is an exception, some devices like the Xr and Xs have a 24 character USB serial. Usbmux, Xcode etc. however insert a dash after the 8th character in this case. To be compatible with other MacOS X and iOS tools, we insert the dash here as well.
func OpenDevice ¶
OpenDevice finds a gousb.Device by using the provided iosDevice.SerialNumber. It returns an open device handle. Opening using VID and PID is not specific enough, as different iOS devices can have identical VID/PID combinations.
func PrintDeviceDetails ¶
PrintDeviceDetails returns a list of device details ready to be JSON converted.
func ValidateUdid ¶
ValidateUdid checks if a given udid is 25 or 40 characters long. 25 character udids must be of format xxxxxxxx-xxxxxxxxxxxxxxxx. Serialnumbers on the usb host contain no dashes. As a convenience ValidateUdid returns the udid with the dash removed so it can be used as a correct USB SerialNumber.
Types ¶
type CmSampleBufConsumer ¶
type CmSampleBufConsumer interface { Consume(buf coremedia.CMSampleBuffer) error Stop() }
CmSampleBufConsumer is a simple interface with one function that consumes CMSampleBuffers
type IosDevice ¶
type IosDevice struct { SerialNumber string ProductName string UsbMuxConfigIndex int QTConfigIndex int VID gousb.ID PID gousb.ID UsbInfo string }
IosDevice contains a gousb.Device pointer for a found device and some additional info like the device usbSerial
func DisableQTConfig ¶
func EnableQTConfig ¶
EnableQTConfig enables the hidden QuickTime Device configuration that will expose two new bulk endpoints. We will send a control transfer to the device via USB which will cause the device to disconnect and then re-connect with a new device configuration. Usually the usbmuxd will automatically enable that new config as it will detect it as the device's preferredConfig.
func FindIosDevice ¶
FindIosDevice finds a iOS device by usbSerial or picks the first one if usbSerial == ""
func FindIosDevices ¶
FindIosDevices finds iOS devices connected on USB ports by looking for their USBMux compatible Bulk Endpoints
func (*IosDevice) DetailsMap ¶
DetailsMap contains all the info for a device in a map ready to be JSON encoded
func (*IosDevice) IsActivated ¶
IsActivated returns a boolean that is true when this device was enabled for screen mirroring and false otherwise.
type MessageProcessor ¶
type MessageProcessor struct {
// contains filtered or unexported fields
}
MessageProcessor is used to implement the control flow of USB messages answers and replies. It receives readily split byte frames, parses them, responds to them and passes on extracted CMSampleBuffers to a consumer
func NewMessageProcessor ¶
func NewMessageProcessor(usbWriter UsbWriter, stopSignal chan interface{}, consumer CmSampleBufConsumer, audioOnly bool) MessageProcessor
NewMessageProcessor creates a new MessageProcessor that will write answers to the given UsbWriter, forward extracted CMSampleBuffers to the CMSampleBufConsumer and wait for the stopSignal.
func NewMessageProcessorWithClockBuilder ¶
func NewMessageProcessorWithClockBuilder(usbWriter UsbWriter, stopSignal chan interface{}, consumer CmSampleBufConsumer, clockBuilder func(uint64) coremedia.CMClock, audioOnly bool) MessageProcessor
NewMessageProcessorWithClockBuilder lets you inject a clockBuilder for the sake of testability.
func (*MessageProcessor) CloseSession ¶
func (mp *MessageProcessor) CloseSession()
CloseSession shuts down the streams on the device by sending HPA0 and HPD0 messages and waiting for RELS messages.
func (*MessageProcessor) ReceiveData ¶
func (mp *MessageProcessor) ReceiveData(data []byte)
ReceiveData waits for byte frames of the correct length without the length field. This function will only accept byte frames starting with the ASYN, SYNC or PING uint32 magic.
type UsbAdapter ¶
type UsbAdapter struct { Dump bool DumpOutWriter io.Writer DumpInWriter io.Writer // contains filtered or unexported fields }
UsbAdapter reads and writes from AV Quicktime USB Bulk endpoints
func (*UsbAdapter) StartReading ¶
func (usbAdapter *UsbAdapter) StartReading(device IosDevice, receiver UsbDataReceiver, stopSignal chan interface{}) error
StartReading claims the AV Quicktime USB Bulk endpoints and starts reading until a stopSignal is sent. Every received data is added to a frameextractor and when it is complete, sent to the UsbDataReceiver.
func (*UsbAdapter) WriteDataToUsb ¶
func (usbAdapter *UsbAdapter) WriteDataToUsb(bytes []byte)
WriteDataToUsb implements the UsbWriter interface and sends the byte array to the usb bulk endpoint.
type UsbDataReceiver ¶
type UsbDataReceiver interface { ReceiveData(data []byte) CloseSession() }
UsbDataReceiver should receive USB SYNC, ASYN and PING packets with the correct length and with the 4 bytes length removed.