TinyUVC 0.1.0
Header-only USB Video Class (UVC) device: turn an MCU into a USB webcam
Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions | Variables
tinyuvc Namespace Reference

TinyUVC: USB Video Class (UVC) device for Arduino and the desktop. More...

Namespaces

namespace  le
 Little endian helpers.
 
namespace  platform
 Functions every platform layer (platform/UVCPlatform*.h) implements.
 
namespace  tusb_glue
 TinyUSB class driver callbacks that connect TinyUSB to UVCDevice.
 
namespace  uvc_spec
 Constants of the USB Video Class 1.1 specification.
 

Classes

class  UVCCamera
 Connects a TinyCamera to a UVCDevice. More...
 
class  UVCConvert
 Converts raw pixel formats (RGB565, RGB888, BGR888, gray) to YUY2, one pixel pair at a time. More...
 
class  UVCDescriptorBuilder
 Writes the UVC function descriptors (everything that belongs into the configuration descriptor after its 9 byte header). More...
 
struct  UVCDescriptorParams
 Input of UVCDescriptorBuilder::build() More...
 
struct  UVCDesktopSettings
 Settings of the simulated USB bus. More...
 
class  UVCDevice
 USB Video Class (UVC 1.1) device - a USB webcam. More...
 
class  UVCDisplayDriver
 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...
 
struct  UVCFormatSpec
 One video format (UVC format descriptor) with its resolutions. More...
 
class  UVCFrameBuffer
 A growing byte buffer for one frame, allocated with UVCMemory (so in PSRAM where available). It grows in steps while a frame is written and keeps its memory when it is cleared, so after the first frames no more allocations happen. More...
 
struct  UVCFrameSpec
 One resolution (UVC frame descriptor) with its supported frame rates. More...
 
