added my Recipes

This commit is contained in:
2024-07-11 14:16:35 +02:00
parent 38bc4f53ac
commit 09b621d929
7118 changed files with 525762 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
From a638f83022c1a031824ea2ea0ad80064a764504a Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Mon, 13 Dec 2021 12:14:12 +0200
Subject: [PATCH 2/7] touch-player: cleanup the makefile
We don't need all these dependencies anymore
---
Makefile.sdk | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/Makefile.sdk b/Makefile.sdk
index 3eb6d4c..27f2557 100644
--- a/Makefile.sdk
+++ b/Makefile.sdk
@@ -18,23 +18,6 @@ LDFLAGS_ADDONS += $(shell pkg-config --libs gtk+-3.0)
CFLAGS_ADDONS += $(shell pkg-config --cflags gstreamer-1.0)
LDFLAGS_ADDONS += $(shell pkg-config --libs gstreamer-1.0)
-# gstreamer video
-CFLAGS_ADDONS += $(shell pkg-config --cflags gstreamer-video-1.0)
-LDFLAGS_ADDONS += $(shell pkg-config --libs gstreamer-video-1.0)
-
-# gstreamer wayland
-CFLAGS_ADDONS += $(shell pkg-config --cflags gstreamer-wayland-1.0)
-LDFLAGS_ADDONS += $(shell pkg-config --libs gstreamer-wayland-1.0)
-
-# gstreamer plugins base
-CFLAGS_ADDONS += $(shell pkg-config --cflags gstreamer-plugins-base-1.0)
-LDFLAGS_ADDONS += $(shell pkg-config --libs gstreamer-plugins-base-1.0)
-
-# glib
-CFLAGS_ADDONS += $(shell pkg-config --cflags glib-2.0)
-LDFLAGS_ADDONS += $(shell pkg-config --libs glib-2.0)
-
-
CFLAGS_ADDONS += -DHAVE_GST
LDFLAGS_ADDONS += -lpthread
--
2.25.1

View File

@@ -0,0 +1,36 @@
From 3810b08ba588f0790bbf0aae764d36097ae33668 Mon Sep 17 00:00:00 2001
From: George Kiagiadakis <george.kiagiadakis@collabora.com>
Date: Thu, 16 Dec 2021 12:59:27 +0200
Subject: [PATCH 3/7] touch-player: ensure that the gtkwsink is found if it is
a child of playbin's video-sink
This allows starting with a --graph command line option that includes
playbin video-sink="foo ! bar ! gtkwaylandsink name=gtkwsink"
---
main.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
index 0f254e0..91b89d8 100644
--- a/main.c
+++ b/main.c
@@ -263,8 +263,15 @@ build_window (DemoApp * d)
gtk_widget_set_name(d->window_widget, "transparent_bg");
sink = gst_bin_get_by_name (GST_BIN (d->pipeline), "gtkwsink");
- if (!sink && !g_strcmp0 (G_OBJECT_TYPE_NAME (d->pipeline), "GstPlayBin"))
+ if (!sink && !g_strcmp0 (G_OBJECT_TYPE_NAME (d->pipeline), "GstPlayBin")) {
g_object_get (d->pipeline, "video-sink", &sink, NULL);
+ if (sink && g_strcmp0 (G_OBJECT_TYPE_NAME (sink), "GstGtkWaylandSink") != 0
+ && GST_IS_BIN (sink)) {
+ GstBin *sinkbin = GST_BIN (sink);
+ sink = gst_bin_get_by_name (sinkbin, "gtkwsink");
+ gst_object_unref (sinkbin);
+ }
+ }
g_assert (sink);
g_assert (!g_strcmp0 (G_OBJECT_TYPE_NAME (sink), "GstGtkWaylandSink"));
--
2.25.1

View File

