Skip to content
Merged

Ci #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ jobs:

- name: Build
run: |
chmod +x ./scripts/bootstrap-tests.sh
SKIP_CHECK=1 ./scripts/bootstrap-tests.sh
chmod +x ./scripts/build.sh
./scripts/build.sh

- name: Run tests
run: |
make check

- name: Verify release build
run: |
make distclean
BUILD_MODE=release ./scripts/build.sh
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,42 @@ $ ./configure

Configuration
=============

The setting file location is `/etc/xdg/libv4l-gst.conf`

### Settings

**max-width**: The maximum width of the video that can be decoded through the plugin (default: 1920)
**max-height**: The maximum height of the video that can be decoded through the plugin (default: 1080)
**bufferpool-library**: Path to the library that provides buffer pools for input and output nodes
**min-buffers**: The minimum number of buffers for each of the above buffer pools

It also supports format specific configuration section:

* **pipeline**: The GStreamer pipeline to be used. Should include everything but the input and output nodes
* `[libv4l-gst]` (global section)
* **max-width** (default: `1920`)
* The maximum width of the video that can be decoded through the plugin
* **max-height** (default: `1080`)
* The maximum height of the video that can be decoded through the plugin
* **bufferpool-library** (default: `NULL`)
* Path to the library that provides buffer pools for input and output nodes
* **min-buffers** (default: `2`)
* The minimum number of buffers for each of the above buffer pools
* **preferred-format** (default: auto-detect or `NV12`)
* Preffered output mode by FourCC (e.g. `AR24`)
* **fixed-pipeline** (default: auto-detect)
* Use fixed pipeline instead of auto-detecting
* Specify in one of the following FourCCs listed as section names (e.g. `H264`)
* `[H264]`
* **pipeline**
* The GStreamer pipeline to be used
* `appsrc` and `appsink` are automatically inserted so you shouldn't include any other `src` or `sink` elements
* If `appsrc` and `appsink` are included manually with some attributes, most of them are honored
* You can use `tee` element here to split output for debugging.
If you use it, you can use any `sink` elements (e.g. `waylandsink`) but one of them should be `appsink`.
* `[H265]`
* Ditto

### Example

The following settings are for the Renesas Porter board,
but they may be updated to use more generic settings.


```
```ini
[libv4l-gst]
min-buffers=2

Expand All @@ -58,27 +75,34 @@ Running
=======

