mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
datetime: change internal implementation to mini object
And move type stuff from GstValue to GstDateTime.
This commit is contained in:
parent
f446280740
commit
8998cf840d
4 changed files with 24 additions and 27 deletions
|
@ -56,12 +56,17 @@ typedef enum
|
||||||
|
|
||||||
struct _GstDateTime
|
struct _GstDateTime
|
||||||
{
|
{
|
||||||
|
GstMiniObject mini_object;
|
||||||
|
|
||||||
GDateTime *datetime;
|
GDateTime *datetime;
|
||||||
|
|
||||||
GstDateTimeFields fields;
|
GstDateTimeFields fields;
|
||||||
volatile gint ref_count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GST_DEFINE_MINI_OBJECT_TYPE (GstDateTime, gst_date_time);
|
||||||
|
|
||||||
|
static void gst_date_time_free (GstDateTime * datetime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_date_time_new_from_g_date_time:
|
* gst_date_time_new_from_g_date_time:
|
||||||
* @dt: (transfer full): the #GDateTime. The new #GstDateTime takes ownership.
|
* @dt: (transfer full): the #GDateTime. The new #GstDateTime takes ownership.
|
||||||
|
@ -81,9 +86,12 @@ gst_date_time_new_from_g_date_time (GDateTime * dt)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
gst_dt = g_slice_new (GstDateTime);
|
gst_dt = g_slice_new (GstDateTime);
|
||||||
|
|
||||||
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (gst_dt), 0, GST_TYPE_DATE_TIME,
|
||||||
|
NULL, NULL, (GstMiniObjectFreeFunction) gst_date_time_free);
|
||||||
|
|
||||||
gst_dt->datetime = dt;
|
gst_dt->datetime = dt;
|
||||||
gst_dt->fields = GST_DATE_TIME_FIELDS_YMD_HMS;
|
gst_dt->fields = GST_DATE_TIME_FIELDS_YMD_HMS;
|
||||||
gst_dt->ref_count = 1;
|
|
||||||
return gst_dt;
|
return gst_dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,7 +876,6 @@ ymd:
|
||||||
return gst_date_time_new_ymd (year, month, day);
|
return gst_date_time_new_ymd (year, month, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_date_time_free (GstDateTime * datetime)
|
gst_date_time_free (GstDateTime * datetime)
|
||||||
{
|
{
|
||||||
|
@ -887,10 +894,7 @@ gst_date_time_free (GstDateTime * datetime)
|
||||||
GstDateTime *
|
GstDateTime *
|
||||||
gst_date_time_ref (GstDateTime * datetime)
|
gst_date_time_ref (GstDateTime * datetime)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (datetime != NULL, NULL);
|
return (GstDateTime *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (datetime));
|
||||||
g_return_val_if_fail (datetime->ref_count > 0, NULL);
|
|
||||||
g_atomic_int_inc (&datetime->ref_count);
|
|
||||||
return datetime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -903,9 +907,5 @@ gst_date_time_ref (GstDateTime * datetime)
|
||||||
void
|
void
|
||||||
gst_date_time_unref (GstDateTime * datetime)
|
gst_date_time_unref (GstDateTime * datetime)
|
||||||
{
|
{
|
||||||
g_return_if_fail (datetime != NULL);
|
gst_mini_object_unref (GST_MINI_OBJECT_CAST (datetime));
|
||||||
g_return_if_fail (datetime->ref_count > 0);
|
|
||||||
|
|
||||||
if (g_atomic_int_dec_and_test (&datetime->ref_count))
|
|
||||||
gst_date_time_free (datetime);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,18 @@ G_BEGIN_DECLS
|
||||||
*/
|
*/
|
||||||
typedef struct _GstDateTime GstDateTime;
|
typedef struct _GstDateTime GstDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_TYPE_DATE_TIME:
|
||||||
|
*
|
||||||
|
* a boxed #GValue type for #GstDateTime that represents a date and time.
|
||||||
|
*
|
||||||
|
* Returns: the #GType of GstDateTime
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define GST_TYPE_DATE_TIME gst_date_time_get_type()
|
||||||
|
|
||||||
|
GType gst_date_time_get_type (void);
|
||||||
|
|
||||||
/* query which fields are set */
|
/* query which fields are set */
|
||||||
|
|
||||||
gboolean gst_date_time_has_year (const GstDateTime * datetime);
|
gboolean gst_date_time_has_year (const GstDateTime * datetime);
|
||||||
|
|
|
@ -6029,9 +6029,6 @@ static const GTypeValueTable _gst_fraction_value_table = {
|
||||||
|
|
||||||
FUNC_VALUE_GET_TYPE (fraction, "GstFraction");
|
FUNC_VALUE_GET_TYPE (fraction, "GstFraction");
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GstDateTime, gst_date_time,
|
|
||||||
(GBoxedCopyFunc) gst_date_time_ref, (GBoxedFreeFunc) gst_date_time_unref);
|
|
||||||
|
|
||||||
static const GTypeValueTable _gst_bitmask_value_table = {
|
static const GTypeValueTable _gst_bitmask_value_table = {
|
||||||
gst_value_init_bitmask,
|
gst_value_init_bitmask,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -272,16 +272,6 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_FRACTION gst_fraction_get_type ()
|
#define GST_TYPE_FRACTION gst_fraction_get_type ()
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_TYPE_DATE_TIME:
|
|
||||||
*
|
|
||||||
* a boxed #GValue type for #GstDateTime that represents a date and time.
|
|
||||||
*
|
|
||||||
* Returns: the #GType of GstDateTime
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GST_TYPE_DATE_TIME gst_date_time_get_type ()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GST_TYPE_BITMASK:
|
* GST_TYPE_BITMASK:
|
||||||
*
|
*
|
||||||
|
@ -405,8 +395,6 @@ GType gst_bitmask_get_type (void);
|
||||||
GType gst_g_thread_get_type (void);
|
GType gst_g_thread_get_type (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GType gst_date_time_get_type (void);
|
|
||||||
|
|
||||||
void gst_value_register (const GstValueTable *table);
|
void gst_value_register (const GstValueTable *table);
|
||||||
void gst_value_init_and_copy (GValue *dest,
|
void gst_value_init_and_copy (GValue *dest,
|
||||||
const GValue *src);
|
const GValue *src);
|
||||||
|
|
Loading…
Reference in a new issue