From 95470640524ef8f3c039d34bd99e552732070a4a Mon Sep 17 00:00:00 2001 From: Florian Zwoch Date: Thu, 4 Jan 2024 09:54:05 +0100 Subject: [PATCH] handle more potential options (#24) Expose more GstElement properties. This bumps required GStreamer version to 1.20. --- .github/workflows/build.yaml | 19 ++--------------- Dockerfile | 5 +---- meson.build | 2 +- obs-vaapi.c | 40 +++++++++++++++++++++++++++++------- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cea1d76..9f06391 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,30 +6,15 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Build x86_64 run: | meson setup --buildtype=release -Dlibobs=disabled -Dc_args=-I/obs -Dc_link_args='-Wl,--unresolved-symbols=ignore-all -static-libgcc' x86_64 meson compile -C x86_64 - - name: Generate aarch64 cross file - run: | - echo "[binaries]" > aarch64.txt - echo "c = 'aarch64-linux-gnu-gcc'" >> aarch64.txt - echo "strip = 'aarch64-linux-gnu-strip'" >> aarch64.txt - echo "pkgconfig = 'aarch64-linux-gnu-pkg-config'" >> aarch64.txt - echo "" >> aarch64.txt - echo "[host_machine]" >> aarch64.txt - echo "system = 'linux'" >> aarch64.txt - echo "cpu_family = 'aarch64'" >> aarch64.txt - echo "cpu = 'aarch64'" >> aarch64.txt - echo "endian = 'little'" >> aarch64.txt - - name: Build aarch64 - run: | - meson setup --cross-file=aarch64.txt --buildtype=release -Dlibobs=disabled -Dc_args=-I/obs -Dc_link_args='-Wl,--unresolved-symbols=ignore-all -static-libgcc' aarch64 - meson compile -C aarch64 + - name: Upload artifacts uses: actions/upload-artifact@v3 with: name: obs-vaapi path: | x86_64/*.so - aarch64/*.so diff --git a/Dockerfile b/Dockerfile index 4010236..93c8b7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,15 +18,12 @@ # along with obs-vaapi. If not, see . # -FROM debian:bullseye - -RUN dpkg --add-architecture arm64 +FROM debian:bookworm RUN apt update \ && apt install -y \ git ninja-build meson wget dpkg-dev \ gcc libsimde-dev libgstreamer-plugins-base1.0-dev libpci-dev \ - gcc-aarch64-linux-gnu libsimde-dev:arm64 libgstreamer-plugins-base1.0-dev:arm64 libpci-dev:arm64 \ && rm -rf /var/lib/apt/lists/* RUN wget https://github.com/obsproject/obs-studio/archive/refs/tags/28.0.0.tar.gz \ diff --git a/meson.build b/meson.build index 420b6f9..36dcb3a 100644 --- a/meson.build +++ b/meson.build @@ -34,7 +34,7 @@ library('obs-vaapi', ), dependencies : [ dependency('libobs', version : '>=28.0.0', required : get_option('libobs')), - dependency('gstreamer-1.0'), + dependency('gstreamer-1.0', version : '>=1.20'), dependency('gstreamer-app-1.0'), dependency('gstreamer-video-1.0'), dependency('libpci'), diff --git a/obs-vaapi.c b/obs-vaapi.c index 6c10a31..cf337ed 100644 --- a/obs-vaapi.c +++ b/obs-vaapi.c @@ -269,7 +269,8 @@ static void *create(obs_data_t *settings, obs_encoder_t *encoder) vaapiencoder = gst_element_factory_make( obs_encoder_get_id(encoder) + strlen("obs-va-"), NULL); - } else { + } else if (g_str_has_prefix(obs_encoder_get_id(encoder), + "obs-vaapi-")) { g_setenv("GST_VAAPI_DRM_DEVICE", obs_data_get_string(settings, "device"), TRUE); @@ -322,8 +323,9 @@ static void *create(obs_data_t *settings, obs_encoder_t *encoder) const char *name = obs_property_name(property); switch (obs_property_get_type(property)) { case OBS_PROPERTY_TEXT: - g_object_set(vaapiencoder, name, - obs_data_get_string(settings, name), NULL); + gst_util_set_object_arg(G_OBJECT(vaapiencoder), name, + obs_data_get_string(settings, + name)); blog(LOG_INFO, "[obs-vaapi] %s: %s", name, obs_data_get_string(settings, name)); break; @@ -532,7 +534,7 @@ static void get_defaults2(obs_data_t *settings, void *type_data) if (g_str_has_prefix(type_data, "obs-va-")) { encoder = gst_element_factory_make( type_data + strlen("obs-va-"), NULL); - } else { + } else if (g_str_has_prefix(type_data, "obs-vaapi-")) { encoder = gst_element_factory_make( type_data + strlen("obs-vaapi-"), NULL); @@ -621,7 +623,19 @@ static void get_defaults2(obs_data_t *settings, void *type_data) } } } else if (GST_IS_PARAM_SPEC_ARRAY_LIST(param)) { - // not implemented + obs_data_set_default_string( + settings, param->name, + gst_value_serialize(&value)); + } else if (G_VALUE_TYPE(&value) == GST_TYPE_STRUCTURE) { + const GstStructure *s = + gst_value_get_structure(&value); + if (s != NULL) { + gchar *str = gst_structure_serialize( + s, GST_SERIALIZE_FLAG_NONE); + obs_data_set_default_string( + settings, param->name, str); + g_free(str); + } } else { blog(LOG_WARNING, "[obs-vaapi] unhandled property: %s", @@ -686,7 +700,7 @@ static obs_properties_t *get_properties2(void *data, void *type_data) if (g_str_has_prefix(type_data, "obs-va-")) { encoder = gst_element_factory_make( type_data + strlen("obs-va-"), NULL); - } else { + } else if (g_str_has_prefix(type_data, "obs-vaapi-")) { encoder = gst_element_factory_make( type_data + strlen("obs-vaapi-"), NULL); @@ -810,7 +824,19 @@ static obs_properties_t *get_properties2(void *data, void *type_data) property, g_param_spec_get_blurb(param)); } else if (GST_IS_PARAM_SPEC_ARRAY_LIST(param)) { - // not implemented + property = obs_properties_add_text( + properties, param->name, param->name, + OBS_TEXT_DEFAULT); + obs_property_set_long_description( + property, + g_param_spec_get_blurb(param)); + } else if (G_VALUE_TYPE(&value) == GST_TYPE_STRUCTURE) { + property = obs_properties_add_text( + properties, param->name, param->name, + OBS_TEXT_DEFAULT); + obs_property_set_long_description( + property, + g_param_spec_get_blurb(param)); } else { blog(LOG_WARNING, "[obs-vaapi] unhandled property: %s",