2009-08-06 09:23:01 +00:00
|
|
|
/* GStreamer Editing Services
|
2009-11-30 14:14:25 +00:00
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
2009-08-06 09:23:01 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-08-06 09:23:01 +00:00
|
|
|
*/
|
|
|
|
|
2014-11-03 10:51:51 +00:00
|
|
|
/* TODO
|
|
|
|
* Add a deinit function
|
|
|
|
*
|
|
|
|
* Do not forget to
|
|
|
|
* + g_ptr_array_unref (new_paths);
|
|
|
|
* + g_hash_table_unref (tried_uris);
|
|
|
|
*/
|
2014-11-03 10:14:45 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2009-08-06 09:23:01 +00:00
|
|
|
#include <ges/ges.h>
|
2013-06-03 21:02:15 +00:00
|
|
|
#include "ges/gstframepositionner.h"
|
2009-08-06 17:51:29 +00:00
|
|
|
#include "ges-internal.h"
|
2014-08-15 13:48:14 +00:00
|
|
|
#include "ges/nle/nle.h"
|
2009-08-06 09:23:01 +00:00
|
|
|
|
2014-03-16 11:46:26 +00:00
|
|
|
#define GES_GNONLIN_VERSION_NEEDED_MAJOR 1
|
|
|
|
#define GES_GNONLIN_VERSION_NEEDED_MINOR 2
|
2012-05-01 17:48:57 +00:00
|
|
|
#define GES_GNONLIN_VERSION_NEEDED_MICRO 0
|
2011-02-07 12:19:18 +00:00
|
|
|
|
2011-01-11 16:19:54 +00:00
|
|
|
GST_DEBUG_CATEGORY (_ges_debug);
|
2009-08-06 09:23:01 +00:00
|
|
|
|
2012-11-27 15:53:14 +00:00
|
|
|
static gboolean ges_initialized = FALSE;
|
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
struct _elements_entry
|
2011-02-07 12:19:18 +00:00
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
const gchar *name;
|
|
|
|
GType (*type) (void);
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct _elements_entry _elements[] = {
|
|
|
|
{"nlesource", nle_source_get_type},
|
|
|
|
{"nlecomposition", nle_composition_get_type},
|
|
|
|
{"nleoperation", nle_operation_get_type},
|
|
|
|
{"nleurisource", nle_urisource_get_type},
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
2011-02-07 12:19:18 +00:00
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
/**
|
|
|
|
* ges_init:
|
|
|
|
*
|
|
|
|
* Initialize the GStreamer Editing Service. Call this before any usage of
|
2011-05-18 14:46:34 +00:00
|
|
|
* GES. You should take care of initilizing GStreamer before calling this
|
|
|
|
* function.
|
2009-09-10 16:40:51 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-07 12:19:18 +00:00
|
|
|
gboolean
|
2009-08-06 09:23:01 +00:00
|
|
|
ges_init (void)
|
|
|
|
{
|
2014-08-15 13:48:14 +00:00
|
|
|
gint i = 0;
|
|
|
|
|
2009-08-06 09:23:01 +00:00
|
|
|
/* initialize debugging category */
|
2011-01-11 16:19:54 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (_ges_debug, "ges", GST_DEBUG_FG_YELLOW,
|
2009-08-06 09:23:01 +00:00
|
|
|
"GStreamer Editing Services");
|
2009-08-07 14:46:35 +00:00
|
|
|
|
2012-11-27 15:53:14 +00:00
|
|
|
if (ges_initialized) {
|
|
|
|
GST_DEBUG ("already initialized ges");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-02-08 20:11:22 +00:00
|
|
|
/* register clip classes with the system */
|
2010-09-23 13:49:04 +00:00
|
|
|
|
2013-01-17 03:58:28 +00:00
|
|
|
GES_TYPE_TEST_CLIP;
|
2013-01-20 15:44:57 +00:00
|
|
|
GES_TYPE_URI_CLIP;
|
2013-01-17 03:55:03 +00:00
|
|
|
GES_TYPE_TITLE_CLIP;
|
2013-01-25 18:16:21 +00:00
|
|
|
GES_TYPE_TRANSITION_CLIP;
|
2013-01-17 03:49:43 +00:00
|
|
|
GES_TYPE_OVERLAY_CLIP;
|
2010-09-23 13:49:04 +00:00
|
|
|
|
2013-06-26 21:08:57 +00:00
|
|
|
GES_TYPE_GROUP;
|
|
|
|
|
2012-09-23 00:05:42 +00:00
|
|
|
/* register formatter types with the system */
|
2013-09-16 14:16:18 +00:00
|
|
|
GES_TYPE_PITIVI_FORMATTER;
|
2012-11-19 16:24:03 +00:00
|
|
|
GES_TYPE_XML_FORMATTER;
|
|
|
|
|
2013-02-08 19:39:18 +00:00
|
|
|
/* Register track elements */
|
2013-01-26 15:40:51 +00:00
|
|
|
GES_TYPE_EFFECT;
|
2012-12-17 18:23:39 +00:00
|
|
|
|
2012-11-27 16:53:22 +00:00
|
|
|
/* Register interfaces */
|
2012-12-17 18:23:39 +00:00
|
|
|
GES_TYPE_META_CONTAINER;
|
2012-09-23 00:05:42 +00:00
|
|
|
|
2012-09-10 00:15:17 +00:00
|
|
|
ges_asset_cache_init ();
|
|
|
|
|
2013-06-03 21:02:15 +00:00
|
|
|
gst_element_register (NULL, "framepositionner", 0,
|
|
|
|
GST_TYPE_FRAME_POSITIONNER);
|
2013-09-09 15:47:32 +00:00
|
|
|
gst_element_register (NULL, "gespipeline", 0, GES_TYPE_PIPELINE);
|
2013-06-03 21:02:15 +00:00
|
|
|
|
2014-08-15 13:48:14 +00:00
|
|
|
for (; _elements[i].name; i++)
|
|
|
|
if (!(gst_element_register (NULL,
|
|
|
|
_elements[i].name, GST_RANK_NONE, (_elements[i].type) ())))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
nle_init_ghostpad_category ();
|
|
|
|
|
2010-09-23 13:49:04 +00:00
|
|
|
/* TODO: user-defined types? */
|
2012-11-27 15:53:14 +00:00
|
|
|
ges_initialized = TRUE;
|
2010-09-23 13:49:04 +00:00
|
|
|
|
2009-08-07 14:46:35 +00:00
|
|
|
GST_DEBUG ("GStreamer Editing Services initialized");
|
2011-02-07 12:19:18 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2009-08-06 09:23:01 +00:00
|
|
|
}
|
2011-12-26 01:54:29 +00:00
|
|
|
|
2014-11-03 10:14:45 +00:00
|
|
|
#ifndef GST_DISABLE_OPTION_PARSING
|
|
|
|
static gboolean
|
|
|
|
parse_goption_arg (const gchar * s_opt,
|
|
|
|
const gchar * arg, gpointer data, GError ** err)
|
|
|
|
{
|
|
|
|
if (g_strcmp0 (s_opt, "--ges-version") == 0) {
|
|
|
|
g_print ("GStreamer Editing Services version %s\n", PACKAGE_VERSION);
|
|
|
|
exit (0);
|
2014-11-03 11:18:35 +00:00
|
|
|
} else if (g_strcmp0 (s_opt, "--ges-sample-paths") == 0) {
|
|
|
|
ges_add_missing_uri_relocation_uri (arg, FALSE);
|
|
|
|
} else if (g_strcmp0 (s_opt, "--ges-sample-path-recurse") == 0) {
|
|
|
|
ges_add_missing_uri_relocation_uri (arg, TRUE);
|
2014-11-03 10:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_init_get_option_group: (skip)
|
|
|
|
*
|
|
|
|
* Returns a #GOptionGroup with GES's argument specifications. The
|
|
|
|
* group is set up to use standard GOption callbacks, so when using this
|
|
|
|
* group in combination with GOption parsing methods, all argument parsing
|
|
|
|
* and initialization is automated.
|
|
|
|
*
|
|
|
|
* This function is useful if you want to integrate GES with other
|
|
|
|
* libraries that use GOption (see g_option_context_add_group() ).
|
|
|
|
*
|
|
|
|
* If you use this function, you should make sure you initialise the GStreamer
|
|
|
|
* as one of the very first things in your program.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a pointer to GES's option group.
|
|
|
|
*/
|
|
|
|
GOptionGroup *
|
|
|
|
ges_init_get_option_group (void)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_OPTION_PARSING
|
|
|
|
|
|
|
|
GOptionGroup *group;
|
|
|
|
static const GOptionEntry ges_args[] = {
|
|
|
|
{"ges-version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
(gpointer) parse_goption_arg,
|
|
|
|
"Print the GStreamer Editing Services version",
|
|
|
|
NULL},
|
2014-11-03 11:18:35 +00:00
|
|
|
{"ges-sample-paths", 0, 0, G_OPTION_ARG_CALLBACK,
|
|
|
|
(gpointer) parse_goption_arg,
|
2014-11-03 10:51:51 +00:00
|
|
|
"List of pathes to look assets in if they were moved"},
|
2014-11-03 11:18:35 +00:00
|
|
|
{"ges-sample-path-recurse", 0, 0, G_OPTION_ARG_CALLBACK,
|
|
|
|
(gpointer) parse_goption_arg,
|
2014-11-03 10:51:51 +00:00
|
|
|
"Same as above, but recursing into the folder"},
|
2014-11-03 10:14:45 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
group = g_option_group_new ("GES", "GStreamer Editing Services Options",
|
|
|
|
"Show GStreamer Options", NULL, NULL);
|
|
|
|
g_option_group_add_entries (group, ges_args);
|
|
|
|
|
|
|
|
return group;
|
|
|
|
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
2011-12-26 01:54:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_version:
|
|
|
|
* @major: (out): pointer to a guint to store the major version number
|
|
|
|
* @minor: (out): pointer to a guint to store the minor version number
|
|
|
|
* @micro: (out): pointer to a guint to store the micro version number
|
|
|
|
* @nano: (out): pointer to a guint to store the nano version number
|
|
|
|
*
|
|
|
|
* Gets the version number of the GStreamer Editing Services library.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ges_version (guint * major, guint * minor, guint * micro, guint * nano)
|
|
|
|
{
|
|
|
|
g_return_if_fail (major);
|
|
|
|
g_return_if_fail (minor);
|
|
|
|
g_return_if_fail (micro);
|
|
|
|
g_return_if_fail (nano);
|
|
|
|
|
|
|
|
*major = GES_VERSION_MAJOR;
|
|
|
|
*minor = GES_VERSION_MINOR;
|
|
|
|
*micro = GES_VERSION_MICRO;
|
|
|
|
*nano = GES_VERSION_NANO;
|
|
|
|
}
|
2014-11-03 10:59:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_init_check:
|
|
|
|
* @argc: (inout) (allow-none): pointer to application's argc
|
|
|
|
* @argv: (inout) (array length=argc) (allow-none): pointer to application's argv
|
|
|
|
* @err: pointer to a #GError to which a message will be posted on error
|
|
|
|
*
|
|
|
|
* Initializes the GStreamer Editing Services library, setting up internal path lists,
|
|
|
|
* and loading evrything needed.
|
|
|
|
*
|
|
|
|
* This function will return %FALSE if GES could not be initialized
|
|
|
|
* for some reason.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if GES could be initialized.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_init_check (int *argc, char **argv[], GError ** err)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_OPTION_PARSING
|
|
|
|
GOptionGroup *group;
|
|
|
|
GOptionContext *ctx;
|
|
|
|
#endif
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
if (ges_initialized) {
|
|
|
|
GST_DEBUG ("already initialized ges");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#ifndef GST_DISABLE_OPTION_PARSING
|
|
|
|
ctx = g_option_context_new ("- GStreamer Editing Services initialization");
|
|
|
|
g_option_context_set_ignore_unknown_options (ctx, TRUE);
|
|
|
|
g_option_context_set_help_enabled (ctx, FALSE);
|
|
|
|
group = ges_init_get_option_group ();
|
|
|
|
g_option_context_add_group (ctx, group);
|
|
|
|
res = g_option_context_parse (ctx, argc, argv, err);
|
|
|
|
g_option_context_free (ctx);
|
|
|
|
#endif
|
|
|
|
if (!res)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
return ges_init ();
|
|
|
|
}
|