class  UVCHostSimulator
 Desktop only: a simulated USB host (modeled on Linux' uvcvideo) that enumerates, negotiates and streams from a UVCDevice. More...
 
class  UVCLoggerClass
 Logger used by all TinyUVC classes. More...
 
class  UVCMemory
 Allocates frame sized buffers in PSRAM or RAM (see UVCMemoryType) More...
 
class  UVCPayloadEncoder
 Produces the UVC payloads of one frame. Each payload starts with a 2 byte header (6 bytes with a presentation time stamp) that carries the frame id bit (FID, toggled per frame) and, in the last payload of the frame, the end of frame bit (EOF). More...
 
struct  UVCProbeCommit
 Video probe and commit control (UVC 1.1, 34 bytes). Kept as a byte array in USB (little endian) layout with typed accessors, so there are no packing or alignment issues. More...
 
struct  UVCRequest
 Setup request as seen by UVCDevice (independent of the USB stack) More...
 
struct  UVCSimBus
 What the device side did, as seen by the simulated USB core. More...
 
struct  UVCStreamSettings
 The format, resolution and frame rate the host selected. More...
 
struct  UVCTinyGPUPixel
 Maps a TinyGPU color type to the matching PixelFormat. More...
 
struct  UVCTinyGPUPixel< tinygpu::RGB565 >
 TinyGPU stores RGB565 byte-swapped: the high byte comes first in memory. More...
 
struct  UVCTinyGPUPixel< tinygpu::RGB888 >
 TinyGPU stores RGB888 as the bytes r, g, b. More...
 
class  UVCVideoCopy
 Streams the frames of an audio-tools VideoFrameSource (e.g. CameraFrameSourceTinyCamera) to a UVCDevice. More...
 
class  UVCVideoOutput
 VideoOutput that sends every frame (write() calls up to flush()) to a UVCDevice. Two frame buffers are used: one is sent while the next one is written. More...
 

Enumerations

enum class  UVCFormat : uint8_t { MJPEG = 0 , YUY2 = 1 }
 Video format offered to the USB host. More...
 
enum class  PixelFormat : uint8_t {
  MJPEG , YUY2 , RGB565_LE , RGB565_BE ,
  RGB888 , BGR888 , GRAY8
}
 Pixel format of the frame data handed to UVCDevice::writeFrame(). MJPEG (a JPEG image) is sent as is. (Not named JPEG: STM32H7 headers define a JPEG macro.) YUY2 is sent as is (YUY2). All other formats are converted to YUY2 on the fly, while they are sent, so they need no extra frame buffer. More...
 
enum class  UVCControlResult : uint8_t {
  Stall , DataIn , DataOut , Status ,
  Handled
}
 What the USB glue has to do with a setup request. More...
 
enum class  UVCLogLevel : int {
  None = 0 , Error = 1 , Warning = 2 , Info = 3 ,
  Debug = 4
}
 Log levels of UVCLogger. More...
 
enum class  UVCMemoryType { Auto , PSRAMOnly , RAMOnly }
 

Functions

bool toPixelFormat (audio_tools::VideoFormat format, PixelFormat &out)
 Maps an audio-tools VideoFormat to the matching PixelFormat.
 
bool addResolution (UVCDevice &uvc, const audio_tools::VideoInfo &info, uint32_t maxJpegSize=0)
 
UVCSimBus & simBus ()
 
UVCDesktopSettings & desktopSettings ()
 
constexpr uint8_t bytesPerPixel (PixelFormat fmt)
 Bytes per pixel of a raw pixel format (0 for JPEG)
 
const char * toString (PixelFormat fmt)
 Name of a pixel format, for logging.
 
const char * toString (UVCFormat fmt)
 Name of a UVC format, for logging.
 
constexpr uint32_t fpsToInterval (uint32_t fps)
 Frame interval in 100ns units for a frame rate.
 
constexpr uint32_t intervalToFps (uint32_t interval)
 Frame rate for a frame interval in 100ns units.
 

Variables

UVCLoggerClass UVCLog
 The global logger instance.
 

Detailed Description

TinyUVC: USB Video Class (UVC) device for Arduino and the desktop.

Enumeration Type Documentation

◆ PixelFormat

Pixel format of the frame data handed to UVCDevice::writeFrame(). MJPEG (a JPEG image) is sent as is. (Not named JPEG: STM32H7 headers define a JPEG macro.) YUY2 is sent as is (YUY2). All other formats are converted to YUY2 on the fly, while they are sent, so they need no extra frame buffer.

Enumerator
MJPEG 

one complete JPEG image (for UVCFormat::MJPEG)

YUY2 

packed YUV 4:2:2, byte order Y0 U Y1 V

RGB565_LE 

16 bit RGB565, little endian (low byte first)

RGB565_BE 

16 bit RGB565, big endian (high byte first, esp32-camera)

RGB888 

24 bit, byte order R G B

BGR888 

24 bit, byte order B G R

GRAY8 

8 bit luminance

◆ UVCControlResult

What the USB glue has to do with a setup request.

Enumerator
Stall 

reject (stall)

DataIn 

send data/len to the host

DataOut 

receive wLength bytes into data, then call handleControlData()

Status 

no data stage: just acknowledge

Handled 

nothing to do (the USB stack acknowledges itself)

◆ UVCFormat

Video format offered to the USB host.

Enumerator
MJPEG 

Motion JPEG: every frame is a complete JPEG image.

YUY2 

Uncompressed YUV 4:2:2 (YUYV), 16 bits per pixel.

◆ UVCLogLevel

Log levels of UVCLogger.

Enumerator
None 
Error 
Warning 
Info 
Debug 

◆ UVCMemoryType

Where frame buffers are allocated (not named PSRAM/RAM: arduino-pico defines a PSRAM macro)

Enumerator
Auto 

PSRAM if the board has it, else RAM.

PSRAMOnly 

PSRAM only: the allocation fails without PSRAM.

RAMOnly 

internal RAM only

Function Documentation

◆ addResolution()

bool tinyuvc::addResolution ( UVCDevice &  uvc,
const audio_tools::VideoInfo &  info,
uint32_t  maxJpegSize = 0 
)
inline

Adds the resolution of a VideoInfo to a UVCDevice: MJPEG for MJPEG frames, YUY2 for raw frames (fps 0 = 15).

◆ bytesPerPixel()

constexpr uint8_t tinyuvc::bytesPerPixel ( PixelFormat  fmt)
inlineconstexpr

Bytes per pixel of a raw pixel format (0 for JPEG)

◆ desktopSettings()

UVCDesktopSettings & tinyuvc::desktopSettings ( )
inline

◆ fpsToInterval()

constexpr uint32_t tinyuvc::fpsToInterval ( uint32_t  fps)
inlineconstexpr

Frame interval in 100ns units for a frame rate.

◆ intervalToFps()

constexpr uint32_t tinyuvc::intervalToFps ( uint32_t  interval)
inlineconstexpr

Frame rate for a frame interval in 100ns units.

◆ simBus()

UVCSimBus & tinyuvc::simBus ( )
inline

◆ toPixelFormat()

bool tinyuvc::toPixelFormat ( audio_tools::VideoFormat  format,
PixelFormat &  out 
)
inline

Maps an audio-tools VideoFormat to the matching PixelFormat.

◆ toString() [1/2]

const char * tinyuvc::toString ( PixelFormat  fmt)
inline

Name of a pixel format, for logging.

◆ toString() [2/2]

const char * tinyuvc::toString ( UVCFormat  fmt)
inline

Name of a UVC format, for logging.

Variable Documentation

◆ UVCLog

UVCLoggerClass tinyuvc::UVCLog
inline

The global logger instance.