Repository navigation
Conversation
PR Summary by QodoAdd opt-in V4L2 video, ALSA audio, and overlay support
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1. Smaller video streams have wrong dimensions
|
|
Addressed in the updated push:
Not changed:
Also in this push: V4L2 builds no longer use the 32-bit-offset |
The capture and encoding threads loop while audioOn is set, but it was only set after both threads had been created. A thread scheduled before that returned at once and audio stayed silent until the next restart.
Boards whose media blocks have mainline-style drivers expose a V4L2 capture node and V4L2 memory-to-memory encoders instead of a vendor SDK. Building with -DDIVINUS_V4L2 adds a HAL for them; without the flag the backend is stubbed out and platform detection is unchanged. Devices are found by capability rather than by name: the first single-planar NV12 capture node (or DIVINUS_V4L2_CAPTURE), and M2M nodes taking NV12 and producing H.264, HEVC, JPEG or MJPEG. Every encoder reads the shared capture frame, importing it by DMABUF when the layouts match and copying it otherwise. The capture rate is a cap that the encoder loop decimates to, and MP4 fragments use the capture timestamps, as on AK. An access unit with more NALs than a pack holds continues in further packs. These builds link no vendor libraries, so they keep the libc mmap() instead of the 32-bit offset variant exported for them.
Read mono S16 PCM from the ALSA "default" device, or DIVINUS_ALSA_DEVICE, and hand it to the existing MP3 and G.711 encoders. The default device converts format, rate and channel count, so codecs that only offer other sample formats need no backend-specific conversion. Building with -DDIVINUS_V4L2 now also requires -lasound. The capture stream is started explicitly, since a prepared stream never becomes readable on its own. A capture error is recovered and retried instead of ending the thread.
Render text and image regions into ARGB1555 buffers queued on V4L2 output nodes that accept ARGB555. Each region claims the first such node whose queue no other file handle owns, places it with the compose selection and sets its opacity through V4L2_CID_ALPHA_COMPONENT. Overlay nodes may belong to different scaler channels, so DIVINUS_V4L2_OSD_CARD optionally restricts the search to nodes whose QUERYCAP card name matches exactly. A region whose bitmap changes size, such as text with a varying CPU or time value, releases its buffer and sets the new format, since a queue cannot change format while it owns buffers.
Add V4L2 support in divinus.
The FH8626 SoC port, merged recently, uses V4L2 as its video backend, and ALSA as the audio backend. This set of patches adds support for it, and will be useful for future SoC ports that don't use a vendor SDK.
What it adds
V4L2_CID_ALPHA_COMPONENT.Impact on other platforms
None. The backend is only built with
-DDIVINUS_V4L2; without it every call is a stub and platform detection is unchanged. The core changes are onecase HAL_PLATFORM_V4L2per existingswitch (plat). The only other change is in MP4 muxing, which uses the capture timestamps for V4L2, as it already does for AK. Builds with the flag also need-lasound. Toolchains with kernel headers older than 4.10 lackV4L2_PIX_FMT_HEVC, so the backend defines it itself and builds against them too (e.g. the FH8852V200 4.9 toolchain).Device discovery
Devices are matched by capability:
Optional environment overrides for boards that need them:
DIVINUS_V4L2_CAPTURE/dev/video0DIVINUS_ALSA_DEVICEdefault)DIVINUS_V4L2_OSD_CARDQUERYCAPcard name matches exactly. Useful when overlay nodes belong to different scaler channels.Commits
media: set audioOn before starting the audio threads: a generic fix that is also part of Fix audio, RTSP, OSD and config bugs in Divinus #73. The V4L2 audio thread needs it, otherwise it exits beforeaudioOnis set. Whichever PR merges second drops it on rebase.hal: add an opt-in V4L2 video backendhal: capture V4L2 backend audio through ALSAhal: draw V4L2 backend regions on overlay output nodesTesting
On FH8626V100 hardware (GC1054 sensor, 1280x720 NV12):
/video.mp4with MP3 audio, including after a sample-rate change through/api/audio./image.jpgsnapshots./api/mp4while the stream is running.