mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
Add a GESAssetTrackFileSource class and make use of it all around
This commit is contained in:
parent
bc0f335734
commit
6dfae640a2
9 changed files with 294 additions and 13 deletions
|
@ -102,6 +102,7 @@ platform as well as Windows. It is released under the GNU Library General Public
|
|||
<chapter>
|
||||
<title>Assets</title>
|
||||
<xi:include href="xml/ges-asset-file-source.xml"/>
|
||||
<xi:include href="xml/ges-asset-track-file-source.xml"/>
|
||||
<xi:include href="xml/ges-project.xml"/>
|
||||
</chapter>
|
||||
|
||||
|
|
|
@ -987,6 +987,7 @@ ges_asset_filesource_is_image
|
|||
ges_asset_filesource_get_info
|
||||
ges_asset_filesource_new
|
||||
ges_asset_filesource_set_timeout
|
||||
ges_asset_filesource_get_stream_assets
|
||||
<SUBSECTION Standard>
|
||||
GESAssetFileSourcePrivate
|
||||
GES_ASSET_FILESOURCE
|
||||
|
@ -997,6 +998,23 @@ GES_IS_ASSET_FILESOURCE_CLASS
|
|||
GES_ASSET_FILESOURCE_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>ges-asset-track-file-source</FILE>
|
||||
<TITLE>GESAssetTrackFileSource</TITLE>
|
||||
GESAssetTrackFileSource
|
||||
ges_asset_track_filesource_get_type
|
||||
ges_asset_track_filesource_get_track_type
|
||||
ges_asset_track_filesource_get_filesource_asset
|
||||
<SUBSECTION Standard>
|
||||
GESAssetTrackFileSourcePrivate
|
||||
GES_ASSET_TRACK_FILESOURCE
|
||||
GES_TYPE_ASSET_TRACK_FILESOURCE
|
||||
GES_ASSET_TRACK_FILESOURCE_CLASS
|
||||
GES_IS_ASSET_TRACK_FILESOURCE
|
||||
GES_IS_ASSET_TRACK_FILESOURCE_CLASS
|
||||
GES_ASSET_TRACK_FILESOURCE_GET_CLASS
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>ges-project</FILE>
|
||||
<TITLE>GESProject</TITLE>
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
*/
|
||||
/**
|
||||
* SECTION: ges-asset-file-source
|
||||
* @short_description: A #GESAsset subclass speciliazed in #GESTimelineFileSource extraction
|
||||
* @short_description: A #GESAsset subclass specialized in #GESTimelineFileSource extraction
|
||||
*
|
||||
* The #GESAssetFileSource is a special #GESAssetFileSource that lets you handle
|
||||
* The #GESAssetFileSource is a special #GESAsset that lets you handle
|
||||
* the media file to use inside the GStreamer Editing Services. It has APIs that
|
||||
* let you get information about the medias. Also, the tags found in the media file are
|
||||
* set as Metadatas of the Asser.
|
||||
|
@ -62,6 +62,17 @@ struct _GESAssetFileSourcePrivate
|
|||
GstDiscovererInfo *info;
|
||||
GstClockTime duration;
|
||||
gboolean is_image;
|
||||
|
||||
GList *asset_trackfilesources;
|
||||
};
|
||||
|
||||
struct _GESAssetTrackFileSourcePrivate
|
||||
{
|
||||
GstDiscovererStreamInfo *sinfo;
|
||||
GESAssetFileSource *parent_asset;
|
||||
|
||||
const gchar *uri;
|
||||
GESTrackType type;
|
||||
};
|
||||
|
||||
|
||||
|
@ -232,6 +243,36 @@ ges_asset_filesource_init (GESAssetFileSource * self)
|
|||
priv->is_image = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_create_track_file_source_asset (GESAssetFileSource * asset,
|
||||
GstDiscovererStreamInfo * sinfo, GESTrackType type)
|
||||
{
|
||||
GESAsset *tck_filesource_asset;
|
||||
GESAssetTrackFileSourcePrivate *priv_tckasset;
|
||||
GESAssetFileSourcePrivate *priv = asset->priv;
|
||||
gchar *stream_id =
|
||||
g_strdup (gst_discoverer_stream_info_get_stream_id (sinfo));
|
||||
|
||||
if (stream_id == NULL) {
|
||||
GST_WARNING ("No stream ID found, using the pointer instead");
|
||||
|
||||
stream_id = g_strdup_printf ("%i", GPOINTER_TO_INT (sinfo));
|
||||
}
|
||||
|
||||
tck_filesource_asset = ges_asset_request (GES_TYPE_TRACK_FILESOURCE,
|
||||
stream_id, NULL);
|
||||
g_free (stream_id);
|
||||
|
||||
priv_tckasset = GES_ASSET_TRACK_FILESOURCE (tck_filesource_asset)->priv;
|
||||
priv_tckasset->uri = ges_asset_get_id (GES_ASSET (asset));
|
||||
priv_tckasset->sinfo = g_object_ref (sinfo);
|
||||
priv_tckasset->parent_asset = asset;
|
||||
priv_tckasset->type = type;
|
||||
|
||||
priv->asset_trackfilesources = g_list_append (priv->asset_trackfilesources,
|
||||
gst_object_ref (tck_filesource_asset));
|
||||
}
|
||||
|
||||
static void
|
||||
ges_asset_filesource_set_info (GESAssetFileSource * self,
|
||||
GstDiscovererInfo * info)
|
||||
|
@ -244,6 +285,7 @@ ges_asset_filesource_set_info (GESAssetFileSource * self,
|
|||
/* Extract infos from the GstDiscovererInfo */
|
||||
stream_list = gst_discoverer_info_get_stream_list (info);
|
||||
for (tmp = stream_list; tmp; tmp = tmp->next) {
|
||||
GESTrackType type = GES_TRACK_TYPE_UNKNOWN;
|
||||
GstDiscovererStreamInfo *sinf = (GstDiscovererStreamInfo *) tmp->data;
|
||||
|
||||
if (GST_IS_DISCOVERER_AUDIO_INFO (sinf)) {
|
||||
|
@ -252,17 +294,21 @@ ges_asset_filesource_set_info (GESAssetFileSource * self,
|
|||
else
|
||||
supportedformats |= GES_TRACK_TYPE_AUDIO;
|
||||
|
||||
type = GES_TRACK_TYPE_AUDIO;
|
||||
} else if (GST_IS_DISCOVERER_VIDEO_INFO (sinf)) {
|
||||
if (supportedformats == GES_TRACK_TYPE_UNKNOWN)
|
||||
supportedformats = GES_TRACK_TYPE_VIDEO;
|
||||
else
|
||||
supportedformats |= GES_TRACK_TYPE_VIDEO;
|
||||
if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
|
||||
sinf)) {
|
||||
sinf))
|
||||
priv->is_image = TRUE;
|
||||
}
|
||||
} else
|
||||
supportedformats = GES_TRACK_TYPE_UNKNOWN;
|
||||
type = GES_TRACK_TYPE_VIDEO;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Creating AsserTrackFileSource for stream: %s",
|
||||
gst_discoverer_stream_info_get_stream_id (sinf));
|
||||
_create_track_file_source_asset (self, sinf, type);
|
||||
}
|
||||
ges_meta_container_set_uint (GES_META_CONTAINER (self),
|
||||
GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS, supportedformats);
|
||||
|
@ -437,3 +483,133 @@ ges_asset_filesource_set_timeout (GESAssetFileSourceClass * class,
|
|||
|
||||
g_object_set (class->discoverer, "timeout", timeout, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_asset_filesource_get_stream_assets:
|
||||
* @self: A #GESAssetFileSource
|
||||
*
|
||||
* Get the GESAssetTrackFileSource @self containes
|
||||
*
|
||||
* Returns: (transfer-none) (element-type GESAssetTrackFileSource): a
|
||||
* #GList of #GESAssetTrackFileSource
|
||||
*/
|
||||
const GList *
|
||||
ges_asset_filesource_get_stream_assets (GESAssetFileSource * self)
|
||||
{
|
||||
g_return_val_if_fail (GES_IS_ASSET_FILESOURCE (self), FALSE);
|
||||
|
||||
return self->priv->asset_trackfilesources;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
* GESAssetTrackFileSource implementation *
|
||||
*****************************************************************/
|
||||
/**
|
||||
* SECTION: ges-asset-track-file-source
|
||||
* @short_description: A #GESAsset subclass specialized in #GESTrackFileSource extraction
|
||||
*
|
||||
* NOTE: You should never request such a #GESAsset as they will be created automatically
|
||||
* by #GESAssetFileSource-s.
|
||||
*/
|
||||
|
||||
G_DEFINE_TYPE (GESAssetTrackFileSource, ges_asset_track_filesource,
|
||||
GES_TYPE_ASSET);
|
||||
|
||||
static GESExtractable *
|
||||
_extract (GESAsset * asset, GError ** error)
|
||||
{
|
||||
GESTrackObject *tckobj;
|
||||
GESAssetTrackFileSourcePrivate *priv =
|
||||
GES_ASSET_TRACK_FILESOURCE (asset)->priv;
|
||||
|
||||
if (GST_IS_DISCOVERER_STREAM_INFO (priv->sinfo) == FALSE) {
|
||||
GST_WARNING_OBJECT (asset, "Can not extract as no strean info set");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (priv->uri == NULL) {
|
||||
GST_WARNING_OBJECT (asset, "Can not extract as no uri set");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tckobj = GES_TRACK_OBJECT (ges_track_filesource_new (g_strdup (priv->uri)));
|
||||
ges_track_object_set_track_type (tckobj, priv->type);
|
||||
|
||||
return GES_EXTRACTABLE (tckobj);
|
||||
}
|
||||
|
||||
static void
|
||||
ges_asset_track_filesource_class_init (GESAssetTrackFileSourceClass * klass)
|
||||
{
|
||||
g_type_class_add_private (klass, sizeof (GESAssetTrackFileSourcePrivate));
|
||||
|
||||
GES_ASSET_CLASS (klass)->extract = _extract;
|
||||
}
|
||||
|
||||
static void
|
||||
ges_asset_track_filesource_init (GESAssetTrackFileSource * self)
|
||||
{
|
||||
GESAssetTrackFileSourcePrivate *priv;
|
||||
|
||||
priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||
GES_TYPE_ASSET_TRACK_FILESOURCE, GESAssetTrackFileSourcePrivate);
|
||||
|
||||
priv->sinfo = NULL;
|
||||
priv->parent_asset = NULL;
|
||||
priv->uri = NULL;
|
||||
priv->type = GES_TRACK_TYPE_UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
GstDiscovererStreamInfo *
|
||||
ges_asset_track_filesource_get_stream_info (GESAssetTrackFileSource * asset)
|
||||
{
|
||||
g_return_val_if_fail (GES_IS_ASSET_TRACK_FILESOURCE (asset), NULL);
|
||||
|
||||
return asset->priv->sinfo;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
ges_asset_track_filesource_get_stream_uri (GESAssetTrackFileSource * asset)
|
||||
{
|
||||
g_return_val_if_fail (GES_IS_ASSET_TRACK_FILESOURCE (asset), NULL);
|
||||
|
||||
return asset->priv->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_asset_track_filesource_get_track_type:
|
||||
* @self: A #GESAssetFileSource
|
||||
*
|
||||
* Get the GESAssetTrackType the #GESTrackObject extracted from @self
|
||||
* should get into
|
||||
*
|
||||
* Returns: a #GESTrackType
|
||||
*/
|
||||
const GESTrackType
|
||||
ges_asset_track_filesource_get_track_type (GESAssetTrackFileSource * asset)
|
||||
{
|
||||
g_return_val_if_fail (GES_IS_ASSET_TRACK_FILESOURCE (asset),
|
||||
GES_TRACK_TYPE_UNKNOWN);
|
||||
|
||||
return asset->priv->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_asset_track_filesource_get_filesource_asset:
|
||||
* @self: A #GESAssetFileSource
|
||||
*
|
||||
* Get the #GESAssetFileSource @self is contained in
|
||||
*
|
||||
* Returns: a #GESAssetFileSource
|
||||
*/
|
||||
const GESAssetFileSource *
|
||||
ges_asset_track_filesource_get_filesource_asset (GESAssetTrackFileSource *
|
||||
asset)
|
||||
{
|
||||
g_return_val_if_fail (GES_IS_ASSET_TRACK_FILESOURCE (asset), NULL);
|
||||
|
||||
return asset->priv->parent_asset;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,45 @@ void ges_asset_filesource_new (const gchar *uri,
|
|||
gpointer user_data);
|
||||
void ges_asset_filesource_set_timeout (GESAssetFileSourceClass *class,
|
||||
GstClockTime timeout);
|
||||
const GList * ges_asset_filesource_get_stream_assets (GESAssetFileSource *self);
|
||||
|
||||
#define GES_TYPE_ASSET_TRACK_FILESOURCE ges_asset_track_filesource_get_type()
|
||||
#define GES_ASSET_TRACK_FILESOURCE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_ASSET_TRACK_FILESOURCE, GESAssetTrackFileSource))
|
||||
#define GES_ASSET_TRACK_FILESOURCE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_ASSET_TRACK_FILESOURCE, GESAssetTrackFileSourceClass))
|
||||
#define GES_IS_ASSET_TRACK_FILESOURCE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_ASSET_TRACK_FILESOURCE))
|
||||
#define GES_IS_ASSET_TRACK_FILESOURCE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_ASSET_TRACK_FILESOURCE))
|
||||
#define GES_ASSET_TRACK_FILESOURCE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_ASSET_TRACK_FILESOURCE, GESAssetTrackFileSourceClass))
|
||||
|
||||
typedef struct _GESAssetTrackFileSourcePrivate GESAssetTrackFileSourcePrivate;
|
||||
|
||||
GType ges_asset_track_filesource_get_type (void);
|
||||
|
||||
struct _GESAssetTrackFileSource
|
||||
{
|
||||
GESAsset parent;
|
||||
|
||||
/* <private> */
|
||||
GESAssetTrackFileSourcePrivate *priv;
|
||||
|
||||
/* Padding for API extension */
|
||||
gpointer __ges_reserved[GES_PADDING];
|
||||
};
|
||||
|
||||
struct _GESAssetTrackFileSourceClass
|
||||
{
|
||||
GESAssetClass parent_class;
|
||||
|
||||
gpointer _ges_reserved[GES_PADDING];
|
||||
};
|
||||
GstDiscovererStreamInfo * ges_asset_track_filesource_get_stream_info (GESAssetTrackFileSource *asset);
|
||||
const gchar * ges_asset_track_filesource_get_stream_uri (GESAssetTrackFileSource *asset);
|
||||
const GESTrackType ges_asset_track_filesource_get_track_type (GESAssetTrackFileSource *asset);
|
||||
const GESAssetFileSource *ges_asset_track_filesource_get_filesource_asset (GESAssetTrackFileSource *asset);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* _GES_ASSET_FILESOURCE */
|
||||
|
|
|
@ -62,11 +62,13 @@ enum
|
|||
};
|
||||
|
||||
|
||||
static GList *ges_timeline_filesource_create_track_objects (GESTimelineObject *
|
||||
obj, GESTrackType type);
|
||||
static GESTrackObject
|
||||
* ges_timeline_filesource_create_track_object (GESTimelineObject * obj,
|
||||
GESTrackType type);
|
||||
void
|
||||
ges_timeline_filesource_set_uri (GESTimelineFileSource * self, gchar * uri);
|
||||
void ges_timeline_filesource_set_uri (GESTimelineFileSource * self,
|
||||
gchar * uri);
|
||||
|
||||
static void
|
||||
filesource_set_max_duration (GESTimelineObject * object, guint64 maxduration);
|
||||
|
@ -182,6 +184,8 @@ ges_timeline_filesource_class_init (GESTimelineFileSourceClass * klass)
|
|||
GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_UNKNOWN,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
timobj_class->create_track_objects =
|
||||
ges_timeline_filesource_create_track_objects;
|
||||
timobj_class->create_track_object =
|
||||
ges_timeline_filesource_create_track_object;
|
||||
timobj_class->set_max_duration = filesource_set_max_duration;
|
||||
|
@ -399,6 +403,28 @@ ges_timeline_filesource_get_uri (GESTimelineFileSource * self)
|
|||
return self->priv->uri;
|
||||
}
|
||||
|
||||
static GList *
|
||||
ges_timeline_filesource_create_track_objects (GESTimelineObject * obj,
|
||||
GESTrackType type)
|
||||
{
|
||||
GList *res = NULL;
|
||||
const GList *tmp, *stream_assets;
|
||||
|
||||
g_return_val_if_fail (obj->asset, NULL);
|
||||
|
||||
stream_assets =
|
||||
ges_asset_filesource_get_stream_assets (GES_ASSET_FILESOURCE
|
||||
(obj->asset));
|
||||
for (tmp = stream_assets; tmp; tmp = tmp->next) {
|
||||
GESAssetTrackFileSource *asset = GES_ASSET_TRACK_FILESOURCE (tmp->data);
|
||||
|
||||
if (ges_asset_track_filesource_get_track_type (asset) == type)
|
||||
res = g_list_prepend (res, ges_asset_extract (GES_ASSET (asset), NULL));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static GESTrackObject *
|
||||
ges_timeline_filesource_create_track_object (GESTimelineObject * obj,
|
||||
GESTrackType type)
|
||||
|
|
|
@ -483,7 +483,8 @@ ges_timeline_object_create_track_object (GESTimelineObject * object,
|
|||
class = GES_TIMELINE_OBJECT_GET_CLASS (object);
|
||||
|
||||
if (G_UNLIKELY (class->create_track_object == NULL)) {
|
||||
GST_ERROR ("No 'create_track_object' implementation available");
|
||||
GST_ERROR ("No 'create_track_object' implementation available fo type %s",
|
||||
G_OBJECT_TYPE_NAME (object));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -497,9 +498,7 @@ ges_timeline_object_create_track_object (GESTimelineObject * object,
|
|||
* @object: The origin #GESTimelineObject
|
||||
* @type: The #GESTrackType to create each #GESTrackObject for.
|
||||
*
|
||||
* Creates all #GESTrackObjects supported by this object provided track.
|
||||
* The track is responsible for calling #ges_timeline_release_track_object
|
||||
* on these objects when it is finished with them.
|
||||
* Creates all #GESTrackObjects supported by this object for the track type.
|
||||
*
|
||||
* Returns: (element-type GESTrackObject) (transfer-full): A #GList of
|
||||
* newly created #GESTrackObject-s
|
||||
|
|
|
@ -165,6 +165,7 @@ struct _GESTimelineObject
|
|||
|
||||
guint64 fullduration; /* Full usable duration of the object (-1: no duration) */
|
||||
|
||||
/*< protected >*/
|
||||
GESAsset *asset;
|
||||
|
||||
/*< private >*/
|
||||
|
|
|
@ -29,8 +29,26 @@
|
|||
#include "ges-internal.h"
|
||||
#include "ges-track-object.h"
|
||||
#include "ges-track-filesource.h"
|
||||
#include "ges-asset-file-source.h"
|
||||
#include "ges-extractable.h"
|
||||
|
||||
G_DEFINE_TYPE (GESTrackFileSource, ges_track_filesource, GES_TYPE_TRACK_SOURCE);
|
||||
static gchar *
|
||||
ges_extractable_check_id (GType type, const gchar * id, GError ** error)
|
||||
{
|
||||
return g_strdup (id);
|
||||
}
|
||||
|
||||
static void
|
||||
ges_extractable_interface_init (GESExtractableInterface * iface)
|
||||
{
|
||||
iface->asset_type = GES_TYPE_ASSET_TRACK_FILESOURCE;
|
||||
iface->check_id = ges_extractable_check_id;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GESTrackFileSource, ges_track_filesource,
|
||||
GES_TYPE_TRACK_SOURCE,
|
||||
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
|
||||
ges_extractable_interface_init));
|
||||
|
||||
struct _GESTrackFileSourcePrivate
|
||||
{
|
||||
|
|
|
@ -143,6 +143,9 @@ typedef struct _GESAssetClass GESAssetClass;
|
|||
typedef struct _GESAssetFileSource GESAssetFileSource;
|
||||
typedef struct _GESAssetFileSourceClass GESAssetFileSourceClass;
|
||||
|
||||
typedef struct _GESAssetTrackFileSource GESAssetTrackFileSource;
|
||||
typedef struct _GESAssetTrackFileSourceClass GESAssetTrackFileSourceClass;
|
||||
|
||||
typedef struct _GESProject GESProject;
|
||||
typedef struct _GESProjectClass GESProjectClass;
|
||||
|
||||
|
|
Loading…
Reference in a new issue