feat(gstreamer): add gstreamer support (#8757)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
André Costa
2025-09-09 20:38:41 +02:00
committed by GitHub
parent 95b9b80176
commit 0dc9cdf3e1
12 changed files with 1475 additions and 0 deletions
+311
View File
@@ -0,0 +1,311 @@
.. _gstreamer:
=========
GStreamer
=========
**GStreamer** is a pipeline-based multimedia framework that links together a wide variety of media processing systems to complete complex workflows.
The framework uses a pipeline model where media data flows from source elements through various processing elements (decoders, converters, filters) to sink elements (display, speakers, files).
The GStreamer extension in LVGL provides video and audio playback capabilities with support for various media formats, streaming protocols, and media sources. It leverages GStreamer's powerful pipeline architecture to handle media decoding, processing, and rendering.
For detailed information about GStreamer, see: https://gstreamer.freedesktop.org/
Features
********
LVGL's GStreamer implementation provides comprehensive media playback capabilities:
**Media Source Support:**
* Local files via file:// URIs
* Network streaming with HTTP/HTTPS support
* RTSP streaming for live video feeds
* UDP streaming for low-latency applications
* Multicast streaming for efficient network distribution
* Video4Linux2 (V4L2) camera devices on Linux
* Audio capture from ALSA and PulseAudio devices
* Test sources for audio and video development
**URI Scheme Support:**
Using the URI factory (``LV_GSTREAMER_FACTORY_URI_DECODE``), you can specify various URI schemes as media sources:
* **Local files**: ``file://path/to/video.mp4``
* **Web streams**: ``http://example.com/stream.webm``, ``https://secure.example.com/video.mp4``
* **RTSP streams**: ``rtsp://camera.local/stream``
* **UDP streams**: ``udp://239.255.12.42:1234``
* **Multicast**: ``multicast://239.255.12.42:1234``
* **V4L2 cameras**: ``v4l2:///dev/video0``
* **Audio devices**: ``alsa://hw:0,0``, ``pulse://default``
GStreamer's ``uridecodebin`` automatically selects the appropriate source element and decoder based on the URI scheme and media format.
**Playback Control:**
* Play, pause, and stop operations
* Precise seeking to specific positions
* Volume control with 0-100% range
* Playback rate control (slow motion and fast forward)
* Real-time position and duration queries
* State management (NULL, READY, PAUSED, PLAYING)
**Media Format Support:**
GStreamer supports a wide variety of media formats through its plugin system:
* **Video**: H.264, H.265/HEVC, VP8, VP9, AV1, MPEG-4, WebM, and many more
* **Audio**: AAC, MP3, Ogg Vorbis, FLAC, Opus, PCM, and others
* **Containers**: MP4, WebM, AVI, MKV, MOV, FLV, and more
Requirements
************
The GStreamer extension requires **GStreamer 1.0** or later with the following components:
:gstreamer-1.0: Core GStreamer framework
:gstreamer-video-1.0: Video handling and processing utilities
:gstreamer-app-1.0: Application integration utilities
Dependencies
------------
Follow the official GStreamer documentation to install its development libraries on your system: https://gstreamer.freedesktop.org/documentation/installing/index.html?gi-language=c
Setup
*****
1. **Install Dependencies**
Install the GStreamer development libraries for your platform as shown in the Dependencies section above.
2. **Enable GStreamer Support**
Set :c:macro:`LV_USE_GSTREAMER` to ``1`` in ``lv_conf.h``.
3. **CMake Integration**
**Option 1: Direct linking with LVGL (Recommended)**
.. code-block:: cmake
find_package(PkgConfig REQUIRED)
# Find GStreamer packages
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER_VIDEO REQUIRED gstreamer-video-1.0)
pkg_check_modules(GSTREAMER_APP REQUIRED gstreamer-app-1.0)
# Link with LVGL
target_include_directories(lvgl PUBLIC
${GSTREAMER_INCLUDE_DIRS}
${GSTREAMER_VIDEO_INCLUDE_DIRS}
${GSTREAMER_APP_INCLUDE_DIRS})
target_link_libraries(lvgl PUBLIC
${GSTREAMER_LIBRARIES}
${GSTREAMER_VIDEO_LIBRARIES}
${GSTREAMER_APP_LIBRARIES})
4. **Manual Compilation with pkg-config**
You can also compile manually using pkg-config to query the necessary flags:
.. code-block:: bash
# Get compilation flags
gcc $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-video-1.0 gstreamer-app-1.0) \
-o your_app your_app.c lvgl.a
5. **Basic Setup Example**
.. code-block:: c
int main(void)
{
/* Initialize LVGL */
lv_init();
/* Setup display driver */
lv_display_t *display = lv_display_create(800, 480);
/* ... configure display driver ... */
/* Create and run your GStreamer application */
lv_example_gstreamer_1();
while (1) {
lv_timer_handler();
}
return 0;
}
Usage
*****
Basic GStreamer Player Creation
-------------------------------
Here's how to create a basic GStreamer player and load media:
.. code-block:: c
/* Create a GStreamer object */
lv_obj_t * streamer = lv_gstreamer_create(lv_screen_active());
/* Set the media source using URI factory */
lv_result_t result = lv_gstreamer_set_src(streamer,
LV_GSTREAMER_FACTORY_URI_DECODE,
LV_GSTREAMER_PROPERTY_URI_DECODE,
"https://example.com/video.webm");
if (result != LV_RESULT_OK) {
LV_LOG_ERROR("Failed to set GStreamer source");
return;
}
/* Start playback */
lv_gstreamer_play(streamer);
Media Source Configuration
--------------------------
The GStreamer widget supports various media sources through different factories:
**URI Factory (Recommended):**
.. code-block:: c
/* Load from web URL */
lv_gstreamer_set_src(streamer, LV_GSTREAMER_FACTORY_URI_DECODE,
LV_GSTREAMER_PROPERTY_URI_DECODE,
"https://example.com/stream.webm");
/* Load from local file */
lv_gstreamer_set_src(streamer, LV_GSTREAMER_FACTORY_URI_DECODE,
LV_GSTREAMER_PROPERTY_URI_DECODE,
"file:///path/to/video.mp4");
/* RTSP stream */
lv_gstreamer_set_src(streamer, LV_GSTREAMER_FACTORY_URI_DECODE,
LV_GSTREAMER_PROPERTY_URI_DECODE,
"rtsp://camera.local/stream");
**File Factory:**
.. code-block:: c
/* Direct file access */
lv_gstreamer_set_src(streamer, LV_GSTREAMER_FACTORY_FILE,
LV_GSTREAMER_PROPERTY_FILE,
"/path/to/video.mp4");
Playback Control
----------------
Control media playback with these functions:
.. code-block:: c
/* Basic playback control */
lv_gstreamer_play(streamer);
lv_gstreamer_pause(streamer);
lv_gstreamer_stop(streamer);
/* Get current state */
lv_gstreamer_state_t state = lv_gstreamer_get_state(streamer);
/* Seek to position (in milliseconds) */
lv_gstreamer_set_position(streamer, 30000); /* Seek to 30 seconds */
/* Get current position and duration */
uint32_t position = lv_gstreamer_get_position(streamer);
uint32_t duration = lv_gstreamer_get_duration(streamer);
/* Set playback rate - values relative to 256 (1x speed) */
lv_gstreamer_set_rate(streamer, 128); /* 0.5x speed */
lv_gstreamer_set_rate(streamer, 256); /* 1.0x speed (normal) */
lv_gstreamer_set_rate(streamer, 512); /* 2.0x speed */
Volume Control
--------------
Manage audio volume with built-in controls:
.. code-block:: c
/* Set volume (0-100%) */
lv_gstreamer_set_volume(streamer, 75);
/* Get current volume */
uint8_t volume = lv_gstreamer_get_volume(streamer);
Event Handling
--------------
Handle GStreamer events using LVGL's event system:
.. code-block:: c
static void gstreamer_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * streamer = lv_event_get_target_obj(e);
if(code == LV_EVENT_READY) {
LV_LOG_USER("Stream ready - Duration: %" LV_PRIu32 " ms",
lv_gstreamer_get_duration(streamer));
LV_LOG_USER("Resolution: %" LV_PRId32 "x%" LV_PRId32,
lv_image_get_src_width(streamer),
lv_image_get_src_height(streamer));
}
}
/* Add event callback */
lv_obj_add_event_cb(streamer, gstreamer_event_cb, LV_EVENT_ALL, NULL);
Widget Architecture
*******************
The GStreamer widget extends the ``lv_image`` widget, which means:
- All standard ``lv_obj`` functions work with GStreamer widgets (positioning, sizing, styling, events)
- All ``lv_image`` functions are available for image-related operations
- Video frames are rendered as image content that updates automatically during playback
State Management
----------------
The GStreamer widget maintains these states:
- ``LV_GSTREAMER_STATE_NULL``: Initial state, no media loaded
- ``LV_GSTREAMER_STATE_READY``: Media loaded and ready to play
- ``LV_GSTREAMER_STATE_PAUSED``: Playback paused
- ``LV_GSTREAMER_STATE_PLAYING``: Active playback
Media Information Access
------------------------
Once media is loaded (LV_EVENT_READY), you can access:
- Video resolution via ``lv_image_get_src_width()`` and ``lv_image_get_src_height()``
- Media duration via ``lv_gstreamer_get_duration()``
- Current playback position via ``lv_gstreamer_get_position()``
- Current volume level via ``lv_gstreamer_get_volume()``
- Current playback state via ``lv_gstreamer_get_state()``
.. _gstreamer_example:
Examples
********
.. include:: ../../examples/libs/gstreamer/index.rst
.. _gstreamer_api:
API
***
.. API startswith: lv_gstreamer_
+1
View File
@@ -17,6 +17,7 @@
freetype
fs
gif
gstreamer
gltf
lfs
libjpeg_turbo
+5
View File
@@ -0,0 +1,5 @@
Loads a video from the internet using the gstreamer widget
----------------------------------------------------------
.. lv_example:: libs/gstreamer/lv_example_gstreamer_1
:language: c
@@ -0,0 +1,39 @@
/**
* @file lv_example_gstreamer.h
*
*/
#ifndef LV_EXAMPLE_GSTREAMER_H
#define LV_EXAMPLE_GSTREAMER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_example_gstreamer_1(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_EXAMPLE_GSTREAMER_H*/
@@ -0,0 +1,217 @@
#include "../../lv_examples.h"
#if LV_BUILD_EXAMPLES
#if LV_USE_GSTREAMER
typedef struct {
lv_obj_t * streamer;
lv_obj_t * pp_button;
lv_obj_t * button_label;
lv_obj_t * position_label;
lv_obj_t * duration_label;
lv_subject_t position_subject;
} event_data_t;
static void volume_setter_create(event_data_t * event_data);
static void control_bar_create(event_data_t * event_data);
static void update_duration_label(lv_obj_t * label, uint32_t duration);
static void volume_observer_cb(lv_observer_t * observer, lv_subject_t * subject);
static void update_position_slider(lv_timer_t * timer);
static void play_pause_pressed(lv_event_t * e);
static void streamer_ready(lv_event_t * e);
/**
* Loads a video from the internet using the gstreamer widget
*/
void lv_example_gstreamer_1(void)
{
static event_data_t event_data;
event_data.streamer = lv_gstreamer_create(lv_screen_active());
/* the gstreamer widget inherits the `lv_image` widget,
* meaning you can also provide it lv_image functions, like
lv_image_set_scale(event_data.streamer, 100);
lv_image_set_rotation(event_data.streamer, 100);
*/
/* Set the current src of the streamer.
* Using the `URI` "factory", we can
* specify various URI schemes as media sources including local files (file://),
* web streams (http://, https://), RTSP streams (rtsp://), UDP streams (udp://),
* and many others. GStreamer's uridecodebin automatically selects the appropriate
* source element and decoder based on the URI scheme and media format. */
lv_gstreamer_set_src(event_data.streamer, LV_GSTREAMER_FACTORY_URI_DECODE, LV_GSTREAMER_PROPERTY_URI_DECODE,
"https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm");
lv_obj_center(event_data.streamer);
/* The LV_EVENT_READY will fire when the stream is ready at that point you can query the stream
* information like its resolution and duration. See `streamer_ready` */
lv_obj_add_event_cb(event_data.streamer, streamer_ready, LV_EVENT_READY, &event_data);
/* Play the stream immediately */
lv_gstreamer_play(event_data.streamer);
/* Create a slider to modify the stream volume and a label to visualize the current value */
volume_setter_create(&event_data);
/* Create a slider to see the position in the stream with 2 text label on each side
* One for the current position in the stream and the other for the total duration of the stream
* Also add a pause/play button*/
control_bar_create(&event_data);
/* Create a timer that will update the slider position based on the stream position
* Make it 3 times faster than the refresh rate for a smoother effect */
lv_timer_create(update_position_slider, LV_DEF_REFR_PERIOD, &event_data);
}
static void volume_setter_create(event_data_t * event_data)
{
lv_obj_t * cont = lv_obj_create(lv_screen_active());
lv_obj_remove_style_all(cont);
lv_obj_set_style_pad_all(cont, 8, 0);
lv_obj_set_style_pad_gap(cont, 8, 0);
lv_obj_set_style_radius(cont, 8, 0);
lv_obj_set_style_bg_color(cont, lv_color_white(), 0);
lv_obj_set_style_bg_opa(cont, LV_OPA_70, 0);
lv_obj_set_size(cont, 40, lv_pct(60));
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN);
lv_obj_set_flex_align(cont, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_align(cont, LV_ALIGN_RIGHT_MID, -8, -40);
lv_obj_t * volume_slider = lv_slider_create(cont);
lv_obj_set_size(volume_slider, 13, LV_PCT(50));
lv_obj_set_flex_grow(volume_slider, 1);
lv_obj_t * volume_label = lv_label_create(cont);
lv_obj_set_style_text_align(volume_label, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_width(volume_label, 50);
/* We use `lv_subject` to simplify binding the data between multiple objects.
* Here the data is shared between the slider, the label and the gstreamer widgets */
static lv_subject_t volume_subject;
lv_subject_init_int(&volume_subject, 50);
lv_subject_add_observer_obj(&volume_subject, volume_observer_cb, event_data->streamer, NULL);
lv_slider_bind_value(volume_slider, &volume_subject);
lv_label_bind_text(volume_label, &volume_subject, LV_SYMBOL_VOLUME_MID "\n%3" LV_PRId32 "%%");
}
static void control_bar_create(event_data_t * event_data)
{
lv_subject_init_int(&event_data->position_subject, 0);
lv_obj_t * cont = lv_obj_create(lv_screen_active());
lv_obj_remove_style_all(cont);
lv_obj_set_style_pad_all(cont, 8, 0);
lv_obj_set_style_margin_hor(cont, 8, 0);
lv_obj_set_style_pad_gap(cont, 8, 0);
lv_obj_set_style_radius(cont, 8, 0);
lv_obj_set_style_bg_color(cont, lv_color_white(), 0);
lv_obj_set_style_bg_opa(cont, LV_OPA_70, 0);
lv_obj_set_size(cont, lv_pct(100), LV_SIZE_CONTENT);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(cont, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
lv_obj_align(cont, LV_ALIGN_BOTTOM_MID, 0, -10);
event_data->position_label = lv_label_create(cont);
lv_obj_set_width(event_data->position_label, 80);
lv_label_set_text_static(event_data->position_label, "0:00:000");
/* Create a button a button to play/pause the stream */
event_data->pp_button = lv_button_create(cont);
lv_obj_center(event_data->pp_button);
lv_obj_add_event_cb(event_data->pp_button, play_pause_pressed, LV_EVENT_CLICKED, event_data);
event_data->button_label = lv_label_create(event_data->pp_button);
lv_label_set_text_static(event_data->button_label, LV_SYMBOL_PAUSE);
lv_obj_t * position_slider = lv_bar_create(cont);
lv_bar_set_range(position_slider, 0, 1000);
lv_obj_set_flex_grow(position_slider, 1);
lv_slider_bind_value(position_slider, &event_data->position_subject);
event_data->duration_label = lv_label_create(cont);
lv_obj_set_width(event_data->duration_label, 80);
lv_label_set_text_static(event_data->duration_label, "0:00:000");
lv_obj_set_style_text_align(event_data->duration_label, LV_TEXT_ALIGN_RIGHT, 0);
}
static void update_duration_label(lv_obj_t * label, uint32_t duration)
{
const uint32_t minutes = duration / 60000;
const uint32_t seconds = (duration / 1000) % 60;
const uint32_t milliseconds = duration % 1000;
lv_label_set_text_fmt(label, "%" LV_PRIu32 ":%02" LV_PRIu32 ":%03" LV_PRIu32, minutes, seconds, milliseconds);
}
static void volume_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
{
lv_obj_t * streamer = lv_observer_get_target_obj(observer);
int32_t volume = lv_subject_get_int(subject);
LV_LOG_USER("Setting volume %" PRId32, volume);
lv_gstreamer_set_volume(streamer, (uint8_t)volume);
}
static void update_position_slider(lv_timer_t * timer)
{
event_data_t * event_data = (event_data_t *)lv_timer_get_user_data(timer);
uint32_t duration = lv_gstreamer_get_duration(event_data->streamer);
uint32_t position = lv_gstreamer_get_position(event_data->streamer);
int32_t position_perc = lv_map(position, 0, duration, 0, 1000);
lv_subject_set_int(&event_data->position_subject, position_perc);
update_duration_label(event_data->position_label, position);
}
static void play_pause_pressed(lv_event_t * e)
{
event_data_t * event_data = (event_data_t *)lv_event_get_user_data(e);
if(lv_streq(lv_label_get_text(event_data->button_label), LV_SYMBOL_PLAY)) {
lv_label_set_text(event_data->button_label, LV_SYMBOL_PAUSE);
lv_gstreamer_play(event_data->streamer);
}
else {
lv_label_set_text(event_data->button_label, LV_SYMBOL_PLAY);
lv_gstreamer_pause(event_data->streamer);
}
}
static void streamer_ready(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
event_data_t * event_data = (event_data_t *)lv_event_get_user_data(e);
lv_obj_t * btn = event_data->pp_button;
lv_obj_t * streamer = event_data->streamer;
if(code == LV_EVENT_READY) {
lv_obj_align(btn, LV_ALIGN_BOTTOM_MID, 0, 0);
uint32_t duration = lv_gstreamer_get_duration(streamer);
LV_LOG_USER("Video is starting");
LV_LOG_USER("\tStream resolution %" LV_PRId32 "x%" LV_PRId32, lv_image_get_src_width(streamer),
lv_image_get_src_height(streamer));
LV_LOG_USER("\tStream duration %" LV_PRIu32, duration);
update_duration_label(event_data->duration_label, duration);
}
}
#else
void lv_example_gstreamer_1(void)
{
/*TODO
*fallback for online examples*/
lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "GStreamer web support is coming soon");
lv_obj_center(label);
}
#endif
#endif
+1
View File
@@ -19,6 +19,7 @@ extern "C" {
#include "freetype/lv_example_freetype.h"
#include "gif/lv_example_gif.h"
#include "gltf/lv_example_gltf.h"
#include "gstreamer/lv_example_gstreamer.h"
#include "lodepng/lv_example_lodepng.h"
#include "libpng/lv_example_libpng.h"
#include "qrcode/lv_example_qrcode.h"
+2
View File
@@ -970,6 +970,8 @@
#define LV_GIF_CACHE_DECODE_DATA 0
#endif
/** GStreamer library */
#define LV_USE_GSTREAMER 0
/** Decode bin images to RAM */
#define LV_BIN_DECODER_RAM_LOAD 0
+1
View File
@@ -109,6 +109,7 @@ extern "C" {
#include "src/libs/gltf/gltf_data/lv_gltf_model.h"
#include "src/libs/gltf/gltf_view/lv_gltf.h"
#include "src/libs/gif/lv_gif.h"
#include "src/libs/gstreamer/lv_gstreamer.h"
#include "src/libs/qrcode/lv_qrcode.h"
#include "src/libs/tjpgd/lv_tjpgd.h"
#include "src/libs/libjpeg_turbo/lv_libjpeg_turbo.h"
File diff suppressed because it is too large Load Diff
+188
View File
@@ -0,0 +1,188 @@
/**
* @file lv_gstreamer.h
*
*/
#ifndef LV_GSTREAMER_H
#define LV_GSTREAMER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_GSTREAMER
#include "../../core/lv_obj.h"
/*********************
* DEFINES
*********************/
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_gstreamer_class;
/* Using the `URI` "factory", we can specify various URI schemes as media sources including
* - local files (file://)
* - web streams (http://, https://)
* - RTSP streams (rtsp://)
* - UDP streams (udp://)
* and many others.
* GStreamer's uridecodebin automatically selects the appropriate
* source element and decoder based on the URI scheme and media format. */
#define LV_GSTREAMER_FACTORY_URI_DECODE "uridecodebin"
#define LV_GSTREAMER_PROPERTY_URI_DECODE "uri"
#define LV_GSTREAMER_FACTORY_FILE "filesrc"
#define LV_GSTREAMER_PROPERTY_FILE "location"
/** These sources are untested. For most of them, URI_DECODE can probably be used instead */
#ifdef LV_GSTREAMER_ENABLE_UNTESTED_SOURCES
#define LV_GSTREAMER_FACTORY_HTTP "souphttpsrc"
#define LV_GSTREAMER_PROPERTY_HTTP "location"
#define LV_GSTREAMER_FACTORY_HTTPS "souphttpsrc"
#define LV_GSTREAMER_PROPERTY_HTTPS "location"
#define LV_GSTREAMER_FACTORY_V4L2_CAMERA "v4l2src"
#define LV_GSTREAMER_PROPERTY_V4L2_CAMERA "device"
#define LV_GSTREAMER_FACTORY_ALSA_AUDIO "alsasrc"
#define LV_GSTREAMER_PROPERTY_ALSA_AUDIO "device"
#define LV_GSTREAMER_FACTORY_PULSE_AUDIO "pulsesrc"
#define LV_GSTREAMER_PROPERTY_PULSE_AUDIO "device"
#define LV_GSTREAMER_FACTORY_TEST_AUDIO "audiotestsrc"
#define LV_GSTREAMER_PROPERTY_TEST_AUDIO NULL
#define LV_GSTREAMER_FACTORY_TEST_VIDEO "videotestsrc"
#define LV_GSTREAMER_PROPERTY_TEST_VIDEO NULL
#define LV_GSTREAMER_FACTORY_APP "appsrc"
#define LV_GSTREAMER_PROPERTY_APP NULL
#endif
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_GSTREAMER_STATE_NULL,
LV_GSTREAMER_STATE_READY,
LV_GSTREAMER_STATE_PAUSED,
LV_GSTREAMER_STATE_PLAYING
} lv_gstreamer_state_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a gstreamer object
* @param parent pointer to an object, it will be the parent of the new gstreamer
* @return pointer to the created gstreamer
*/
lv_obj_t * lv_gstreamer_create(lv_obj_t * parent);
/**
* Add a source to this gstreamer object
* @param gstreamer pointer to a gstreamer object
* @param factory_name the factory name for the source of this gstreamer object.
* for common factory names, check `LV_GSTREAMER_FACTORY_XXX` defines
* @param property the property name for the gstreamer source object
* for common properties, see `LV_GSTREAMER_PROPERTY_XXX` defines
* Passing NULL will create the source object but not set its source
* @param source the property value for the gstreamer source object
* Passing NULL will create the source object but not set its source
* @return LV_RESULT_OK if the source was correctly set else LV_RESULT_INVALID
*/
lv_result_t lv_gstreamer_set_src(lv_obj_t * gstreamer, const char * factory_name, const char * property,
const char * source);
/**
* Play this gstreamer
* @param gstreamer pointer to a gstreamer object
*/
void lv_gstreamer_play(lv_obj_t * gstreamer);
/**
* Pause this gstreamer
* @param gstreamer pointer to a gstreamer object
*/
void lv_gstreamer_pause(lv_obj_t * gstreamer);
/**
* Stop this gstreamer
* @param gstreamer pointer to a gstreamer object
*/
void lv_gstreamer_stop(lv_obj_t * gstreamer);
/**
* Seek a position in this gstreamer
* @param gstreamer pointer to a gstreamer object
* @param position position to seek to
*/
void lv_gstreamer_set_position(lv_obj_t * gstreamer, uint32_t position);
/**
* Get the duration of this gstreamer
* @param gstreamer pointer to a gstreamer object
* @return the duration (in ms) of the gstreamer object
*/
uint32_t lv_gstreamer_get_duration(lv_obj_t * gstreamer);
/**
* Get the position of this gstreamer
* @param gstreamer pointer to a gstreamer object
* @return the position (in ms) of the gstreamer object
*/
uint32_t lv_gstreamer_get_position(lv_obj_t * gstreamer);
/**
* Get the state of this gstreamer
* @param gstreamer pointer to a gstreamer object
*/
lv_gstreamer_state_t lv_gstreamer_get_state(lv_obj_t * gstreamer);
/**
* Set the volume of this gstreamer
* @param gstreamer pointer to a gstreamer object
* @param volume the value to set in the range [0..100]. Higher values are clamped
*/
void lv_gstreamer_set_volume(lv_obj_t * gstreamer, uint8_t volume);
/**
* Get the volume of this gstreamer
* @param gstreamer pointer to a gstreamer object
* @return the volume for this gstreamer
*/
uint8_t lv_gstreamer_get_volume(lv_obj_t * gstreamer);
/**
* Set the speed rate of this gstreamer
* @param gstreamer pointer to a gstreamer object
* @param rate the rate factor. Example values:
* - 256: 1x
* - <256: slow down
* - >256: speed up
* - 128: 0.5x
* - 512: 2x
*/
void lv_gstreamer_set_rate(lv_obj_t * gstreamer, uint32_t rate);
/**********************
* MACROS
**********************/
#endif /*LV_USE_GSTREAMER*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_GSTREAMER_H*/
@@ -0,0 +1,74 @@
/**
* @file lv_gstreamer_internal.h
*
*/
#ifndef LV_GSTREAMER_INTERNAL_H
#define LV_GSTREAMER_INTERNAL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../lv_conf_internal.h"
#if LV_USE_GSTREAMER
#include <gst/gst.h>
#include <gst/video/video.h>
#include "../../widgets/image/lv_image_private.h"
#include "lv_gstreamer.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct _lv_gstreamer_t {
lv_image_t image;
lv_image_dsc_t frame;
GstVideoInfo video_info;
GstElement * pipeline;
GstElement * audio_convert;
GstElement * video_convert;
GstElement * audio_volume;
GstSample * last_sample;
lv_timer_t * gstreamer_timer;
GAsyncQueue * frame_queue;
bool is_video_info_valid;
};
typedef struct {
uint8_t * frame_data;
uint32_t width;
uint32_t height;
uint32_t stride;
size_t data_size;
} frame_data_t;
typedef struct _lv_gstreamer_t lv_gstreamer_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif /* LV_USE_GSTREAMER != 0 */
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_GSTREAMER_INTERNAL_H*/
+8
View File
@@ -3079,6 +3079,14 @@
#endif
#endif
/** GStreamer library */
#ifndef LV_USE_GSTREAMER
#ifdef CONFIG_LV_USE_GSTREAMER
#define LV_USE_GSTREAMER CONFIG_LV_USE_GSTREAMER
#else
#define LV_USE_GSTREAMER 0
#endif
#endif
/** Decode bin images to RAM */
#ifndef LV_BIN_DECODER_RAM_LOAD