uri-source: Expose the volume property.

+ Make the pspec_hash function an internal util.
	+ Add a create_props_hashtable implementation
	+ If TRACK_TYPE_AUDIO, put the volume properties in the hashtable.
This commit is contained in:
Mathieu Duponchelle 2013-05-16 08:10:35 +02:00 committed by Thibault Saunier
parent 800325db02
commit 6be4f79ca0
4 changed files with 70 additions and 32 deletions

View file

@ -24,8 +24,8 @@
*/
#include <glib/gprintf.h>
#include <string.h>
#include "ges-utils.h"
#include "ges-internal.h"
#include "ges-track-element.h"
#include "ges-base-effect.h"
@ -33,9 +33,6 @@
G_DEFINE_ABSTRACT_TYPE (GESBaseEffect, ges_base_effect, GES_TYPE_OPERATION);
static GHashTable *ges_base_effect_get_props_hashtable (GESTrackElement * self);
guint pspec_hash (gconstpointer key_spec);
static gboolean pspec_equal (gconstpointer key_spec_1,
gconstpointer key_spec_2);
struct _GESBaseEffectPrivate
{
@ -60,29 +57,6 @@ ges_base_effect_init (GESBaseEffect * self)
GESBaseEffectPrivate);
}
static gboolean
pspec_equal (gconstpointer key_spec_1, gconstpointer key_spec_2)
{
const GParamSpec *key1 = key_spec_1;
const GParamSpec *key2 = key_spec_2;
return (key1->owner_type == key2->owner_type &&
strcmp (key1->name, key2->name) == 0);
}
guint
pspec_hash (gconstpointer key_spec)
{
const GParamSpec *key = key_spec;
const gchar *p;
guint h = key->owner_type;
for (p = key->name; *p; p++)
h = (h << 5) - h + *p;
return h;
}
/* Virtual methods */
static GHashTable *
ges_base_effect_get_props_hashtable (GESTrackElement * self)

View file

@ -26,12 +26,19 @@
* the type of the track which contains the object.
*/
#include "ges-utils.h"
#include "ges-internal.h"
#include "ges-track-element.h"
#include "ges-uri-source.h"
#include "ges-uri-asset.h"
#include "ges-extractable.h"
struct _GESUriSourcePrivate
{
GHashTable *props_hashtable;
void *dummy;
};
static gchar *
ges_extractable_check_id (GType type, const gchar * id, GError ** error)
{
@ -65,11 +72,6 @@ G_DEFINE_TYPE_WITH_CODE (GESUriSource, ges_track_filesource,
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
ges_extractable_interface_init));
struct _GESUriSourcePrivate
{
void *dummy;
};
enum
{
PROP_0,
@ -135,6 +137,9 @@ ges_uri_source_create_element (GESTrackElement * trksrc)
GstPad *ghost;
GESLayer *layer;
gfloat layer_volume;
GObjectClass *class;
guint i, nb_specs;
GParamSpec **parray;
self = (GESUriSource *) trksrc;
track = ges_track_element_get_track (trksrc);
@ -171,6 +176,22 @@ ges_uri_source_create_element (GESTrackElement * trksrc)
} else
GST_DEBUG_OBJECT (trksrc, "NOT setting the volume");
class = G_OBJECT_GET_CLASS (volume);
parray = g_object_class_list_properties (class, &nb_specs);
if (self->priv->props_hashtable == NULL)
self->priv->props_hashtable =
g_hash_table_new_full ((GHashFunc) pspec_hash, pspec_equal,
(GDestroyNotify) g_param_spec_unref, gst_object_unref);
for (i = 0; i < nb_specs; i++) {
if (parray[i]->flags & G_PARAM_WRITABLE) {
g_hash_table_insert (self->priv->props_hashtable,
g_param_spec_ref (parray[i]), gst_object_ref (volume));
}
}
g_free (parray);
ret = topbin;
break;
default:
@ -185,6 +206,19 @@ ges_uri_source_create_element (GESTrackElement * trksrc)
return ret;
}
static GHashTable *
ges_uri_source_get_props_hashtable (GESTrackElement * element)
{
GESUriSource *self = (GESUriSource *) element;
if (self->priv->props_hashtable == NULL)
self->priv->props_hashtable =
g_hash_table_new_full ((GHashFunc) pspec_hash, pspec_equal,
(GDestroyNotify) g_param_spec_unref, gst_object_unref);
return self->priv->props_hashtable;
}
static void
ges_track_filesource_class_init (GESUriSourceClass * klass)
{
@ -207,6 +241,7 @@ ges_track_filesource_class_init (GESUriSourceClass * klass)
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
track_class->create_element = ges_uri_source_create_element;
track_class->get_props_hastable = ges_uri_source_get_props_hashtable;
}
static void
@ -214,6 +249,7 @@ ges_track_filesource_init (GESUriSource * self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_URI_SOURCE, GESUriSourcePrivate);
self->priv->props_hashtable = NULL;
}
/**

View file

@ -23,6 +23,8 @@
*
*/
#include <string.h>
#include "ges-internal.h"
#include "ges-timeline.h"
#include "ges-track.h"
@ -97,3 +99,26 @@ element_end_compare (GESTimelineElement * a, GESTimelineElement * b)
return 1;
}
gboolean
pspec_equal (gconstpointer key_spec_1, gconstpointer key_spec_2)
{
const GParamSpec *key1 = key_spec_1;
const GParamSpec *key2 = key_spec_2;
return (key1->owner_type == key2->owner_type &&
strcmp (key1->name, key2->name) == 0);
}
guint
pspec_hash (gconstpointer key_spec)
{
const GParamSpec *key = key_spec;
const gchar *p;
guint h = key->owner_type;
for (p = key->name; *p; p++)
h = (h << 5) - h + *p;
return h;
}

View file

@ -27,6 +27,9 @@
G_BEGIN_DECLS
GESTimeline * ges_timeline_new_audio_video (void);
gboolean pspec_equal (gconstpointer key_spec_1, gconstpointer key_spec_2);
guint pspec_hash (gconstpointer key_spec);
G_END_DECLS