Remove GST_TYPE_DATE, our own GDate type

Which we had to add because GLib didn't have it
back in the day. Port everything to plain old
G_TYPE_DATE, which is also a boxed type. Ideally
we'd just use GDateTime for everything, but it
doesn't support not setting some of the fields
unfortuntely (which would be very useful for
tag handling in general, if we could express
2012-01 for example).

https://bugzilla.gnome.org/show_bug.cgi?id=666351
This commit is contained in:
Tim-Philipp Müller 2012-01-12 20:46:27 +00:00
parent 18ef740f05
commit c721d53773
9 changed files with 19 additions and 125 deletions

View file

@ -2828,12 +2828,6 @@ gst_value_get_fraction_range_min
gst_value_get_fraction_range_max
gst_value_set_fraction_range_full
<SUBSECTION date>
GST_VALUE_HOLDS_DATE
GST_TYPE_DATE
gst_value_set_date
gst_value_get_date
<SUBSECTION datetime>
GST_VALUE_HOLDS_DATE_TIME

View file

@ -467,3 +467,10 @@ The 0.11 porting guide
gst_registry_get_default() -> gst_registry_get()
gst_default_registry_*(...) -> gst_registry_*(gst_registry_get(), ...)
* GstValue
GST_TYPE_DATE -> G_TYPE_DATE
GST_VALUE_HOLDS_DATE(value) -> G_VALUE_HOLDS(value,G_TYPE_DATE)
gst_value_set_date() -> g_value_set_boxed()
gst_value_get_date() -> g_value_get_boxed()

View file

