mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
plugin: Add context handler base class
In order to bridge work with GL between GTK and GStreamer reliably, we need to create and check context capabilities ahead of time. We also need to be able to query context at any time during playback. Also we should avoid changing importers on context queries, this can lead to all sort of problems. To be able to achieve all of above, introduce new context handler base class that works separately of importers.
This commit is contained in:
86
lib/gst/plugin/gstclappercontexthandler.c
vendored
Normal file
86
lib/gst/plugin/gstclappercontexthandler.c
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rafał Dzięgiel <rafostar.github@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstclappercontexthandler.h"
|
||||
|
||||
#define parent_class gst_clapper_context_handler_parent_class
|
||||
G_DEFINE_TYPE (GstClapperContextHandler, gst_clapper_context_handler, GST_TYPE_OBJECT);
|
||||
|
||||
static gboolean
|
||||
_default_handle_context_query (GstClapperContextHandler *self,
|
||||
GstBaseSink *bsink, GstQuery *query)
|
||||
{
|
||||
GST_FIXME_OBJECT (self, "Need to handle context query");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_clapper_context_handler_init (GstClapperContextHandler *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_clapper_context_handler_finalize (GObject *object)
|
||||
{
|
||||
GstClapperContextHandler *self = GST_CLAPPER_CONTEXT_HANDLER_CAST (object);
|
||||
|
||||
GST_TRACE_OBJECT (self, "Finalize");
|
||||
|
||||
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_clapper_context_handler_class_init (GstClapperContextHandlerClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
GstClapperContextHandlerClass *handler_class = (GstClapperContextHandlerClass *) klass;
|
||||
|
||||
gobject_class->finalize = gst_clapper_context_handler_finalize;
|
||||
|
||||
handler_class->handle_context_query = _default_handle_context_query;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_clapper_context_handler_handle_context_query (GstClapperContextHandler *self,
|
||||
GstBaseSink *bsink, GstQuery *query)
|
||||
{
|
||||
GstClapperContextHandlerClass *handler_class = GST_CLAPPER_CONTEXT_HANDLER_GET_CLASS (self);
|
||||
|
||||
return handler_class->handle_context_query (self, bsink, query);
|
||||
}
|
||||
|
||||
GstClapperContextHandler *
|
||||
gst_clapper_context_handler_obtain_with_type (GPtrArray *context_handlers, GType type)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < context_handlers->len; i++) {
|
||||
GstClapperContextHandler *handler = g_ptr_array_index (context_handlers, i);
|
||||
|
||||
if (G_TYPE_CHECK_INSTANCE_TYPE (handler, type))
|
||||
return gst_object_ref (handler);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
62
lib/gst/plugin/gstclappercontexthandler.h
vendored
Normal file
62
lib/gst/plugin/gstclappercontexthandler.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rafał Dzięgiel <rafostar.github@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstbasesink.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_CLAPPER_CONTEXT_HANDLER (gst_clapper_context_handler_get_type())
|
||||
#define GST_IS_CLAPPER_CONTEXT_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_CONTEXT_HANDLER))
|
||||
#define GST_IS_CLAPPER_CONTEXT_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CLAPPER_CONTEXT_HANDLER))
|
||||
#define GST_CLAPPER_CONTEXT_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER_CONTEXT_HANDLER, GstClapperContextHandlerClass))
|
||||
#define GST_CLAPPER_CONTEXT_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_CONTEXT_HANDLER, GstClapperContextHandler))
|
||||
#define GST_CLAPPER_CONTEXT_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CLAPPER_CONTEXT_HANDLER, GstClapperContextHandlerClass))
|
||||
#define GST_CLAPPER_CONTEXT_HANDLER_CAST(obj) ((GstClapperContextHandler *)(obj))
|
||||
|
||||
typedef struct _GstClapperContextHandler GstClapperContextHandler;
|
||||
typedef struct _GstClapperContextHandlerClass GstClapperContextHandlerClass;
|
||||
|
||||
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstClapperContextHandler, gst_object_unref)
|
||||
#endif
|
||||
|
||||
struct _GstClapperContextHandler
|
||||
{
|
||||
GstObject parent;
|
||||
};
|
||||
|
||||
struct _GstClapperContextHandlerClass
|
||||
{
|
||||
GstObjectClass parent_class;
|
||||
|
||||
gboolean (* handle_context_query) (GstClapperContextHandler *handler,
|
||||
GstBaseSink *bsink,
|
||||
GstQuery *query);
|
||||
};
|
||||
|
||||
GType gst_clapper_context_handler_get_type (void);
|
||||
|
||||
gboolean gst_clapper_context_handler_handle_context_query (GstClapperContextHandler *handler, GstBaseSink *bsink, GstQuery *query);
|
||||
|
||||
GstClapperContextHandler * gst_clapper_context_handler_obtain_with_type (GPtrArray *context_handlers, GType type);
|
||||
|
||||
G_END_DECLS
|
1
lib/gst/plugin/meson.build
vendored
1
lib/gst/plugin/meson.build
vendored
@@ -41,6 +41,7 @@ gst_clapper_plugin_sources = [
|
||||
'gstclapperpaintable.c',
|
||||
'gstgtkutils.c',
|
||||
'gstplugin.c',
|
||||
'gstclappercontexthandler.c',
|
||||
'gstclapperimporter.c',
|
||||
'gstclapperimporterloader.c',
|
||||
]
|
||||
|
Reference in New Issue
Block a user