![]() |
![]() |
![]() |
Grilo Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
GrlDataGrlData — Low-level class for storing metadata information about media resources provided by GrlMediaSource objects. |
#include <grilo.h> struct GrlData; struct GrlDataClass; GrlData * grl_data_new (void
); void grl_data_add_binary (GrlData *data
,GrlKeyID key
,const guint8 *buf
,gsize size
); void grl_data_add_boxed (GrlData *data
,GrlKeyID key
,gconstpointer boxed
); void grl_data_add_float (GrlData *data
,GrlKeyID key
,gfloat floatvalue
); void grl_data_add_int (GrlData *data
,GrlKeyID key
,gint intvalue
); void grl_data_add_related_keys (GrlData *data
,GrlRelatedKeys *relkeys
); void grl_data_add_string (GrlData *data
,GrlKeyID key
,const gchar *strvalue
); GrlData * grl_data_dup (GrlData *data
); const GValue * grl_data_get (GrlData *data
,GrlKeyID key
); const guint8 * grl_data_get_binary (GrlData *data
,GrlKeyID key
,gsize *size
); gpointer grl_data_get_boxed (GrlData *data
,GrlKeyID key
); gfloat grl_data_get_float (GrlData *data
,GrlKeyID key
); gint grl_data_get_int (GrlData *data
,GrlKeyID key
); GList * grl_data_get_keys (GrlData *data
); GrlRelatedKeys * grl_data_get_related_keys (GrlData *data
,GrlKeyID key
,guint index
); GList * grl_data_get_single_values_for_key (GrlData *data
,GrlKeyID key
); GList * grl_data_get_single_values_for_key_string (GrlData *data
,GrlKeyID key
); const gchar * grl_data_get_string (GrlData *data
,GrlKeyID key
); gboolean grl_data_has_key (GrlData *data
,GrlKeyID key
); guint grl_data_length (GrlData *data
,GrlKeyID key
); void grl_data_remove (GrlData *data
,GrlKeyID key
); void grl_data_remove_nth (GrlData *data
,GrlKeyID key
,guint index
); void grl_data_set (GrlData *data
,GrlKeyID key
,const GValue *value
); void grl_data_set_binary (GrlData *data
,GrlKeyID key
,const guint8 *buf
,gsize size
); void grl_data_set_boxed (GrlData *data
,GrlKeyID key
,gconstpointer boxed
); void grl_data_set_float (GrlData *data
,GrlKeyID key
,gfloat floatvalue
); void grl_data_set_int (GrlData *data
,GrlKeyID key
,gint intvalue
); void grl_data_set_related_keys (GrlData *data
,GrlRelatedKeys *relkeys
,guint index
); void grl_data_set_string (GrlData *data
,GrlKeyID key
,const gchar *strvalue
);
This class acts as a generic metadata dictionary where metadata keys and their values can be stored. Usually, application and plugin developers would interact with specific subclasses of GrlData, like GrlMedia or GrlMediaVideo, which provide specific API to manipulate well known attributes of these media types.
GrlData * grl_data_new (void
);
Creates a new data object.
Returns : |
a new data object. |
Since 0.1.4
void grl_data_add_binary (GrlData *data
,GrlKeyID key
,const guint8 *buf
,gsize size
);
Appends a new binary value for key
in data
.
|
data to append |
|
key to append. [type GrlKeyID] |
|
the buffer containing the new value |
|
size of buffer |
Since 0.1.10
void grl_data_add_boxed (GrlData *data
,GrlKeyID key
,gconstpointer boxed
);
Appends a new boxed value for key
in data
.
|
data to append |
|
key to append. [type GrlKeyID] |
|
the new value |
Since 0.2.0
void grl_data_add_float (GrlData *data
,GrlKeyID key
,gfloat floatvalue
);
Appends a new float value for key
in data
.
|
data to append |
|
key to append. [type GrlKeyID] |
|
the new value |
Since 0.1.10
void grl_data_add_int (GrlData *data
,GrlKeyID key
,gint intvalue
);
Appends a new int value for key
in data
.
|
data to append |
|
key to append. [type GrlKeyID] |
|
the new value |
Since 0.1.10
void grl_data_add_related_keys (GrlData *data
,GrlRelatedKeys *relkeys
);
Adds a new set of values into data
.
All keys in prop
must be related among them.
data
will take the ownership of relkeys
, so do not modify it.
|
data to change |
|
a set of related properties with their values |
Since 0.1.10
void grl_data_add_string (GrlData *data
,GrlKeyID key
,const gchar *strvalue
);
Appends a new string value for key
in data
.
|
data to append |
|
key to append. [type GrlKeyID] |
|
the new value |
Since 0.1.10
GrlData * grl_data_dup (GrlData *data
);
Makes a deep copy of data
and all its contents.
|
data to duplicate |
Returns : |
a new GrlData. Free it with g_object_unref. [transfer full] |
Since 0.1.10
const GValue * grl_data_get (GrlData *data
,GrlKeyID key
);
Get the first value from data
associated with key
.
|
data to retrieve value |
|
key to look up. [type GrlKeyID] |
Returns : |
a GValue. This value should not be modified nor freed by user. [transfer none] |
Since 0.1.4
const guint8 * grl_data_get_binary (GrlData *data
,GrlKeyID key
,gsize *size
);
Returns the first binary value associated with key
from data
. If key
has
no first value, or value is not a gfloat, or key
is not in data, then NULL
is returned.
|
data to inspect |
|
key to use. [type GrlKeyID] |
|
location to store the buffer size. [out] |
Returns : |
buffer location associated with the key , or NULL in other case. If
successful size will be set the to the buffer size. |
Since 0.1.9
gpointer grl_data_get_boxed (GrlData *data
,GrlKeyID key
);
Returns the first boxed value associated with key
from data
. If key
has
no first value, that value is not of a boxed type, or key
is not in data
,
then NULL
is returned.
|
data to inspect |
|
key to use. [type GrlKeyID] |
Returns : |
the boxed instance associated with key if
possible, or NULL in other cases. The caller should not change nor free the
value. [transfer none]
|
Since 0.2.0
gfloat grl_data_get_float (GrlData *data
,GrlKeyID key
);
Returns the first float value associated with key
from data
. If key
has no
first value, or value is not a gfloat, or key
is not in data, then 0 is
returned.
|
data to inspect |
|
key to use. [type GrlKeyID] |
Returns : |
float value associated with key , or 0 in other case. |
Since 0.1.5
gint grl_data_get_int (GrlData *data
,GrlKeyID key
);
Returns the first int value associated with key
from data
. If key
has no
first value, or value is not a gint, or key
is not in data, then 0 is
returned.
|
data to inspect |
|
key to use. [type GrlKeyID] |
Returns : |
int value associated with key , or 0 in other case. |
Since 0.1.4
GList * grl_data_get_keys (GrlData *data
);
Returns a list with keys contained in data
.
|
data to inspect |
Returns : |
an array with the
keys. The content of the list should not be modified or freed. Use
g_list_free() when done using the list. [transfer container][element-type GrlKeyID]
|
Since 0.1.4
GrlRelatedKeys * grl_data_get_related_keys (GrlData *data
,GrlKeyID key
,guint index
);
Returns a set containing the values for key
and related keys at position
index
from data
.
If user changes any of the values in the related keys, the changes will become permanent.
|
a data |
|
a metadata key |
|
element to retrieve, starting at 0 |
Returns : |
a GrlRelatedKeys. Do not free it. [transfer none] |
Since 0.1.10
GList * grl_data_get_single_values_for_key (GrlData *data
,GrlKeyID key
);
Returns all non-NULL
values for key
from data
. This ignores related keys.
|
a data |
|
a metadata key |
Returns : |
a GList with values. Do not change or free the values. Free the list with g_list_free. [element-type GObject.Value][transfer container] |
Since 0.1.13
GList * grl_data_get_single_values_for_key_string (GrlData *data
,GrlKeyID key
);
Returns all non-NULL
values for key
from data
. key
must have been
registered as a string-type key. This ignores related keys.
|
a data |
|
a metadata key |
Returns : |
a GList with values. Do not change or free the strings. Free the list with g_list_free. [element-type utf8][transfer container] |
Since 0.1.13
const gchar * grl_data_get_string (GrlData *data
,GrlKeyID key
);
Returns the first string value associated with key
from data
. If key
has
no first value, or value is not string, or key
is not in data
, then NULL
is returned.
|
data to inspect |
|
key to use. [type GrlKeyID] |
Returns : |
string associated with key , or NULL in other case. Caller should
not change nor free the value. |
Since 0.1.4
gboolean grl_data_has_key (GrlData *data
,GrlKeyID key
);
Checks if key
is in data
.
|
data to inspect |
|
key to search. [type GrlKeyID] |
Returns : |
TRUE if key is in data , FALSE in other case. |
Since 0.1.4
guint grl_data_length (GrlData *data
,GrlKeyID key
);
Returns how many values key
or related keys have in data
: if key
has no
value, but a related key has, then it is counted as positive.
As example, let's think in three related keys, K1, K2 and K3, and then thinks we have added several values for those keys, as:
(V10, V20, V30),, (V11, NULL, V31), (V12, NULL, V32)
Therefore, when invoking grl_data_length (data, K2) it will return 3: considering K2 and the related keys (K1 and K3), there are 3 values.
|
a data |
|
a metadata key |
Returns : |
number of values |
Since 0.1.10
void grl_data_remove (GrlData *data
,GrlKeyID key
);
Removes the first value for key
from data
. If there are other keys related
to key
their values will also be removed from data
.
|
data to change |
|
key to remove. [type GrlKeyID] |
Since 0.1.4
void grl_data_remove_nth (GrlData *data
,GrlKeyID key
,guint index
);
Removes the value at position index
for key
from data
. If there are other
keys related to key
, their values at position index
will also be removed
from data
.
|
a data |
|
a metadata key |
|
index of key to be removed, starting at 0 |
Since 0.1.10
void grl_data_set (GrlData *data
,GrlKeyID key
,const GValue *value
);
Sets the first value associated with key
in data
. If key already has a
value old value is freed and the new one is set.
Also, checks that value
is compliant with key
specification, modifying it
accordingly. For instance, if key
requires a number between 0 and 10, but
value
is outside this range, it will be adapted accordingly.
|
data to modify |
|
key to change or add. [type GrlKeyID] |
|
the new value |
Since 0.1.4
void grl_data_set_binary (GrlData *data
,GrlKeyID key
,const guint8 *buf
,gsize size
);
Sets the first binary value associated with key
in data
. If key
already
has a first value old value is replaced by the new one.
|
data to change |
|
key to change or add. [type GrlKeyID] |
|
buffer holding the data |
|
size of the buffer |
Since 0.1.9
void grl_data_set_boxed (GrlData *data
,GrlKeyID key
,gconstpointer boxed
);
Sets the first boxed value associated with key
in data
. If key
already
has a value, the old value is freed and the new one is set.
|
data to modify |
|
key to change or add |
|
the new value |
Since 0.2.0
void grl_data_set_float (GrlData *data
,GrlKeyID key
,gfloat floatvalue
);
Sets the first float value associated with key
in data
. If key
already has
a first value old value is replaced by the new one.
|
data to change |
|
key to change or add. [type GrlKeyID] |
|
the new value |
Since 0.1.5
void grl_data_set_int (GrlData *data
,GrlKeyID key
,gint intvalue
);
Sets the first int value associated with key
in data
. If key
already has a
first value old value is replaced by the new one.
|
data to change |
|
key to change or add. [type GrlKeyID] |
|
the new value |
Since 0.1.4
void grl_data_set_related_keys (GrlData *data
,GrlRelatedKeys *relkeys
,guint index
);
Updates the values at position index
in data
with values in relkeys
.
data
will take ownership of relkeys
, so do not free it after invoking this
function.
|
a data |
|
a set of related keys |
|
position to be updated, starting at 0 |
Since 0.1.10
void grl_data_set_string (GrlData *data
,GrlKeyID key
,const gchar *strvalue
);
Sets the first string value associated with key
in data
. If key
already
has a value old value is freed and the new one is set.
|
data to modify |
|
key to change or add. [type GrlKeyID] |
|
the new value |
Since 0.1.4