@ -811,10 +811,6 @@ gst_caps_set_simple_valist (GstCaps * caps, const char *field, va_list varargs)
type = va_arg (varargs, GType);
if (G_UNLIKELY (type == G_TYPE_DATE)) {
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
type = GST_TYPE_DATE;
}
G_VALUE_COLLECT_INIT (&value, type, varargs, 0, &err);
if (G_UNLIKELY (err)) {
g_critical ("%s", err);

View file

@ -581,10 +581,6 @@ gst_structure_set_valist_internal (GstStructure * structure,
type = va_arg (varargs, GType);
if (G_UNLIKELY (type == G_TYPE_DATE)) {
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
type = GST_TYPE_DATE;
}
G_VALUE_COLLECT_INIT (&field.value, type, varargs, 0, &err);
if (G_UNLIKELY (err)) {
g_critical ("%s", err);
@ -651,10 +647,6 @@ gst_structure_id_set_valist_internal (GstStructure * structure,
type = va_arg (varargs, GType);
if (G_UNLIKELY (type == G_TYPE_DATE)) {
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
type = GST_TYPE_DATE;
}
#ifndef G_VALUE_COLLECT_INIT
g_value_init (&field.value, type);
G_VALUE_COLLECT (&field.value, varargs, 0, &err);
@ -797,10 +789,10 @@ gst_structure_set_field (GstStructure * structure, GstStructureField * field)
g_value_unset (&field->value);
return;
}
} else if (G_UNLIKELY (GST_VALUE_HOLDS_DATE (&field->value))) {
} else if (G_UNLIKELY (G_VALUE_HOLDS (&field->value, G_TYPE_DATE))) {
const GDate *d;
d = gst_value_get_date (&field->value);
d = g_value_get_boxed (&field->value);
/* only check for NULL GDates in taglists, as they might make sense
* in other, generic structs */
if (G_UNLIKELY ((IS_TAGLIST (structure) && d == NULL))) {
@ -1398,7 +1390,7 @@ gst_structure_get_date (const GstStructure * structure, const gchar * fieldname,
if (field == NULL)
return FALSE;
if (!GST_VALUE_HOLDS_DATE (&field->value))
if (!G_VALUE_HOLDS (&field->value, G_TYPE_DATE))
return FALSE;
/* FIXME: 0.11 g_value_dup_boxed() -> g_value_get_boxed() */
@ -1687,7 +1679,7 @@ gst_structure_get_abbrs (gint * n_abbrs)
,
{"structure", GST_TYPE_STRUCTURE}
,
{"date", GST_TYPE_DATE}
{"date", G_TYPE_DATE}
,
{"datetime", GST_TYPE_DATE_TIME}
,

View file

@ -149,9 +149,9 @@ _priv_gst_tag_initialize (void)
G_TYPE_STRING,
_("album artist sortname"),
_("The artist of the entire album, as it should be sorted"), NULL);
gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, GST_TYPE_DATE,
gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_DATE,
_("date"), _("date the data was created (as a GDate structure)"), NULL);
gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, GST_TYPE_DATE_TIME,
gst_tag_register (GST_TAG_DATE_TIME, GST_TAG_FLAG_META, G_TYPE_DATE_TIME,
_("datetime"),
_("date and time the data was created (as a GstDateTime structure)"),
NULL);

View file

@ -4447,52 +4447,6 @@ gst_value_compare_fraction (const GValue * value1, const GValue * value2)
* GDate *
*********/
/**
* gst_value_set_date:
* @value: a GValue initialized to GST_TYPE_DATE
* @date: the date to set the value to
*
* Sets the contents of @value to correspond to @date. The actual
* #GDate structure is copied before it is used.
*/
void
gst_value_set_date (GValue * value, const GDate * date)
{
g_return_if_fail (G_VALUE_TYPE (value) == GST_TYPE_DATE);
g_return_if_fail (g_date_valid (date));
g_value_set_boxed (value, date);
}
/**
* gst_value_get_date:
* @value: a GValue initialized to GST_TYPE_DATE
*
* Gets the contents of @value.
*
* Returns: (transfer none): the contents of @value
*/
const GDate *
gst_value_get_date (const GValue * value)
{
g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_DATE, NULL);
return (const GDate *) g_value_get_boxed (value);
}
static gpointer
gst_date_copy (gpointer boxed)
{
const GDate *date = (const GDate *) boxed;
if (!g_date_valid (date)) {
GST_WARNING ("invalid GDate");
return NULL;
}
return g_date_new_julian (g_date_get_julian (date));
}
static gint
gst_value_compare_date (const GValue * value1, const GValue * value2)
{
@ -4994,25 +4948,6 @@ static const GTypeValueTable _gst_fraction_value_table = {
FUNC_VALUE_GET_TYPE (fraction, "GstFraction");
GType
gst_date_get_type (void)
{
static GType gst_date_type = 0;
if (G_UNLIKELY (gst_date_type == 0)) {
/* FIXME 0.11: we require GLib 2.8 already
* Not using G_TYPE_DATE here on purpose, even if we could
* if GLIB_CHECK_VERSION(2,8,0) was true: we don't want the
* serialised strings to have different type strings depending
* on what version is used, so FIXME when we require GLib-2.8 */
gst_date_type = g_boxed_type_register_static ("GstDate",
(GBoxedCopyFunc) gst_date_copy, (GBoxedFreeFunc) g_date_free);
}
return gst_date_type;
}
GType
gst_date_time_get_type (void)
{
@ -5189,7 +5124,7 @@ _priv_gst_value_initialize (void)
gst_value_deserialize_date,
};
gst_value.type = gst_date_get_type ();
gst_value.type = G_TYPE_DATE;
gst_value_register (&gst_value);
}
{
@ -5260,9 +5195,9 @@ _priv_gst_value_initialize (void)
gst_value_transform_double_fraction);
g_value_register_transform_func (G_TYPE_FLOAT, GST_TYPE_FRACTION,
gst_value_transform_float_fraction);
g_value_register_transform_func (GST_TYPE_DATE, G_TYPE_STRING,
g_value_register_transform_func (G_TYPE_DATE, G_TYPE_STRING,
gst_value_transform_date_string);
g_value_register_transform_func (G_TYPE_STRING, GST_TYPE_DATE,
g_value_register_transform_func (G_TYPE_STRING, G_TYPE_DATE,
gst_value_transform_string_date);
g_value_register_transform_func (GST_TYPE_OBJECT, G_TYPE_STRING,
gst_value_transform_object_string);

View file

@ -177,14 +177,6 @@ G_BEGIN_DECLS
*/
#define GST_VALUE_HOLDS_FRACTION(x) (G_VALUE_HOLDS((x), gst_fraction_get_type ()))
/**
* GST_VALUE_HOLDS_DATE:
* @x: the #GValue to check
*
* Checks if the given #GValue contains a #GST_TYPE_DATE value.
*/
#define GST_VALUE_HOLDS_DATE(x) (G_VALUE_HOLDS((x), gst_date_get_type ()))
/**
* GST_VALUE_HOLDS_DATE_TIME:
* @x: the #GValue to check
@ -279,16 +271,6 @@ G_BEGIN_DECLS
#define GST_TYPE_FRACTION gst_fraction_get_type ()
/**
* GST_TYPE_DATE:
*
* a boxed #GValue type for #GDate that represents a date.
*
* Returns: the #GType of GstDate
*/
#define GST_TYPE_DATE gst_date_get_type ()
/**
* GST_TYPE_DATE_TIME:
*
@ -456,7 +438,6 @@ GType gst_value_list_get_type (void);
GType gst_value_array_get_type (void);
GType gst_bitmask_get_type (void);
GType gst_date_get_type (void);
GType gst_date_time_get_type (void);
void gst_value_register (const GstValueTable *table);
@ -548,12 +529,6 @@ void gst_value_set_fraction_range_full (GValue *value,
const GValue *gst_value_get_fraction_range_min (const GValue *value);
const GValue *gst_value_get_fraction_range_max (const GValue *value);
/* date */
const GDate * gst_value_get_date (const GValue *value);
void gst_value_set_date (GValue *value,
const GDate *date);
/* bitmask */
guint64 gst_value_get_bitmask (const GValue *value);
void gst_value_set_bitmask (GValue *value,

View file

@ -1951,11 +1951,10 @@ GST_START_TEST (test_date)
date = g_date_new_dmy (22, 9, 2005);
s = gst_structure_new ("media/x-type", "SOME_DATE_TAG", GST_TYPE_DATE,
s = gst_structure_new ("media/x-type", "SOME_DATE_TAG", G_TYPE_DATE,
date, NULL);
fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG",
GST_TYPE_DATE));
fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG", G_TYPE_DATE));
fail_unless (gst_structure_get_date (s, "SOME_DATE_TAG", &date2));
fail_unless (date2 != NULL);
fail_unless (g_date_valid (date2));
@ -1979,8 +1978,7 @@ GST_START_TEST (test_date)
fail_unless (s != NULL);
fail_unless (gst_structure_has_name (s, "media/x-type"));
fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG",
GST_TYPE_DATE));
fail_unless (gst_structure_has_field_typed (s, "SOME_DATE_TAG", G_TYPE_DATE));
fail_unless (gst_structure_get_date (s, "SOME_DATE_TAG", &date));
fail_unless (date != NULL);
fail_unless (g_date_valid (date));

View file

@ -267,7 +267,6 @@ EXPORTS
gst_control_source_get_value_array
gst_core_error_get_type
gst_core_error_quark
gst_date_get_type
gst_date_time_get_day
gst_date_time_get_hour
gst_date_time_get_microsecond
@ -1186,7 +1185,6 @@ EXPORTS
gst_value_fraction_subtract
gst_value_get_bitmask
gst_value_get_caps
gst_value_get_date
gst_value_get_double_range_max
gst_value_get_double_range_min
gst_value_get_fraction_denominator
@ -1215,7 +1213,6 @@ EXPORTS
gst_value_serialize
gst_value_set_bitmask
gst_value_set_caps
gst_value_set_date
gst_value_set_double_range
gst_value_set_fraction
gst_value_set_fraction_range