mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-03 15:06:34 +00:00
formatter: Implement the GESExtractable interface
Make it a GInitially unowned, GESProject will become the owner
This commit is contained in:
parent
346a01b4eb
commit
a89683f06a
2 changed files with 75 additions and 3 deletions
|
@ -51,7 +51,11 @@
|
|||
#include "ges-internal.h"
|
||||
#include "ges.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GESFormatter, ges_formatter, G_TYPE_OBJECT);
|
||||
static void ges_extractable_interface_init (GESExtractableInterface * iface);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GESFormatter, ges_formatter,
|
||||
G_TYPE_INITIALLY_UNOWNED, G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
|
||||
ges_extractable_interface_init));
|
||||
|
||||
struct _GESFormatterPrivate
|
||||
{
|
||||
|
@ -71,6 +75,74 @@ enum
|
|||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
/* Utils */
|
||||
static GESFormatterClass *
|
||||
ges_formatter_find_for_uri (const gchar * uri)
|
||||
{
|
||||
GType *formatters;
|
||||
guint n_formatters, i;
|
||||
GESFormatterClass *class, *ret = NULL;
|
||||
|
||||
formatters = g_type_children (GES_TYPE_FORMATTER, &n_formatters);
|
||||
for (i = 0; i < n_formatters; i++) {
|
||||
class = g_type_class_ref (formatters[i]);
|
||||
|
||||
if (class->can_load_uri (uri, NULL)) {
|
||||
ret = class;
|
||||
break;
|
||||
}
|
||||
g_type_class_unref (class);
|
||||
}
|
||||
|
||||
g_free (formatters);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* GESExtractable implementation */
|
||||
static gchar *
|
||||
extractable_check_id (GType type, const gchar * id)
|
||||
{
|
||||
if (gst_uri_is_valid (id))
|
||||
return g_strdup (id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
extractable_get_id (GESExtractable * self)
|
||||
{
|
||||
GESAsset *asset;
|
||||
|
||||
if (!(asset = ges_extractable_get_asset (self)))
|
||||
return NULL;
|
||||
|
||||
return g_strdup (ges_asset_get_id (asset));
|
||||
}
|
||||
|
||||
static GType
|
||||
extractable_get_real_extractable_type (GType type, const gchar * id)
|
||||
{
|
||||
GType real_type = G_TYPE_NONE;
|
||||
GESFormatterClass *class;
|
||||
|
||||
class = ges_formatter_find_for_uri (id);
|
||||
if (class) {
|
||||
real_type = G_OBJECT_CLASS_TYPE (class);
|
||||
g_type_class_unref (class);
|
||||
}
|
||||
|
||||
return real_type;
|
||||
}
|
||||
|
||||
static void
|
||||
ges_extractable_interface_init (GESExtractableInterface * iface)
|
||||
{
|
||||
iface->check_id = (GESExtractableCheckId) extractable_check_id;
|
||||
iface->get_id = extractable_get_id;
|
||||
iface->get_real_extractable_type = extractable_get_real_extractable_type;
|
||||
}
|
||||
|
||||
static void
|
||||
ges_formatter_class_init (GESFormatterClass * klass)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef struct _GESFormatterPrivate GESFormatterPrivate;
|
|||
*/
|
||||
|
||||
struct _GESFormatter {
|
||||
GObject parent;
|
||||
GInitiallyUnowned parent;
|
||||
|
||||
/*< private >*/
|
||||
GESFormatterPrivate *priv;
|
||||
|
@ -114,7 +114,7 @@ typedef gboolean (*GESFormatterSaveToURIMethod) (GESFormatter *formatter,
|
|||
*/
|
||||
|
||||
struct _GESFormatterClass {
|
||||
GObjectClass parent_class;
|
||||
GInitiallyUnownedClass parent_class;
|
||||
|
||||
GESFormatterCanLoadURIMethod can_load_uri;
|
||||
GESFormatterCanSaveURIMethod can_save_uri;
|
||||
|
|
Loading…
Reference in a new issue