mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Add type to quark and type to string conversions.
Original commit message from CVS: * docs/design/part-TODO.txt: * gst/gstformat.c: (_gst_format_initialize), (gst_format_get_name), (gst_format_to_quark), (gst_format_register): * gst/gstformat.h: * gst/gstquery.c: (_gst_query_initialize), (gst_query_type_get_name), (gst_query_type_to_quark), (gst_query_type_register): * gst/gstquery.h: Add type to quark and type to string conversions.
This commit is contained in:
parent
9192ae50e0
commit
8d46970ed8
6 changed files with 88 additions and 20 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2005-11-19 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* docs/design/part-TODO.txt:
|
||||||
|
* gst/gstformat.c: (_gst_format_initialize), (gst_format_get_name),
|
||||||
|
(gst_format_to_quark), (gst_format_register):
|
||||||
|
* gst/gstformat.h:
|
||||||
|
* gst/gstquery.c: (_gst_query_initialize),
|
||||||
|
(gst_query_type_get_name), (gst_query_type_to_quark),
|
||||||
|
(gst_query_type_register):
|
||||||
|
* gst/gstquery.h:
|
||||||
|
Add type to quark and type to string conversions.
|
||||||
|
|
||||||
2005-11-19 Andy Wingo <wingo@pobox.com>
|
2005-11-19 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
* gst/gstbuffer.h (GST_BUFFER_FLAG_ORIGINAL): Removed. Fixes
|
* gst/gstbuffer.h (GST_BUFFER_FLAG_ORIGINAL): Removed. Fixes
|
||||||
|
|
|
@ -11,8 +11,6 @@ API/ABI
|
||||||
|
|
||||||
- make it possible to seek on other formats than bytes in basesrc.
|
- make it possible to seek on other formats than bytes in basesrc.
|
||||||
|
|
||||||
- GstFormat, GstQuery quarks, get_name.
|
|
||||||
|
|
||||||
- GstEvent, GstMessage register like GstFormat or GstQuery.
|
- GstEvent, GstMessage register like GstFormat or GstQuery.
|
||||||
|
|
||||||
- unblocking while seeking. gst_element_flush_pads (GstElement, gboolean);
|
- unblocking while seeking. gst_element_flush_pads (GstElement, gboolean);
|
||||||
|
|
|
@ -43,12 +43,12 @@ static GHashTable *_format_to_nick = NULL;
|
||||||
static guint32 _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */
|
static guint32 _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */
|
||||||
|
|
||||||
static GstFormatDefinition standard_definitions[] = {
|
static GstFormatDefinition standard_definitions[] = {
|
||||||
{GST_FORMAT_DEFAULT, "default", "Default format for the media type"},
|
{GST_FORMAT_DEFAULT, "default", "Default format for the media type", 0},
|
||||||
{GST_FORMAT_BYTES, "bytes", "Bytes"},
|
{GST_FORMAT_BYTES, "bytes", "Bytes", 0},
|
||||||
{GST_FORMAT_TIME, "time", "Time"},
|
{GST_FORMAT_TIME, "time", "Time", 0},
|
||||||
{GST_FORMAT_BUFFERS, "buffers", "Buffers"},
|
{GST_FORMAT_BUFFERS, "buffers", "Buffers", 0},
|
||||||
{GST_FORMAT_PERCENT, "percent", "Percent"},
|
{GST_FORMAT_PERCENT, "percent", "Percent", 0},
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -63,6 +63,7 @@ _gst_format_initialize (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (standards->nick) {
|
while (standards->nick) {
|
||||||
|
standards->quark = g_quark_from_static_string (standards->nick);
|
||||||
g_hash_table_insert (_nick_to_format, standards->nick, standards);
|
g_hash_table_insert (_nick_to_format, standards->nick, standards);
|
||||||
g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value),
|
g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value),
|
||||||
standards);
|
standards);
|
||||||
|
@ -74,6 +75,26 @@ _gst_format_initialize (void)
|
||||||
g_static_mutex_unlock (&mutex);
|
g_static_mutex_unlock (&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gst_format_get_name (GstFormat format)
|
||||||
|
{
|
||||||
|
const GstFormatDefinition *def;
|
||||||
|
|
||||||
|
def = gst_format_get_details (format);
|
||||||
|
|
||||||
|
return def->nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
GQuark
|
||||||
|
gst_format_to_quark (GstFormat format)
|
||||||
|
{
|
||||||
|
const GstFormatDefinition *def;
|
||||||
|
|
||||||
|
def = gst_format_get_details (format);
|
||||||
|
|
||||||
|
return def->quark;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_format_register:
|
* gst_format_register:
|
||||||
* @nick: The nick of the new format
|
* @nick: The nick of the new format
|
||||||
|
@ -104,6 +125,7 @@ gst_format_register (const gchar * nick, const gchar * description)
|
||||||
format->value = _n_values;
|
format->value = _n_values;
|
||||||
format->nick = g_strdup (nick);
|
format->nick = g_strdup (nick);
|
||||||
format->description = g_strdup (description);
|
format->description = g_strdup (description);
|
||||||
|
format->quark = g_quark_from_static_string (format->nick);
|
||||||
|
|
||||||
g_static_mutex_lock (&mutex);
|
g_static_mutex_lock (&mutex);
|
||||||
g_hash_table_insert (_nick_to_format, format->nick, format);
|
g_hash_table_insert (_nick_to_format, format->nick, format);
|
||||||
|
|
|
@ -34,7 +34,8 @@ G_BEGIN_DECLS
|
||||||
/**
|
/**
|
||||||
* GstFormat:
|
* GstFormat:
|
||||||
* @GST_FORMAT_UNDEFINED: undefined format
|
* @GST_FORMAT_UNDEFINED: undefined format
|
||||||
* @GST_FORMAT_DEFAULT: the default format of the pad/element
|
* @GST_FORMAT_DEFAULT: the default format of the pad/element. This can be
|
||||||
|
* samples for raw audio, frames/fields for raw video.
|
||||||
* @GST_FORMAT_BYTES: bytes
|
* @GST_FORMAT_BYTES: bytes
|
||||||
* @GST_FORMAT_TIME: time in nanoseconds
|
* @GST_FORMAT_TIME: time in nanoseconds
|
||||||
* @GST_FORMAT_BUFFERS: buffers
|
* @GST_FORMAT_BUFFERS: buffers
|
||||||
|
@ -42,9 +43,11 @@ G_BEGIN_DECLS
|
||||||
*
|
*
|
||||||
* Standard predefined formats
|
* Standard predefined formats
|
||||||
*/
|
*/
|
||||||
|
/* NOTE: don't forget to update the table in gstformat.c when changing
|
||||||
|
* this enum */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_FORMAT_UNDEFINED = 0, /* must be first in list */
|
GST_FORMAT_UNDEFINED = 0, /* must be first in list */
|
||||||
GST_FORMAT_DEFAULT = 1, /* samples for raw audio, frames/fields for raw video */
|
GST_FORMAT_DEFAULT = 1,
|
||||||
GST_FORMAT_BYTES = 2,
|
GST_FORMAT_BYTES = 2,
|
||||||
GST_FORMAT_TIME = 3,
|
GST_FORMAT_TIME = 3,
|
||||||
GST_FORMAT_BUFFERS = 4,
|
GST_FORMAT_BUFFERS = 4,
|
||||||
|
@ -81,10 +84,14 @@ struct _GstFormatDefinition
|
||||||
GstFormat value;
|
GstFormat value;
|
||||||
gchar *nick;
|
gchar *nick;
|
||||||
gchar *description;
|
gchar *description;
|
||||||
|
GQuark quark;
|
||||||
};
|
};
|
||||||
|
|
||||||
void _gst_format_initialize (void);
|
void _gst_format_initialize (void);
|
||||||
|
|
||||||
|
const gchar* gst_format_get_name (GstFormat format);
|
||||||
|
GQuark gst_format_to_quark (GstFormat format);
|
||||||
|
|
||||||
/* register a new format */
|
/* register a new format */
|
||||||
GstFormat gst_format_register (const gchar *nick,
|
GstFormat gst_format_register (const gchar *nick,
|
||||||
const gchar *description);
|
const gchar *description);
|
||||||
|
|
|
@ -58,16 +58,16 @@ static GHashTable *_query_type_to_nick = NULL;
|
||||||
static guint32 _n_values = 1; /* we start from 1 because 0 reserved for NONE */
|
static guint32 _n_values = 1; /* we start from 1 because 0 reserved for NONE */
|
||||||
|
|
||||||
static GstQueryTypeDefinition standard_definitions[] = {
|
static GstQueryTypeDefinition standard_definitions[] = {
|
||||||
{GST_QUERY_POSITION, "position", "Current position"},
|
{GST_QUERY_POSITION, "position", "Current position", 0},
|
||||||
{GST_QUERY_DURATION, "duration", "Total duration"},
|
{GST_QUERY_DURATION, "duration", "Total duration", 0},
|
||||||
{GST_QUERY_LATENCY, "latency", "Latency"},
|
{GST_QUERY_LATENCY, "latency", "Latency", 0},
|
||||||
{GST_QUERY_JITTER, "jitter", "Jitter"},
|
{GST_QUERY_JITTER, "jitter", "Jitter", 0},
|
||||||
{GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1"},
|
{GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1", 0},
|
||||||
{GST_QUERY_SEEKING, "seeking", "Seeking capabilities and parameters"},
|
{GST_QUERY_SEEKING, "seeking", "Seeking capabilities and parameters", 0},
|
||||||
{GST_QUERY_SEGMENT, "segment", "currently configured segment"},
|
{GST_QUERY_SEGMENT, "segment", "currently configured segment", 0},
|
||||||
{GST_QUERY_CONVERT, "convert", "Converting between formats"},
|
{GST_QUERY_CONVERT, "convert", "Converting between formats", 0},
|
||||||
{GST_QUERY_FORMATS, "formats", "Supported formats for conversion"},
|
{GST_QUERY_FORMATS, "formats", "Supported formats for conversion", 0},
|
||||||
{0, NULL, NULL}
|
{0, NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -86,6 +86,7 @@ _gst_query_initialize (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (standards->nick) {
|
while (standards->nick) {
|
||||||
|
standards->quark = g_quark_from_static_string (standards->nick);
|
||||||
g_hash_table_insert (_nick_to_query, standards->nick, standards);
|
g_hash_table_insert (_nick_to_query, standards->nick, standards);
|
||||||
g_hash_table_insert (_query_type_to_nick,
|
g_hash_table_insert (_query_type_to_nick,
|
||||||
GINT_TO_POINTER (standards->value), standards);
|
GINT_TO_POINTER (standards->value), standards);
|
||||||
|
@ -99,6 +100,26 @@ _gst_query_initialize (void)
|
||||||
gst_query_get_type ();
|
gst_query_get_type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gst_query_type_get_name (GstQueryType query)
|
||||||
|
{
|
||||||
|
const GstQueryTypeDefinition *def;
|
||||||
|
|
||||||
|
def = gst_query_type_get_details (query);
|
||||||
|
|
||||||
|
return def->nick;
|
||||||
|
}
|
||||||
|
|
||||||
|
GQuark
|
||||||
|
gst_query_type_to_quark (GstQueryType query)
|
||||||
|
{
|
||||||
|
const GstQueryTypeDefinition *def;
|
||||||
|
|
||||||
|
def = gst_query_type_get_details (query);
|
||||||
|
|
||||||
|
return def->quark;
|
||||||
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_query_get_type (void)
|
gst_query_get_type (void)
|
||||||
{
|
{
|
||||||
|
@ -201,6 +222,7 @@ gst_query_type_register (const gchar * nick, const gchar * description)
|
||||||
query->value = _n_values;
|
query->value = _n_values;
|
||||||
query->nick = g_strdup (nick);
|
query->nick = g_strdup (nick);
|
||||||
query->description = g_strdup (description);
|
query->description = g_strdup (description);
|
||||||
|
query->quark = g_quark_from_static_string (query->nick);
|
||||||
|
|
||||||
g_static_mutex_lock (&mutex);
|
g_static_mutex_lock (&mutex);
|
||||||
g_hash_table_insert (_nick_to_query, query->nick, query);
|
g_hash_table_insert (_nick_to_query, query->nick, query);
|
||||||
|
|
|
@ -49,6 +49,8 @@ G_BEGIN_DECLS
|
||||||
*
|
*
|
||||||
* Standard predefined Query types
|
* Standard predefined Query types
|
||||||
*/
|
*/
|
||||||
|
/* NOTE: don't forget to update the table in gstquery.c when changing
|
||||||
|
* this enum */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_QUERY_NONE = 0,
|
GST_QUERY_NONE = 0,
|
||||||
GST_QUERY_POSITION,
|
GST_QUERY_POSITION,
|
||||||
|
@ -86,6 +88,7 @@ struct _GstQueryTypeDefinition
|
||||||
GstQueryType value;
|
GstQueryType value;
|
||||||
gchar *nick;
|
gchar *nick;
|
||||||
gchar *description;
|
gchar *description;
|
||||||
|
GQuark quark;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GST_TYPE_QUERY (gst_query_get_type())
|
#define GST_TYPE_QUERY (gst_query_get_type())
|
||||||
|
@ -118,6 +121,10 @@ struct _GstQueryClass {
|
||||||
};
|
};
|
||||||
|
|
||||||
void _gst_query_initialize (void);
|
void _gst_query_initialize (void);
|
||||||
|
|
||||||
|
const gchar* gst_query_type_get_name (GstQueryType query);
|
||||||
|
GQuark gst_query_type_to_quark (GstQueryType query);
|
||||||
|
|
||||||
GType gst_query_get_type (void);
|
GType gst_query_get_type (void);
|
||||||
|
|
||||||
/* register a new query */
|
/* register a new query */
|
||||||
|
|
Loading…
Reference in a new issue