|
TinyUVC 0.1.0
Header-only USB Video Class (UVC) device: turn an MCU into a USB webcam
|
Desktop only: a simulated USB host (modeled on Linux' uvcvideo) that enumerates, negotiates and streams from a UVCDevice. More...
#include <UVCHostSimulator.h>

Classes | |
| struct | Frame |
| A frame received from the device. More... | |
| struct | HostFormat |
| Format descriptor as parsed by the host. More... | |
| struct | HostFrame |
| Frame descriptor as parsed by the host. More... | |
Public Member Functions | |
| UVCHostSimulator (bool withCdc=true) | |
| ~UVCHostSimulator () | |
| bool | connect (UVCDevice &dev) |
| void | disconnect () |
| Simulates unplugging (bus reset) | |
| bool | isConnected () const |
| const std::vector< HostFormat > & | formats () const |
| Formats/resolutions as parsed from the descriptors. | |
| const std::vector< uint8_t > & | configDescriptor () const |
| The complete configuration descriptor. | |
| const std::string & | error () const |
| Last error message. | |
| bool | startStream (UVCFormat fmt, uint16_t width, uint16_t height, uint32_t fps=0) |
| Streams format/resolution/frame rate (fps 0 = default rate) | |
| bool | startStream (uint8_t formatIndex, uint8_t frameIndex, uint32_t interval) |
| Negotiates like Linux: GET_DEF, SET_CUR/GET_CUR probe, SET_CUR commit. | |
| bool | stopStream (bool useSetInterface=false) |
| bool | poll () |
| size_t | pollAll (size_t maxTransfers=1000000) |
| Polls until no transfer is pending (or max transfers) | |
| void | onFrame (std::function< void(const Frame &)> cb) |
| Callback for every received frame. | |
| uint32_t | framesReceived () const |
| uint32_t | framesWithError () const |
| uint32_t | payloads () const |
| uint32_t | droppedPayloads () const |
| uint32_t | transfers () const |
| uint32_t | zeroLengthPackets () const |
| uint16_t | maxPacketSize () const |
| uint32_t | urbSize () const |
| bool | isStreaming () const |
| bool | control (const UVCRequest &r, const uint8_t *out, uint16_t outLen, std::vector< uint8_t > *in) |
| bool | getProbe (uint8_t request, bool commit, UVCProbeCommit &pc) |
| Class request GET_xxx of the probe (or commit) control. | |
| bool | setProbe (bool commit, const UVCProbeCommit &pc) |
| Class request SET_CUR of the probe (or commit) control. | |
| uint8_t | requestErrorCode () |
| VC_REQUEST_ERROR_CODE_CONTROL (0xFF if the request failed) | |
Protected Member Functions | |
| bool | fail (const std::string &msg) |
| const HostFormat * | findFormat (uint8_t index) const |
| bool | buildConfiguration (UVCDevice &dev) |
| bool | parseConfiguration () |
| Parses and validates the configuration like a UVC host. | |
| bool | openDrivers () |
| void | resetPayload () |
| void | packet (const uint8_t *data, uint16_t len) |
| One USB packet arrives at the host controller. | |
| void | urbComplete (const uint8_t *mem, size_t len, bool shortUrb) |
| uvc_video_decode_bulk() | |
| int | decodeStart (const uint8_t *data, size_t len) |
| uvc_video_decode_start(): returns the header length or -1 (skip) | |
| void | decodeData (const uint8_t *mem, size_t len) |
| uvc_video_decode_data() | |
| void | decodeEnd (const uint8_t *header) |
| uvc_video_decode_end() | |
| void | completeFrame () |
Static Protected Member Functions | |
| static const HostFrame * | findFrame (const HostFormat &f, uint8_t index) |
Protected Attributes | |
| bool | withCdc_ |
| UVCDevice * | dev_ = nullptr |
| usbd_class_driver_t const * | driver_ = nullptr |
| bool | connected_ = false |
| bool | streaming_ = false |
| std::string | error_ |
| std::vector< uint8_t > | config_ |
| std::vector< HostFormat > | formats_ |
| uint8_t | ep_ = 0 |
| uint16_t | mps_ = 64 |
| uint8_t | vcItf_ = 0 |
| UVCStreamSettings | settings_ |
| uint32_t | maxVideoFrameSize_ = 0 |
| uint32_t | maxPayload_ = 0 |
| uint32_t | urbSize_ = 0 |
| std::vector< uint8_t > | urb_ |
| uint32_t | payloadSize_ = 0 |
| uint8_t | headerSize_ = 0 |
| uint8_t | header_ [256] = {} |
| bool | skipPayload_ = false |
| int | lastFid_ = -1 |
| bool | frameActive_ = false |
| bool | frameError_ = false |
| std::vector< uint8_t > | frame_ |
| bool | framePts_ = false |
| uint32_t | framePtsValue_ = 0 |
| std::function< void(const Frame &)> | onFrame_ |
| uint32_t | frames_ = 0 |
| uint32_t | errorFrames_ = 0 |
| uint32_t | payloads_ = 0 |
| uint32_t | droppedPayloads_ = 0 |
| uint32_t | transfers_ = 0 |
| uint32_t | zlps_ = 0 |
Desktop only: a simulated USB host (modeled on Linux' uvcvideo) that enumerates, negotiates and streams from a UVCDevice.
| withCdc | puts a CDC serial function in front of the camera, like on a board that also uses USB Serial (tests interface numbering) |
|
inline |
|
inlineprotected |
The complete configuration descriptor.
Enumerates the device: builds and validates the configuration descriptor and lets the class driver open its interfaces
|
inline |
Runs a control request through the class driver like the TinyUSB core: setup stage, data stage, status stage. Returns false on stall.
uvc_video_decode_data()
uvc_video_decode_end()
uvc_video_decode_start(): returns the header length or -1 (skip)
|
inline |
Simulates unplugging (bus reset)
|
inline |
|
inline |
Last error message.
|
inlineprotected |
|
inlinestaticprotected |
|
inline |
Formats/resolutions as parsed from the descriptors.
|
inline |
|
inline |
|
inline |
Class request GET_xxx of the probe (or commit) control.
|
inline |
|
inline |
|
inline |
Callback for every received frame.
|
inlineprotected |
Like process_set_config() of TinyUSB: offers each interface to the application driver; interfaces it does not claim belong to others
One USB packet arrives at the host controller.
|
inlineprotected |
Parses and validates the configuration like a UVC host.
|
inline |
|
inline |
Reads the pending IN transfer (if any) like the host controller and returns true if there was one
Polls until no transfer is pending (or max transfers)
|
inline |
VC_REQUEST_ERROR_CODE_CONTROL (0xFF if the request failed)
|
inlineprotected |
|
inline |
Class request SET_CUR of the probe (or commit) control.
|
inline |
Negotiates like Linux: GET_DEF, SET_CUR/GET_CUR probe, SET_CUR commit.
|
inline |
Streams format/resolution/frame rate (fps 0 = default rate)
Stops streaming like Linux (clear halt of the bulk endpoint) or with SET_INTERFACE(0) (useSetInterface)
|
inline |
|
inlineprotected |
uvc_video_decode_bulk()
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |