mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
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:
parent
800325db02
commit
6be4f79ca0
4 changed files with 70 additions and 32 deletions
|
@ -24,8 +24,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
#include "ges-utils.h"
|
||||||
#include "ges-internal.h"
|
#include "ges-internal.h"
|
||||||
#include "ges-track-element.h"
|
#include "ges-track-element.h"
|
||||||
#include "ges-base-effect.h"
|
#include "ges-base-effect.h"
|
||||||
|
@ -33,9 +33,6 @@
|
||||||
G_DEFINE_ABSTRACT_TYPE (GESBaseEffect, ges_base_effect, GES_TYPE_OPERATION);
|
G_DEFINE_ABSTRACT_TYPE (GESBaseEffect, ges_base_effect, GES_TYPE_OPERATION);
|
||||||
|
|
||||||
static GHashTable *ges_base_effect_get_props_hashtable (GESTrackElement * self);
|
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
|
struct _GESBaseEffectPrivate
|
||||||
{
|
{
|
||||||
|
@ -60,29 +57,6 @@ ges_base_effect_init (GESBaseEffect * self)
|
||||||
GESBaseEffectPrivate);
|
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 */
|
/* Virtual methods */
|
||||||
static GHashTable *
|
static GHashTable *
|
||||||
ges_base_effect_get_props_hashtable (GESTrackElement * self)
|
ges_base_effect_get_props_hashtable (GESTrackElement * self)
|
||||||
|
|
|
@ -26,12 +26,19 @@
|
||||||
* the type of the track which contains the object.
|
* the type of the track which contains the object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ges-utils.h"
|
||||||
#include "ges-internal.h"
|
#include "ges-internal.h"
|
||||||
#include "ges-track-element.h"
|
#include "ges-track-element.h"
|
||||||
#include "ges-uri-source.h"
|
#include "ges-uri-source.h"
|
||||||
#include "ges-uri-asset.h"
|
#include "ges-uri-asset.h"
|
||||||
#include "ges-extractable.h"
|
#include "ges-extractable.h"
|
||||||
|
|
||||||
|
struct _GESUriSourcePrivate
|
||||||
|
{
|
||||||
|
GHashTable *props_hashtable;
|
||||||
|
void *dummy;
|
||||||
|
};
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
ges_extractable_check_id (GType type, const gchar * id, GError ** error)
|
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,
|
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
|
||||||
ges_extractable_interface_init));
|
ges_extractable_interface_init));
|
||||||
|
|
||||||
struct _GESUriSourcePrivate
|
|
||||||
{
|
|
||||||
void *dummy;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
@ -135,6 +137,9 @@ ges_uri_source_create_element (GESTrackElement * trksrc)
|
||||||
GstPad *ghost;
|
GstPad *ghost;
|
||||||
GESLayer *layer;
|
GESLayer *layer;
|
||||||
gfloat layer_volume;
|
gfloat layer_volume;
|
||||||
|
GObjectClass *class;
|
||||||
|
guint i, nb_specs;
|
||||||
|
GParamSpec **parray;
|
||||||
|
|
||||||
self = (GESUriSource *) trksrc;
|
self = (GESUriSource *) trksrc;
|
||||||
track = ges_track_element_get_track (trksrc);
|
track = ges_track_element_get_track (trksrc);
|
||||||
|
@ -171,6 +176,22 @@ ges_uri_source_create_element (GESTrackElement * trksrc)
|
||||||
} else
|
} else
|
||||||
GST_DEBUG_OBJECT (trksrc, "NOT setting the volume");
|
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;
|
ret = topbin;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -185,6 +206,19 @@ ges_uri_source_create_element (GESTrackElement * trksrc)
|
||||||
return ret;
|
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
|
static void
|
||||||
ges_track_filesource_class_init (GESUriSourceClass * klass)
|
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));
|
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
track_class->create_element = ges_uri_source_create_element;
|
track_class->create_element = ges_uri_source_create_element;
|
||||||
|
track_class->get_props_hastable = ges_uri_source_get_props_hashtable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -214,6 +249,7 @@ ges_track_filesource_init (GESUriSource * self)
|
||||||
{
|
{
|
||||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||||
GES_TYPE_URI_SOURCE, GESUriSourcePrivate);
|
GES_TYPE_URI_SOURCE, GESUriSourcePrivate);
|
||||||
|
self->priv->props_hashtable = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "ges-internal.h"
|
#include "ges-internal.h"
|
||||||
#include "ges-timeline.h"
|
#include "ges-timeline.h"
|
||||||
#include "ges-track.h"
|
#include "ges-track.h"
|
||||||
|
@ -97,3 +99,26 @@ element_end_compare (GESTimelineElement * a, GESTimelineElement * b)
|
||||||
|
|
||||||
return 1;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
GESTimeline * ges_timeline_new_audio_video (void);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue