|
TinyUVC 0.1.0
Header-only USB Video Class (UVC) device: turn an MCU into a USB webcam
|
TinyGPU DisplayDriver that sends the written surfaces as webcam frames to the USB host: uncompressed (YUY2), or compressed with TinyJPEG (MJPEG) - whichever format the host selected. More...
#include <TinyGPU.h>


Classes | |
| struct | JpegSink |
| Output of fmt2jpg_cb() into a frame buffer. More... | |
| struct | Size |
| A resolution with the max frame size reported to the host. More... | |
Public Member Functions | |
| UVCDisplayDriver (UVCDevice &uvc) | |
| ~UVCDisplayDriver () override | |
| bool | addResolution (UVCFormat format, uint16_t width, uint16_t height, std::initializer_list< uint8_t > fps, uint32_t maxJpegSize=0) |
| bool | addResolution (UVCFormat format, uint16_t width, uint16_t height, uint8_t fps, uint32_t maxJpegSize=0) |
| bool | addResolution (uint16_t width, uint16_t height, uint8_t fps) |
| Uncompressed (YUY2) resolution. | |
| bool | addResolution (uint16_t width, uint16_t height, std::initializer_list< uint8_t > fps) |
| bool | begin () override |
| Starts the UVC device (if it is not running yet) | |
| void | end () override |
| void | setPacing (bool pacing) |
| Wait for the frame interval the host selected (default true) | |
| void | setTimeout (uint32_t ms) |
| How long writeData() waits for the previous frame (default 1000 ms) | |
| void | setJpegQuality (uint8_t quality) |
| JPEG quality 1..100 (default 80) | |
| void | setMemoryType (UVCMemoryType type) |
| Where the frame buffers are allocated (default: PSRAM if available) | |
| bool | writeData (tinygpu::ISurface< RGB_T > &surface) override |
| bool | writeData (tinygpu::ISurface< RGB_T > &surface, size_t x, size_t y) override |
| bool | flush () |
| Sends the frame composed with writeData(surface, x, y) | |
| size_t | width () const override |
| size_t | height () const override |
| bool | sizeChanged (size_t width, size_t height) const |
| true when the host selected a different size than width x height | |
| bool | isJpeg () const |
| true if the host selected MJPEG | |
| bool | waitSent (uint32_t timeoutMs) |
| Waits until the device finished reading the previous frame. | |
| uint32_t | frames () const |
| uint32_t | dropped () const |
| uint32_t | mismatched () const |
| Surfaces that were rejected because of their size. | |
| size_t | lastJpegSize () const |
| Size of the last JPEG. | |
| UVCDevice & | device () |
Protected Member Functions | |
| Size | selected () const |
| The resolution the host selected, or the first one. | |
| size_t | rawBytes () const |
| UVCFrameBuffer * | nextBuffer (size_t bytes) |
| bool | sendJpeg (const uint8_t *pixels) |
| bool | send (UVCFrameBuffer &buf, size_t len, PixelFormat format) |
| bool | setAddressWindow (size_t, size_t, size_t, size_t) override |
Static Protected Member Functions | |
| static constexpr bool | useEsp32Jpeg () |
| esp32-camera's encoder: RGB565 only (in TinyGPU's byte order) | |
| static size_t | jpegSinkWrite (void *arg, size_t index, const void *data, size_t len) |
Protected Attributes | |
| UVCDevice & | uvc_ |
| UVCFrameBuffer | buffers_ [2] |
| frames handed to the device: one is sent while the next is prepared | |
| int | next_ = 0 |
| UVCFrameBuffer | work_ |
| frames composed by partial writes | |
| size_t | workBytes_ = 0 |
| size of the frame in work_ (0: none) | |
| UVCFrameBuffer | swap_ |
| RGB565 in TinyJPEG's byte order. | |
| uint8_t | quality_ = 80 |
| bool | pacing_ = true |
| bool | dirty_ = false |
| bool | sent_ = false |
| uint32_t | timeoutMs_ = 1000 |
| uint32_t | lastUs_ = 0 |
| uint32_t | frames_ = 0 |
| uint32_t | dropped_ = 0 |
| uint32_t | mismatched_ = 0 |
| size_t | lastJpegSize_ = 0 |
TinyGPU DisplayDriver that sends the written surfaces as webcam frames to the USB host: uncompressed (YUY2), or compressed with TinyJPEG (MJPEG) - whichever format the host selected.
The surface is copied (YUY2) or compressed (MJPEG) into a frame buffer, from PSRAM where available (see UVCMemory), so the sketch can render the next frame while the previous one is still being sent. writeData() waits until the device can take a new frame and, with pacing (default), until the frame interval the host selected has passed: the render loop then runs at the frame rate of the webcam.
width()/height() report the resolution the host selected; resize your surface when it changes (see the TinyGPUWireframeWebcam example). Supported color types: RGB565 and RGB888.
|
inlineexplicit |
|
inlineoverride |
|
inline |
|
inline |
Uncompressed (YUY2) resolution.
|
inline |
Offers a resolution to the host. Call before begin(). MJPEG needs a JPEG encoder (see TINYUVC_HAS_JPEG); maxJpegSize is the biggest JPEG the host has to expect (0: width * height bytes).
|
inline |
|
inlineoverride |
Starts the UVC device (if it is not running yet)
|
inline |
|
inline |
|
inlineoverride |
|
inline |
Sends the frame composed with writeData(surface, x, y)
|
inline |
|
inlineoverride |
|
inline |
true if the host selected MJPEG
|
inlinestaticprotected |
|
inline |
Size of the last JPEG.
|
inline |
Surfaces that were rejected because of their size.
|
inlineprotected |
The buffer for the next frame. The device takes a frame only when the previous one is done, so at most the other buffer is still being sent.
|
inlineprotected |
|
inlineprotected |
The resolution the host selected, or the first one.
|
inlineprotected |
|
inlineprotected |
|
inlineoverrideprotected |
|
inline |
JPEG quality 1..100 (default 80)
|
inline |
Where the frame buffers are allocated (default: PSRAM if available)
|
inline |
Wait for the frame interval the host selected (default true)
|
inline |
How long writeData() waits for the previous frame (default 1000 ms)
|
inline |
true when the host selected a different size than width x height
|
inlinestaticconstexprprotected |
esp32-camera's encoder: RGB565 only (in TinyGPU's byte order)
|
inline |
Waits until the device finished reading the previous frame.
|
inlineoverride |
Width/height selected by the host (the first resolution while the host is not streaming)
|
inlineoverride |
Sends the surface as the next frame. Returns false if it was not sent: not streaming, the surface size does not match the host's selection, or the previous frame did not finish in time.
|
inlineoverride |
Copies the surface into the frame at x/y (e.g. for partial updates of GUI libraries) without sending it: call flush() when the frame is complete.
|
protected |
frames handed to the device: one is sent while the next is prepared
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
RGB565 in TinyJPEG's byte order.
|
protected |
|
protected |
|
protected |
frames composed by partial writes
|
protected |
size of the frame in work_ (0: none)