2015-03-14 20:52:47 +00:00
|
|
|
/* GStreamer Editing Services GStreamer plugin
|
|
|
|
* Copyright (C) 2019 Thibault Saunier <tsaunier@igalia.com>
|
|
|
|
*
|
|
|
|
* gessrc.c
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
|
|
|
|
**
|
2019-06-06 19:40:57 +00:00
|
|
|
* SECTION:element-gessrc
|
2015-03-14 20:52:47 +00:00
|
|
|
* @short_description: A GstBin subclasses use to use GESTimeline
|
|
|
|
* as sources inside any GstPipeline.
|
|
|
|
* @see_also: #GESTimeline
|
|
|
|
*
|
|
|
|
* The gessrc is a bin that will simply expose the track src pads
|
|
|
|
* and implements the GstUriHandler interface using a custom `ges://`
|
|
|
|
* uri scheme.
|
2019-06-06 14:16:50 +00:00
|
|
|
*
|
2015-03-14 20:52:47 +00:00
|
|
|
* NOTE: That to use it inside playbin and friends you **need** to
|
|
|
|
* set gessrc::timeline property yourself.
|
2019-06-06 14:16:50 +00:00
|
|
|
*
|
2015-03-14 20:52:47 +00:00
|
|
|
* Example with #playbin:
|
2019-06-06 14:16:50 +00:00
|
|
|
*
|
2015-03-14 20:52:47 +00:00
|
|
|
* {{../../examples/c/gessrc.c}}
|
2019-06-06 14:16:50 +00:00
|
|
|
*
|
2015-03-14 20:52:47 +00:00
|
|
|
* Example with #GstPlayer:
|
2019-06-06 14:16:50 +00:00
|
|
|
*
|
2015-03-14 20:52:47 +00:00
|
|
|
* {{../../examples/python/gst-player.py}}
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2019-06-06 14:16:50 +00:00
|
|
|
#include <ges/ges.h>
|
2015-03-14 20:52:47 +00:00
|
|
|
|
2019-06-06 17:51:45 +00:00
|
|
|
#include "gesbasebin.h"
|
|
|
|
|
2015-03-14 20:52:47 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gessrc);
|
|
|
|
#define GST_CAT_DEFAULT gessrc
|
|
|
|
|
2019-06-06 17:51:45 +00:00
|
|
|
G_DECLARE_FINAL_TYPE (GESSrc, ges_src, GES, SRC, GESBaseBin);
|
2019-06-06 14:16:50 +00:00
|
|
|
struct _GESSrc
|
|
|
|
{
|
2019-06-06 17:51:45 +00:00
|
|
|
GESBaseBin parent;
|
2023-06-15 21:38:30 +00:00
|
|
|
|
|
|
|
gchar *uri;
|
2019-06-06 14:16:50 +00:00
|
|
|
};
|
|
|
|
#define GES_SRC(obj) ((GESSrc*) obj)
|
|
|
|
|
2015-03-14 20:52:47 +00:00
|
|
|
/*** GSTURIHANDLER INTERFACE *************************************************/
|
|
|
|
|
|
|
|
static GstURIType
|
|
|
|
ges_src_uri_get_type (GType type)
|
|
|
|
{
|
|
|
|
return GST_URI_SRC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *const *
|
|
|
|
ges_src_uri_get_protocols (GType type)
|
|
|
|
{
|
|
|
|
static const gchar *protocols[] = { "ges", NULL };
|
|
|
|
|
|
|
|
return protocols;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
ges_src_uri_get_uri (GstURIHandler * handler)
|
|
|
|
{
|
|
|
|
GESSrc *self = GES_SRC (handler);
|
2019-06-06 17:51:45 +00:00
|
|
|
GESTimeline *timeline = ges_base_bin_get_timeline (GES_BASE_BIN (self));
|
2015-03-14 20:52:47 +00:00
|
|
|
|
2023-06-15 21:38:30 +00:00
|
|
|
GST_OBJECT_LOCK (self);
|
|
|
|
if (self->uri) {
|
|
|
|
gchar *uri = g_strdup (self->uri);
|
|
|
|
|
|
|
|
GST_OBJECT_UNLOCK (self);
|
|
|
|
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (self);
|
|
|
|
|
2021-01-15 18:21:06 +00:00
|
|
|
return ges_command_line_formatter_get_timeline_uri (timeline);
|
2015-03-14 20:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2021-01-15 18:03:20 +00:00
|
|
|
ges_src_uri_set_uri (GstURIHandler * handler, const gchar * uristr,
|
2015-03-14 20:52:47 +00:00
|
|
|
GError ** error)
|
|
|
|
{
|
2021-01-15 18:03:20 +00:00
|
|
|
gboolean res = FALSE;
|
2023-06-15 21:38:30 +00:00
|
|
|
GESSrc *self = GES_SRC (handler);
|
2021-01-15 18:03:20 +00:00
|
|
|
GstUri *uri = gst_uri_from_string (uristr);
|
|
|
|
GESProject *project = NULL;
|
|
|
|
GESTimeline *timeline = NULL;
|
|
|
|
|
|
|
|
if (!gst_uri_get_path (uri)) {
|
|
|
|
GST_INFO_OBJECT (handler, "User need to specify the timeline");
|
|
|
|
res = TRUE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
project = ges_project_new (uristr);
|
|
|
|
timeline = (GESTimeline *) ges_asset_extract (GES_ASSET (project), NULL);
|
|
|
|
|
|
|
|
if (timeline)
|
|
|
|
res = ges_base_bin_set_timeline (GES_BASE_BIN (handler), timeline);
|
|
|
|
|
|
|
|
done:
|
|
|
|
gst_uri_unref (uri);
|
|
|
|
gst_clear_object (&project);
|
|
|
|
|
2023-06-15 21:38:30 +00:00
|
|
|
GST_OBJECT_LOCK (handler);
|
|
|
|
g_free (self->uri);
|
|
|
|
self->uri = g_strdup (uristr);
|
|
|
|
GST_OBJECT_UNLOCK (handler);
|
|
|
|
|
2021-01-15 18:03:20 +00:00
|
|
|
return res;
|
2015-03-14 20:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
|
|
|
{
|
|
|
|
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
|
|
|
|
|
|
|
|
iface->get_type = ges_src_uri_get_type;
|
|
|
|
iface->get_protocols = ges_src_uri_get_protocols;
|
|
|
|
iface->get_uri = ges_src_uri_get_uri;
|
|
|
|
iface->set_uri = ges_src_uri_set_uri;
|
|
|
|
}
|
|
|
|
|
2019-06-06 17:51:45 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESSrc, ges_src, ges_base_bin_get_type (),
|
2015-03-14 20:52:47 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, ges_src_uri_handler_init));
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_src_class_init (GESSrcClass * self_class)
|
|
|
|
{
|
|
|
|
GstElementClass *gstelement_klass = GST_ELEMENT_CLASS (self_class);
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gessrc, "gessrc", 0, "ges src element");
|
2019-06-06 17:51:45 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_klass,
|
|
|
|
"GStreamer Editing Services based 'source'",
|
|
|
|
"Codec/Source/Editing",
|
|
|
|
"Source for GESTimeline.", "Thibault Saunier <tsaunier@igalia.com");
|
2015-03-14 20:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_src_init (GESSrc * self)
|
|
|
|
{
|
2019-08-27 14:02:04 +00:00
|
|
|
SUPRESS_UNUSED_WARNING (GES_SRC);
|
|
|
|
SUPRESS_UNUSED_WARNING (GES_IS_SRC);
|
build: also suppress unused-function warnings about g_autoptr
../plugins/ges/gesdemux.c:50:1: error: unused function 'glib_autoptr_cleanup_GESDemux' [-Werror,-Wunused-function]
G_DECLARE_FINAL_TYPE (GESDemux, ges_demux, GES, DEMUX, GESBaseBin);
^
/home/matt/Projects/cerbero/build/dist/android_universal/x86_64/include/glib-2.0/gobject/gtype.h:1401:3: note: expanded from macro 'G_DECLARE_FINAL_TYPE'
_GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \
^
/home/matt/Projects/cerbero/build/dist/android_universal/x86_64/include/glib-2.0/glib/gmacros.h:451:22: note: expanded from macro '_GLIB_DEFINE_AUTOPTR_CHAINUP'
static inline void _GLIB_AUTOPTR_FUNC_NAME(ModuleObjName) (ModuleObjName **_ptr) { \
^
/home/matt/Projects/cerbero/build/dist/android_universal/x86_64/include/glib-2.0/glib/gmacros.h:441:43: note: expanded from macro '_GLIB_AUTOPTR_FUNC_NAME'
#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
^
<scratch space>:81:1: note: expanded from here
glib_autoptr_cleanup_GESDemux
^
../plugins/ges/gessrc.c:56:1: error: unused function 'glib_autoptr_cleanup_GESSrc' [-Werror,-Wunused-function]
G_DECLARE_FINAL_TYPE (GESSrc, ges_src, GES, SRC, GESBaseBin);
^
/home/matt/Projects/cerbero/build/dist/android_universal/x86_64/include/glib-2.0/gobject/gtype.h:1401:3: note: expanded from macro 'G_DECLARE_FINAL_TYPE'
_GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \
^
/home/matt/Projects/cerbero/build/dist/android_universal/x86_64/include/glib-2.0/glib/gmacros.h:451:22: note: expanded from macro '_GLIB_DEFINE_AUTOPTR_CHAINUP'
static inline void _GLIB_AUTOPTR_FUNC_NAME(ModuleObjName) (ModuleObjName **_ptr) { \
^
/home/matt/Projects/cerbero/build/dist/android_universal/x86_64/include/glib-2.0/glib/gmacros.h:441:43: note: expanded from macro '_GLIB_AUTOPTR_FUNC_NAME'
#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
^
<scratch space>:158:1: note: expanded from here
glib_autoptr_cleanup_GESSrc
^
2019-08-28 08:13:06 +00:00
|
|
|
#if defined(g_autoptr)
|
|
|
|
SUPRESS_UNUSED_WARNING (glib_autoptr_cleanup_GESSrc);
|
|
|
|
#endif
|
2015-03-14 20:52:47 +00:00
|
|
|
}
|