Commit a635e48d authored by Simon Corsin's avatar Simon Corsin Committed by Thibault Saunier
Browse files

GES: Add GESVideoSource and GESAudioSource base classes

  + Update documentation.
  + Implements subclasses audio-uri-source and video-uri-source
parent 7fcc6e4b
......@@ -47,6 +47,8 @@ platform as well as Windows. It is released under the GNU Library General Public
<xi:include href="xml/ges-track.xml"/>
<xi:include href="xml/ges-track-element.xml"/>
<xi:include href="xml/ges-source.xml"/>
<xi:include href="xml/ges-video-source.xml"/>
<xi:include href="xml/ges-audio-source.xml"/>
<xi:include href="xml/ges-base-effect.xml"/>
<xi:include href="xml/ges-operation.xml"/>
<xi:include href="xml/ges-base-transition-clip.xml"/>
......@@ -66,7 +68,8 @@ platform as well as Windows. It is released under the GNU Library General Public
<chapter>
<title>Track objects</title>
<xi:include href="xml/ges-uri-source.xml"/>
<xi:include href="xml/ges-audio-uri-source.xml"/>
<xi:include href="xml/ges-video-uri-source.xml"/>
<xi:include href="xml/ges-title-source.xml"/>
<xi:include href="xml/ges-audio-test-source.xml"/>
<xi:include href="xml/ges-video-test-source.xml"/>
......
......@@ -192,20 +192,69 @@ GES_TYPE_OPERATION
</SECTION>
<SECTION>
<FILE>ges-uri-source</FILE>
<TITLE>GESUriSource</TITLE>
GESUriSource
ges_track_filesource_new
<FILE>ges-video-source</FILE>
<TITLE>GESVideoSource</TITLE>
GESVideoSource
<SUBSECTION Standard>
GESUriSourceClass
GESUriSourcePrivate
GES_URI_SOURCE
GES_URI_SOURCE_CLASS
GES_URI_SOURCE_GET_CLASS
GES_TYPE_URI_SOURCE
GES_IS_URI_SOURCE
GES_IS_URI_SOURCE_CLASS
ges_track_filesource_get_type
GESVideoSourceClass
GESVideoSourcePrivate
GES_VIDEO_SOURCE
GES_VIDEO_SOURCE_CLASS
GES_VIDEO_SOURCE_GET_CLASS
GES_TYPE_VIDEO_SOURCE
GES_IS_VIDEO_SOURCE
GES_IS_VIDEO_SOURCE_CLASS
ges_video_source_get_type
</SECTION>
<SECTION>
<FILE>ges-audio-source</FILE>
<TITLE>GESAudioSource</TITLE>
GESAudioSource
<SUBSECTION Standard>
GESAudioSourceClass
GESAudioSourcePrivate
GES_AUDIO_SOURCE
GES_AUDIO_SOURCE_CLASS
GES_AUDIO_SOURCE_GET_CLASS
GES_TYPE_AUDIO_SOURCE
GES_IS_AUDIO_SOURCE
GES_IS_AUDIO_SOURCE_CLASS
ges_audio_source_get_type
</SECTION>
<SECTION>
<FILE>ges-video-uri-source</FILE>
<TITLE>GESVideoUriSource</TITLE>
GESVideoUriSource
ges_video_uri_source_new
<SUBSECTION Standard>
GESVideoUriSourceClass
GESVideoUriSourcePrivate
GES_VIDEO_URI_SOURCE
GES_VIDEO_URI_SOURCE_CLASS
GES_VIDEO_URI_SOURCE_GET_CLASS
GES_TYPE_VIDEO_URI_SOURCE
GES_IS_VIDEO_URI_SOURCE
GES_IS_VIDEO_URI_SOURCE_CLASS
ges_video_uri_source_get_type
</SECTION>
<SECTION>
<FILE>ges-audio-uri-source</FILE>
<TITLE>GESAudioUriSource</TITLE>
GESAudioUriSource
ges_audio_uri_source_new
<SUBSECTION Standard>
GESAudioUriSourceClass
GESAudioUriSourcePrivate
GES_AUDIO_URI_SOURCE
GES_AUDIO_URI_SOURCE_CLASS
GES_AUDIO_URI_SOURCE_GET_CLASS
GES_TYPE_AUDIO_URI_SOURCE
GES_IS_AUDIO_URI_SOURCE
GES_IS_AUDIO_URI_SOURCE_CLASS
ges_audio_uri_source_get_type
</SECTION>
<SECTION>
......
......@@ -22,7 +22,8 @@ ges_text_overlay_clip_get_type
ges_title_clip_get_type
ges_audio_test_source_get_type
ges_audio_transition_get_type
ges_track_filesource_get_type
ges_video_uri_source_get_type
ges_audio_uri_source_get_type
ges_track_get_type
ges_image_source_get_type
ges_track_element_get_type
......
......@@ -34,7 +34,10 @@ libges_@GST_API_VERSION@_la_SOURCES = \
ges-track-element.c \
ges-source.c \
ges-operation.c \
ges-uri-source.c \
ges-video-source.c \
ges-audio-source.c \
ges-video-uri-source.c \
ges-audio-uri-source.c \
ges-image-source.c \
ges-transition.c \
ges-audio-transition.c \
......@@ -100,7 +103,10 @@ libges_@GST_API_VERSION@include_HEADERS = \
ges-track-element.h \
ges-source.h \
ges-operation.h \
ges-uri-source.h \
ges-video-source.h \
ges-audio-source.h \
ges-video-uri-source.h \
ges-audio-uri-source.h \
ges-image-source.h \
ges-transition.h \
ges-audio-transition.h \
......
/* GStreamer Editing Services
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
* 2009 Nokia Corporation
*
* 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.
*/
/**
* SECTION:ges-audio-source
* @short_description: Base Class for audio sources
*/
#include "ges-internal.h"
#include "ges/ges-meta-container.h"
#include "ges-track-element.h"
#include "ges-audio-source.h"
#include "ges-layer.h"
G_DEFINE_TYPE (GESAudioSource, ges_audio_source, GES_TYPE_SOURCE);
struct _GESAudioSourcePrivate
{
/* Dummy variable */
void *nothing;
};
static void
_sync_element_to_layer_property_float (GESTrackElement * trksrc,
GstElement * element, const gchar * meta, const gchar * propname)
{
GESTimelineElement *parent;
GESLayer *layer;
gfloat value;
parent = ges_timeline_element_get_parent (GES_TIMELINE_ELEMENT (trksrc));
layer = ges_clip_get_layer (GES_CLIP (parent));
gst_object_unref (parent);
if (layer != NULL) {
ges_meta_container_get_float (GES_META_CONTAINER (layer), meta, &value);
g_object_set (element, propname, value, NULL);
GST_DEBUG_OBJECT (trksrc, "Setting %s to %f", propname, value);
} else {
GST_DEBUG_OBJECT (trksrc, "NOT setting the %s", propname);
}
gst_object_unref (layer);
}
static GstElement *
ges_audio_source_create_element (GESTrackElement * trksrc)
{
GstElement *topbin;
GstElement *sub_element;
GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_GET_CLASS (trksrc);
const gchar *props[] = { "volume", "mute", NULL };
GstElement *volume;
if (!source_class->create_source)
return NULL;
sub_element = source_class->create_source (trksrc);
GST_DEBUG_OBJECT (trksrc, "Creating a bin sub_element ! volume");
volume = gst_element_factory_make ("volume", NULL);
topbin = ges_source_create_topbin ("audiosrcbin", sub_element, volume, NULL);
_sync_element_to_layer_property_float (trksrc, volume, GES_META_VOLUME,
"volume");
ges_track_element_add_children_props (trksrc, volume, NULL, NULL, props);
return topbin;
}
static void
ges_audio_source_class_init (GESAudioSourceClass * klass)
{
GESTrackElementClass *track_class = GES_TRACK_ELEMENT_CLASS (klass);
GESAudioSourceClass *audio_source_class = GES_AUDIO_SOURCE_CLASS (klass);
g_type_class_add_private (klass, sizeof (GESAudioSourcePrivate));
track_class->gnlobject_factorytype = "gnlsource";
track_class->create_element = ges_audio_source_create_element;
audio_source_class->create_source = NULL;
}
static void
ges_audio_source_init (GESAudioSource * self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_AUDIO_SOURCE, GESAudioSourcePrivate);
}
/* GStreamer Editing Services
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
* 2009 Nokia Corporation
*
* 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.
*/
#ifndef _GES_AUDIO_SOURCE
#define _GES_AUDIO_SOURCE
#include <glib-object.h>
#include <gst/gst.h>
#include <ges/ges-types.h>
#include <ges/ges-track-element.h>
#include <ges/ges-source.h>
G_BEGIN_DECLS
#define GES_TYPE_AUDIO_SOURCE ges_audio_source_get_type()
#define GES_AUDIO_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_AUDIO_SOURCE, GESAudioSource))
#define GES_AUDIO_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_AUDIO_SOURCE, GESAudioSourceClass))
#define GES_IS_AUDIO_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_AUDIO_SOURCE))
#define GES_IS_AUDIO_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_AUDIO_SOURCE))
#define GES_AUDIO_SOURCE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_AUDIO_SOURCE, GESAudioSourceClass))
typedef struct _GESAudioSourcePrivate GESAudioSourcePrivate;
/**
* GESAudioSource:
*
* Base class for audio sources
*/
struct _GESAudioSource {
/*< private >*/
GESSource parent;
GESAudioSourcePrivate *priv;
/* Padding for API extension */
gpointer _ges_reserved[GES_PADDING];
};
/**
* GESAudioSourceClass:
* @create_source: method to return the GstElement to put in the source topbin.
* Other elements will be queued, like a volume.
* In the case of a AudioUriSource, for example, the subclass will return a decodebin,
* and we will append a volume.
*/
struct _GESAudioSourceClass {
/*< private >*/
GESSourceClass parent_class;
/*< public >*/
GstElement* (*create_source) (GESTrackElement * object);
/*< private >*/
/* Padding for API extension */
gpointer _ges_reserved[GES_PADDING];
};
GType ges_audio_source_get_type (void);
G_END_DECLS
#endif /* _GES_AUDIO_SOURCE */
......@@ -31,7 +31,8 @@
#include "ges-track-element.h"
#include "ges-audio-test-source.h"
G_DEFINE_TYPE (GESAudioTestSource, ges_audio_test_source, GES_TYPE_SOURCE);
G_DEFINE_TYPE (GESAudioTestSource, ges_audio_test_source,
GES_TYPE_AUDIO_SOURCE);
#define DEFAULT_VOLUME 1.0
struct _GESAudioTestSourcePrivate
......@@ -57,7 +58,7 @@ static void
ges_audio_test_source_class_init (GESAudioTestSourceClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GESSourceClass *source_class = GES_SOURCE_CLASS (klass);
GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_CLASS (klass);
g_type_class_add_private (klass, sizeof (GESAudioTestSourcePrivate));
......
......@@ -23,7 +23,7 @@
#include <glib-object.h>
#include <ges/ges-types.h>
#include <ges/ges-source.h>
#include <ges/ges-audio-source.h>
G_BEGIN_DECLS
......@@ -53,7 +53,7 @@ typedef struct _GESAudioTestSourcePrivate GESAudioTestSourcePrivate;
*/
struct _GESAudioTestSource {
GESSource parent;
GESAudioSource parent;
/*< private >*/
GESAudioTestSourcePrivate *priv;
......@@ -64,7 +64,7 @@ struct _GESAudioTestSource {
struct _GESAudioTestSourceClass {
/*< private >*/
GESSourceClass parent_class;
GESAudioSourceClass parent_class;
/* Padding for API extension */
gpointer _ges_reserved[GES_PADDING];
......
......@@ -19,21 +19,18 @@
*/
/**
* SECTION:ges-uri-source
* @short_description: outputs a single media stream from a given file
*
* Outputs a single media stream from a given file. The stream chosen depends on
* the type of the track which contains the object.
* SECTION:ges-audio-uri-source
* @short_description: outputs a single audio stream from a given file
*/
#include "ges-utils.h"
#include "ges-internal.h"
#include "ges-track-element.h"
#include "ges-uri-source.h"
#include "ges-audio-uri-source.h"
#include "ges-uri-asset.h"
#include "ges-extractable.h"
struct _GESUriSourcePrivate
struct _GESAudioUriSourcePrivate
{
void *nothing;
};
......@@ -46,13 +43,13 @@ enum
/* GESSource VMethod */
static GstElement *
ges_uri_source_create_source (GESTrackElement * trksrc)
ges_audio_uri_source_create_source (GESTrackElement * trksrc)
{
GESUriSource *self;
GESAudioUriSource *self;
GESTrack *track;
GstElement *decodebin;
self = (GESUriSource *) trksrc;
self = (GESAudioUriSource *) trksrc;
track = ges_track_element_get_track (trksrc);
......@@ -94,8 +91,8 @@ ges_extractable_interface_init (GESExtractableInterface * iface)
iface->set_asset = extractable_set_asset;
}
G_DEFINE_TYPE_WITH_CODE (GESUriSource, ges_track_filesource,
GES_TYPE_SOURCE,
G_DEFINE_TYPE_WITH_CODE (GESAudioUriSource, ges_audio_uri_source,
GES_TYPE_AUDIO_SOURCE,
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
ges_extractable_interface_init));
......@@ -103,10 +100,10 @@ G_DEFINE_TYPE_WITH_CODE (GESUriSource, ges_track_filesource,
/* GObject VMethods */
static void
ges_track_filesource_get_property (GObject * object, guint property_id,
ges_audio_uri_source_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
GESUriSource *uriclip = GES_URI_SOURCE (object);
GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object);
switch (property_id) {
case PROP_URI:
......@@ -118,10 +115,10 @@ ges_track_filesource_get_property (GObject * object, guint property_id,
}
static void
ges_track_filesource_set_property (GObject * object, guint property_id,
ges_audio_uri_source_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GESUriSource *uriclip = GES_URI_SOURCE (object);
GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object);
switch (property_id) {
case PROP_URI:
......@@ -137,30 +134,30 @@ ges_track_filesource_set_property (GObject * object, guint property_id,
}
static void
ges_track_filesource_dispose (GObject * object)
ges_audio_uri_source_dispose (GObject * object)
{
GESUriSource *uriclip = GES_URI_SOURCE (object);
GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object);
if (uriclip->uri)
g_free (uriclip->uri);
G_OBJECT_CLASS (ges_track_filesource_parent_class)->dispose (object);
G_OBJECT_CLASS (ges_audio_uri_source_parent_class)->dispose (object);
}
static void
ges_track_filesource_class_init (GESUriSourceClass * klass)
ges_audio_uri_source_class_init (GESAudioUriSourceClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GESSourceClass *source_class = GES_SOURCE_CLASS (klass);
GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_CLASS (klass);
g_type_class_add_private (klass, sizeof (GESUriSourcePrivate));
g_type_class_add_private (klass, sizeof (GESAudioUriSourcePrivate));
object_class->get_property = ges_track_filesource_get_property;
object_class->set_property = ges_track_filesource_set_property;
object_class->dispose = ges_track_filesource_dispose;
object_class->get_property = ges_audio_uri_source_get_property;
object_class->set_property = ges_audio_uri_source_set_property;
object_class->dispose = ges_audio_uri_source_dispose;
/**
* GESUriSource:uri:
* GESAudioUriSource:uri:
*
* The location of the file/resource to use.
*/
......@@ -168,27 +165,27 @@ ges_track_filesource_class_init (GESUriSourceClass * klass)
g_param_spec_string ("uri", "URI", "uri of the resource",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
source_class->create_source = ges_uri_source_create_source;
source_class->create_source = ges_audio_uri_source_create_source;
}
static void
ges_track_filesource_init (GESUriSource * self)
ges_audio_uri_source_init (GESAudioUriSource * self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_URI_SOURCE, GESUriSourcePrivate);
GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourcePrivate);
}
/**
* ges_track_filesource_new:
* ges_audio_uri_source_new:
* @uri: the URI the source should control
*
* Creates a new #GESUriSource for the provided @uri.
* Creates a new #GESAudioUriSource for the provided @uri.
*
* Returns: The newly created #GESUriSource, or %NULL if there was an
* Returns: The newly created #GESAudioUriSource, or %NULL if there was an
* error.
*/
GESUriSource *
ges_track_filesource_new (gchar * uri)
GESAudioUriSource *
ges_audio_uri_source_new (gchar * uri)
{
return g_object_new (GES_TYPE_URI_SOURCE, "uri", uri, NULL);
return g_object_new (GES_TYPE_AUDIO_URI_SOURCE, "uri", uri, NULL);
}
......@@ -18,62 +18,62 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef _GES_URI_SOURCE
#define _GES_URI_SOURCE
#ifndef _GES_AUDIO_URI_SOURCE
#define _GES_AUDIO_URI_SOURCE
#include <glib-object.h>
#include <ges/ges-types.h>
#include <ges/ges-source.h>
#include <ges/ges-audio-source.h>
G_BEGIN_DECLS
#define GES_TYPE_URI_SOURCE ges_track_filesource_get_type()
#define GES_TYPE_AUDIO_URI_SOURCE ges_audio_uri_source_get_type()
#define GES_URI_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_URI_SOURCE, GESUriSource))
#define GES_AUDIO_URI_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSource))
#define GES_URI_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_URI_SOURCE, GESUriSourceClass))
#define GES_AUDIO_URI_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourceClass))
#define GES_IS_URI_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_URI_SOURCE))
#define GES_IS_AUDIO_URI_SOURCE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_AUDIO_URI_SOURCE))
#define GES_IS_URI_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_URI_SOURCE))
#define GES_IS_AUDIO_URI_SOURCE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_AUDIO_URI_SOURCE))
#define GES_URI_SOURCE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_URI_SOURCE, GESUriSourceClass))
#define GES_AUDIO_URI_SOURCE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourceClass))
typedef struct _GESUriSourcePrivate GESUriSourcePrivate;
typedef struct _GESAudioUriSourcePrivate GESAudioUriSourcePrivate;
/**
* GESUriSource:
* GESAudioUriSource:
*/
struct _GESUriSource {
struct _GESAudioUriSource {
/*< private >*/
GESSource parent;
GESAudioSource parent;
gchar *uri;
GESUriSourcePrivate *priv;
GESAudioUriSourcePrivate *priv;
/* Padding for API extension */
gpointer _ges_reserved[GES_PADDING];
};
struct _GESUriSourceClass {
struct _GESAudioUriSourceClass {
/*< private >*/
GESSourceClass parent_class;
GESAudioSourceClass parent_class;
/* Padding for API extension */
gpointer _ges_reserved[GES_PADDING];
};
GType ges_track_filesource_get_type (void);
GType ges_audio_uri_source_get_type (void);
GESUriSource* ges_track_filesource_new (gchar *uri);
GESAudioUriSource* ges_audio_uri_source_new (gchar *uri);
G_END_DECLS
#endif /* _GES_URI_SOURCE */
#endif /* _GES_AUDIO_URI_SOURCE */
......@@ -32,7 +32,7 @@
#include "ges-track-element.h"
#include "ges-image-source.h"