| 1 |
/* GStreamer Wayland Library |
| 2 |
* |
| 3 |
* Copyright (C) 2022 Collabora Ltd. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Library General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Library General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Library General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 |
* Boston, MA 02110-1301 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifdef HAVE_CONFIG_H |
| 22 |
#include <config.h> |
| 23 |
#endif |
| 24 |
|
| 25 |
#include "gstwlcontext.h" |
| 26 |
|
| 27 |
gboolean |
| 28 |
gst_is_wl_display_handle_need_context_message (GstMessage * msg) |
| 29 |
{ |
| 30 |
const gchar *type = NULL; |
| 31 |
|
| 32 |
g_return_val_if_fail (GST_IS_MESSAGE (msg), FALSE); |
| 33 |
|
| 34 |
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_NEED_CONTEXT && |
| 35 |
gst_message_parse_context_type (msg, &type)) { |
| 36 |
return !g_strcmp0 (type, GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE) || |
| 37 |
!g_strcmp0 (type, GST_WL_DISPLAY_HANDLE_LEGACY_CONTEXT_TYPE); |
| 38 |
} |
| 39 |
|
| 40 |
return FALSE; |
| 41 |
} |
| 42 |
|
| 43 |
GstContext * |
| 44 |
gst_wl_display_handle_context_new (struct wl_display *display) |
| 45 |
{ |
| 46 |
GstContext *context = |
| 47 |
gst_context_new (GST_WL_DISPLAY_HANDLE_CONTEXT_TYPE, TRUE); |
| 48 |
gst_structure_set (gst_context_writable_structure (context), |
| 49 |
"display", G_TYPE_POINTER, display, NULL); |
| 50 |
return context; |
| 51 |
} |
| 52 |
|
| 53 |
struct wl_display * |
| 54 |
gst_wl_display_handle_context_get_handle (GstContext * context) |
| 55 |
{ |
| 56 |
const GstStructure *s; |
| 57 |
struct wl_display *display; |
| 58 |
|
| 59 |
g_return_val_if_fail (GST_IS_CONTEXT (context), NULL); |
| 60 |
|
| 61 |
s = gst_context_get_structure (context); |
| 62 |
if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL)) |
| 63 |
return display; |
| 64 |
/* backward compatibility */ |
| 65 |
if (gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL)) |
| 66 |
return display; |
| 67 |
return NULL; |
| 68 |
} |