Create a dummy V4L2 device file under /dev
```
```console
# touch /dev/video-gst
# chmod 666 /dev/video-gst
```
Accessing the /dev/video-gst file will allow an application to use the v4l-gst plugin
using the same API as a regular V4L2 device file.

Building and running unit tests
===============================
Building and running unit tests on PC
=====================================

## Overview

Although this software intends to build on Yocto, you can run unit tests on GNU/Linux PC
using in-tree v4l-utils.

## Prerequisites

In addition to developer tools for standard build, need following tools:

* [`cutter`](https://github.com/clear-code/cutter)
* meson (to build v4l-utils)
* meson (to build in-tree v4l-utils)

See [the CI workflow](./.github/workflows/tests.yml) for more detail.

## Build

```console
./scripts/bootstrap-tests.sh
$ ./scripts/build.sh
```

## Run tests
Expand Down
87 changes: 45 additions & 42 deletions scripts/bootstrap-tests.sh → scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eu
# Bootstrap and run tests for this repository. This script will:
# - ensure v4l-utils submodule is built into _install_root/usr (if needed)
# - ensure cutter is available (system or build submodule into _local)
# - configure (if needed), build (if needed) and run `make check`
# - configure (if needed), build (if needed)

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
Expand Down Expand Up @@ -48,43 +48,48 @@ if [ ! -d "$V4L_DIR" ]; then
fi
fi

# Cutter: prefer system cutter; otherwise use local installed copy or build
if command -v cutter >/dev/null 2>&1; then
echo "cutter found in PATH; skipping cutter build"
elif [ -x "$ROOT/_local/bin/cutter" ]; then
echo "Using existing local cutter at $ROOT/_local/bin/cutter"
export PATH="$ROOT/_local/bin:$PATH"
export PKG_CONFIG_PATH="$ROOT/_local/lib/pkgconfig:${PKG_CONFIG_PATH-}"
# Cutter: prefer system cutter; otherwise build the submodule when doing test builds
BUILD_MODE="${BUILD_MODE-test}"
if [ "$BUILD_MODE" = "release" ]; then
echo "BUILD_MODE=release: skipping cutter build (unit test harness not required)"
else
echo "cutter not found — attempting to build from submodule..."
git submodule update --init --recursive cutter || {
echo "cutter submodule not present; please add or install cutter." >&2
exit 1
}
if command -v cutter >/dev/null 2>&1; then
echo "cutter found in PATH; skipping cutter build"
elif [ -x "$ROOT/_local/bin/cutter" ] || [ -x "$ROOT/_local/usr/bin/cutter" ]; then
echo "Using existing local cutter at $ROOT/_local/usr/bin or $ROOT/_local/bin"
export PATH="$ROOT/_local/usr/bin:$ROOT/_local/bin:$PATH"
export PKG_CONFIG_PATH="$ROOT/_local/usr/lib/pkgconfig:$ROOT/_local/lib/pkgconfig:${PKG_CONFIG_PATH-}"
else
echo "cutter not found — attempting to build from submodule..."
git submodule update --init --recursive cutter || {
echo "cutter submodule not present; please add or install cutter." >&2
exit 1
}

cd "$ROOT/cutter"
if [ -f meson.build ] && command -v meson >/dev/null 2>&1; then
CBUILD=builddir
if [ ! -d "$CBUILD" ]; then
meson setup "$CBUILD" --prefix=/usr
cd "$ROOT/cutter"
if [ -f meson.build ] && command -v meson >/dev/null 2>&1; then
CBUILD=builddir
if [ ! -d "$CBUILD" ]; then
meson setup "$CBUILD" --prefix=/usr
else
meson setup --reconfigure "$CBUILD" --prefix=/usr
fi
ninja -C "$CBUILD" -j"$(nproc)"
DESTDIR="$ROOT/_local" ninja -C "$CBUILD" install
elif [ -f configure.ac ] || [ -f configure ]; then
autoreconf -fi
./configure --prefix="$ROOT/_local"
make -j"$(nproc)"
make install
else
meson setup --reconfigure "$CBUILD" --prefix=/usr
echo "Could not detect build system for cutter; install cutter manually." >&2
exit 1
fi
ninja -C "$CBUILD" -j"$(nproc)"
DESTDIR="$ROOT/_local" ninja -C "$CBUILD" install
elif [ -f configure.ac ] || [ -f configure ]; then
autoreconf -fi
./configure --prefix="$ROOT/_local"
make -j"$(nproc)"
make install
else
echo "Could not detect build system for cutter; install cutter manually." >&2
exit 1
fi

cd "$ROOT"
export PATH="$ROOT/_local/usr/bin:$ROOT/_local/bin:$PATH"
export PKG_CONFIG_PATH="$ROOT/_local/usr/lib/pkgconfig:$ROOT/_local/lib/pkgconfig:${PKG_CONFIG_PATH-}"
cd "$ROOT"
export PATH="$ROOT/_local/usr/bin:$ROOT/_local/bin:$PATH"
export PKG_CONFIG_PATH="$ROOT/_local/usr/lib/pkgconfig:$ROOT/_local/lib/pkgconfig:${PKG_CONFIG_PATH-}"
fi
fi

# Configure & build the project only when needed
Expand All @@ -97,7 +102,12 @@ else
export PKG_CONFIG_PATH="$V4L_DIR/lib/pkgconfig:${PKG_CONFIG_PATH-}"
export CPPFLAGS="-I$V4L_DIR/include ${CPPFLAGS-}"
export LDFLAGS="-L$V4L_DIR/lib ${LDFLAGS-}"
./configure --enable-unit-tests --with-libv4l-dir="$V4L_DIR"
if [ "$BUILD_MODE" = "release" ]; then
echo "Configuring release build (unit tests disabled)"
./configure --with-libv4l-dir="$V4L_DIR"
else
./configure --enable-unit-tests --with-libv4l-dir="$V4L_DIR"
fi
fi

if make -q >/dev/null 2>&1; then
Expand All @@ -106,11 +116,4 @@ else
make -j"$(nproc)"
fi

# If SKIP_CHECK is set to "1", skip running `make check` so CI can run
# the build and tests as separate named steps within the same job.
if [ "${SKIP_CHECK-}" = "1" ]; then
echo "SKIP_CHECK=1: skipping 'make check'"
exit 0
fi

make check
echo "Build finished (BUILD_MODE=$BUILD_MODE)"
Loading