@@ -0,0 +1,95 @@
From c7f30dc0fffd6ed56956dc5bebe94fc108ae4fe5 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 16 Dec 2021 14:25:50 +0100
Subject: [PATCH 4/7] touch-player: Use gtk event types for double tap
GTK offers abstactions for double-click etc. which also respect
system settings. In order to provide a clean example for developers,
drop the custom code in favor of them.
Right now the default double click settings are not alligned with
other demos, thus set an application specific override to 600ms.
---
main.c | 47 ++++++++++++-----------------------
1 file changed, 16 insertions(+), 31 deletions(-)
diff --git a/main.c b/main.c
index 91b89d8..bac7c6a 100644
--- a/main.c
+++ b/main.c
@@ -41,7 +41,6 @@ typedef struct
gint current_uri; /* index for argv */
guint32 last_touch_tap;
- guint32 last_pointer_tap;
} DemoApp;
static void
@@ -133,41 +132,21 @@ gstreamer_bus_callback (GstBus * bus, GstMessage * message, void *data)
}
static gboolean
-button_notify_event_cb (GtkWidget * widget, GdkEventButton * event,
+button_notify_event_cb (GtkWidget * widget, GdkEventButton * eventButton,
gpointer data)
{
DemoApp *d = data;
- guint32 diff;
- GstState actual_state;
- g_print("--> %s\n", __FUNCTION__);
+ if (eventButton->type == GDK_BUTTON_PRESS) {
+ GstState actual_state;
- if (event->button == GDK_BUTTON_PRIMARY) {
- if (d->last_pointer_tap == 0) {
- d->last_pointer_tap = event->time;
- gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
- if (actual_state == GST_STATE_PAUSED)
- gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
- else
- gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
- } else {
- diff = event->time - d->last_pointer_tap;
- if (d->last_pointer_tap != 0) {
- d->last_pointer_tap = event->time;
- if (diff < 600) {
- //g_print("--> DOUBLE TAP\n");
- g_main_loop_quit (d->loop);
- } else {
- gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
- if (actual_state == GST_STATE_PAUSED)
- gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
- else
- gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
- //g_print("--> SIMPLE TAP\n");
- }
- //g_print("--> BEGIN diff = %d\n", diff);
- }
- }
+ gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
+ if (actual_state == GST_STATE_PAUSED)
+ gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
+ else
+ gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
+ } else if (eventButton->type == GDK_2BUTTON_PRESS) {
+ g_main_loop_quit (d->loop);
}
/* We've handled the event, stop processing */
@@ -283,6 +262,12 @@ build_window (DemoApp * d)
g_signal_connect (video_widget, "button-press-event",
G_CALLBACK (button_notify_event_cb), d);
+ // Override the system settings to match other demos more closely
+ g_object_set (gtk_settings_get_default (),
+ "gtk-double-click-time", 600,
+ "gtk-double-click-distance", 100,
+ NULL);
+
gtk_container_add(GTK_CONTAINER (d->window_widget), video_widget);
gtk_widget_show_all (d->window_widget);
--
2.25.1

View File

@@ -0,0 +1,98 @@
From 6becd213de6a94c9c6f44b260927ee965fbcbb2b Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 16 Dec 2021 14:32:51 +0100
Subject: [PATCH 5/7] touch-player: Remove touch event handler
It is currently unused. If developers want to handle touch events
differently, they should set the event masks accordingly.
As that is documented well for GTK3 there's arguably no need
to carry a code example around here.
---
main.c | 57 -----------------------------------
1 file changed, 57 deletions(-)
diff --git a/main.c b/main.c
index bac7c6a..173a8a9 100644
--- a/main.c
+++ b/main.c
@@ -39,8 +39,6 @@ typedef struct
gchar **argv;
gint current_uri; /* index for argv */
-
- guint32 last_touch_tap;
} DemoApp;
static void
@@ -153,59 +151,6 @@ button_notify_event_cb (GtkWidget * widget, GdkEventButton * eventButton,
return TRUE;
}
-static gboolean
-touch_notify_event_cb (GtkWidget * widget, GdkEvent * event, gpointer data)
-{
- DemoApp *d = data;
- guint32 diff;
- GstState actual_state;
-
- g_print("--> %s\n", __FUNCTION__);
- switch(event->touch.type) {
- case GDK_TOUCH_BEGIN:
- if (d->last_touch_tap == 0) {
- d->last_touch_tap = event->touch.time;
- gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
- if (actual_state == GST_STATE_PAUSED)
- gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
- else
- gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
- } else {
- diff = event->touch.time - d->last_touch_tap;
- if (d->last_touch_tap != 0) {
- d->last_touch_tap = event->touch.time;
- if (diff < 600) {
- g_print("--> DOUBLE TAP\n");
- g_main_loop_quit (d->loop);
- } else {
- gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
- if (actual_state == GST_STATE_PAUSED)
- gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
- else
- gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
- g_print("--> SIMPLE TAP\n");
- }
- g_print("--> BEGIN diff = %d\n", diff);
- }
- }
- break;
- case GDK_TOUCH_UPDATE:
- //g_print("--> UPDATE\n");
- break;
- case GDK_TOUCH_END:
- //g_print("--> END\n");
- break;
- case GDK_TOUCH_CANCEL:
- //g_print("--> CANCEL\n");
- break;
- default:
- break;
- //g_print("--> something else \n");
- }
- /* We've handled it, stop processing */
- return TRUE;
-}
-
static void
build_window (DemoApp * d)
{
@@ -257,8 +202,6 @@ build_window (DemoApp * d)
g_object_get (sink, "widget", &video_widget, NULL);
gtk_widget_set_support_multidevice (video_widget, TRUE);
gtk_widget_set_vexpand (video_widget, TRUE);
- g_signal_connect (video_widget, "touch-event",
- G_CALLBACK (touch_notify_event_cb), d);
g_signal_connect (video_widget, "button-press-event",
G_CALLBACK (button_notify_event_cb), d);
--
2.25.1

View File

@@ -0,0 +1,25 @@
From 763d938e19cb27979e2d11c7123e6de1ad31321b Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 16 Dec 2021 18:23:10 +0100
Subject: [PATCH 6/7] touch-player: Set default window size
Otherwise the window is unreasonable small, especially on desktops.
---
main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/main.c b/main.c
index 173a8a9..b262fb7 100644
--- a/main.c
+++ b/main.c
@@ -161,6 +161,7 @@ build_window (DemoApp * d)
/* windows */
d->window_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW(d->window_widget), "GStreamer Wayland GTK ");
+ gtk_window_set_default_size (GTK_WINDOW (d->window_widget), 320, 240);
g_signal_connect (d->window_widget, "destroy",
G_CALLBACK (gtk_widget_destroyed), &d->window_widget);
g_signal_connect_swapped (d->window_widget, "destroy",
--
2.25.1

View File

@@ -0,0 +1,197 @@
From 1b69798661d39d5bea14479a4a9b963cbc5f6ef4 Mon Sep 17 00:00:00 2001
From: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
Date: Thu, 30 Mar 2023 10:43:12 +0200
Subject: [PATCH 7/7] TOUCH EVENT: add touch event
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
---
main.c | 90 ++++++++++++++++++++++++++++++++---
1 file changed, 84 insertions(+), 6 deletions(-)
diff --git a/main.c b/main.c
index b262fb7..f3c7444 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,9 @@
static gchar *graph = NULL;
static gchar *shader_file = NULL;
static gboolean nofullscreen = FALSE;
+static gint window_width = 480;
+static gint window_height = 272;
+static guint32 last_touch_tap = 0;
static GOptionEntry entries[] = {
{"nofullscreen", 'F', 0, G_OPTION_ARG_NONE, &nofullscreen,
@@ -56,6 +59,7 @@ msg_state_changed (GstBus * bus, GstMessage * message, gpointer user_data)
{
const GstStructure *s;
DemoApp *d = user_data;
+ (void)bus;
s = gst_message_get_structure (message);
@@ -123,21 +127,71 @@ gstreamer_bus_callback (GstBus * bus, GstMessage * message, void *data)
break;
default:
+/* const GstStructure *s = gst_message_get_structure (message);*/
+/* gchar *str;*/
+/* str = gst_structure_to_string (s);*/
+/* g_print ("BUS %s: %s\n", GST_MESSAGE_TYPE_NAME (message), str);*/
+/* g_free (str);*/
/* unhandled message */
break;
}
return TRUE;
}
+
+
+static gboolean
+touch_notify_event_cb (GtkWidget * widget, GdkEventTouch * eventTouch,
+ gpointer data)
+{
+ DemoApp *d = data;
+ (void)widget;
+ guint32 diff;
+ GstState actual_state;
+
+ if (eventTouch->type == GDK_TOUCH_END || eventTouch->type == GDK_TOUCH_CANCEL) {
+ if (last_touch_tap == 0) {
+ last_touch_tap = eventTouch->time;
+ gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
+ if (actual_state == GST_STATE_PAUSED)
+ gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
+ else
+ gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
+ } else {
+ diff = eventTouch->time - last_touch_tap;
+ if (last_touch_tap != 0) {
+ last_touch_tap = eventTouch->time;
+ if (diff < 600) {
+ //g_print("--> DOUBLE TAP\n");
+ gst_element_set_state (d->pipeline, GST_STATE_NULL);
+ g_main_loop_quit (d->loop);
+ exit(1); //force to quit application
+ } else {
+ gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
+ if (actual_state == GST_STATE_PAUSED)
+ gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
+ else
+ gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
+ //g_print("--> SIMPLE TAP\n");
+ }
+ //g_print("--> BEGIN diff = %d\n", diff);
+ }
+ }
+ }
+
+ /* We've handled the event, stop processing */
+ return TRUE;
+}
+
static gboolean
button_notify_event_cb (GtkWidget * widget, GdkEventButton * eventButton,
gpointer data)
{
DemoApp *d = data;
+ (void)widget;
if (eventButton->type == GDK_BUTTON_PRESS) {
GstState actual_state;
-
gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
if (actual_state == GST_STATE_PAUSED)
gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
@@ -146,11 +200,11 @@ button_notify_event_cb (GtkWidget * widget, GdkEventButton * eventButton,
} else if (eventButton->type == GDK_2BUTTON_PRESS) {
g_main_loop_quit (d->loop);
}
-
/* We've handled the event, stop processing */
return TRUE;
}
+
static void
build_window (DemoApp * d)
{
@@ -186,9 +240,10 @@ build_window (DemoApp * d)
g_object_unref(provider);
gtk_widget_set_name(d->window_widget, "transparent_bg");
-
sink = gst_bin_get_by_name (GST_BIN (d->pipeline), "gtkwsink");
- if (!sink && !g_strcmp0 (G_OBJECT_TYPE_NAME (d->pipeline), "GstPlayBin")) {
+ if (!sink &&
+ (!g_strcmp0 (G_OBJECT_TYPE_NAME (d->pipeline), "GstPlayBin") ||
+ !g_strcmp0 (G_OBJECT_TYPE_NAME (d->pipeline), "GstPlayBin3"))) {
g_object_get (d->pipeline, "video-sink", &sink, NULL);
if (sink && g_strcmp0 (G_OBJECT_TYPE_NAME (sink), "GstGtkWaylandSink") != 0
&& GST_IS_BIN (sink)) {
@@ -205,6 +260,8 @@ build_window (DemoApp * d)
gtk_widget_set_vexpand (video_widget, TRUE);
g_signal_connect (video_widget, "button-press-event",
G_CALLBACK (button_notify_event_cb), d);
+ g_signal_connect (video_widget, "touch-event",
+ G_CALLBACK (touch_notify_event_cb), d);
// Override the system settings to match other demos more closely
g_object_set (gtk_settings_get_default (),
@@ -214,6 +271,8 @@ build_window (DemoApp * d)
gtk_container_add(GTK_CONTAINER (d->window_widget), video_widget);
gtk_widget_show_all (d->window_widget);
+/* gtk_widget_set_can_focus(video_widget, TRUE);*/
+/* gtk_widget_grab_focus (video_widget);*/
g_object_unref (video_widget);
gst_object_unref (sink);
@@ -248,8 +307,26 @@ keyboard_cb (const gchar key_input, gpointer user_data)
gst_element_get_state(d->pipeline, &actual_state, NULL, -1);
if (actual_state == GST_STATE_PLAYING)
gst_element_set_state (d->pipeline, GST_STATE_PAUSED);
- else
+ else {
+/* switch (actual_state){*/
+/* case GST_STATE_VOID_PENDING:*/
+/* g_print("keyboard_cb state: GST_STATE_VOID_PENDING\n");*/
+/* break;*/
+/* case GST_STATE_NULL:*/
+/* g_print("keyboard_cb state: GST_STATE_NULL\n");*/
+/* break;*/
+/* case GST_STATE_READY:*/
+/* g_print("keyboard_cb state: GST_STATE_READY\n");*/
+/* break;*/
+/* case GST_STATE_PAUSED:*/
+/* g_print("keyboard_cb state: GST_STATE_PAUSED\n");*/
+/* break;*/
+/* case GST_STATE_PLAYING:*/
+/* g_print("keyboard_cb state: GST_STATE_PLAYING\n");*/
+/* break;*/
+/* }*/
gst_element_set_state (d->pipeline, GST_STATE_PLAYING);
+ }
break;
}
case 'q':
@@ -265,6 +342,7 @@ io_callback (GIOChannel * io, GIOCondition condition, gpointer data)
{
gchar in;
GError *error = NULL;
+ (void)condition;
switch (g_io_channel_read_chars (io, &in, 1, NULL, &error)) {
case G_IO_STATUS_NORMAL:
@@ -327,7 +405,7 @@ main (int argc, char **argv)
d->argv = argv;
d->current_uri = 1;
- d->pipeline = gst_parse_launch ("playbin video-sink=gtkwaylandsink", &error);
+ d->pipeline = gst_parse_launch ("playbin3 video-sink='gtkwaylandsink name=gtkwsink' ", &error);
if (error)
goto out;
--
2.25.1