mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-29 18:48:44 +00:00
Remove old query functions. Ported old code.
Original commit message from CVS: Remove old query functions. Ported old code. Added position/convert helper functions to gstutils. Reordered gstpad.c code, grouping relevant things. Remove gst_message_new(), always need to speficy a specific message.
This commit is contained in:
parent
328ddd7363
commit
8df6cd7243
24 changed files with 966 additions and 1197 deletions
57
ChangeLog
57
ChangeLog
|
@ -1,3 +1,60 @@
|
|||
2005-05-09 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* docs/design/draft-push-pull.txt:
|
||||
* gst/base/gstbasesrc.c: (gst_basesrc_init), (gst_basesrc_query):
|
||||
* gst/elements/gstfilesink.c: (gst_filesink_init),
|
||||
(gst_filesink_query):
|
||||
* gst/elements/gsttypefindelement.c: (gst_type_find_element_init),
|
||||
(gst_type_find_handle_src_query), (find_element_get_length):
|
||||
* gst/gstelement.c: (gst_element_seek), (gst_element_query):
|
||||
* gst/gstelement.h:
|
||||
* gst/gstmessage.c:
|
||||
* gst/gstmessage.h:
|
||||
* gst/gstpad.c: (gst_real_pad_init), (gst_pad_get_query_types),
|
||||
(gst_real_pad_get_caps_unlocked),
|
||||
(gst_pad_get_internal_links_default), (gst_pad_get_internal_links),
|
||||
(gst_pad_event_default_dispatch), (gst_pad_event_default),
|
||||
(gst_pad_dispatcher), (gst_pad_query), (gst_pad_query_default),
|
||||
(gst_real_pad_dispose), (gst_real_pad_finalize),
|
||||
(gst_pad_load_and_link), (gst_pad_save_thyself),
|
||||
(gst_ghost_pad_save_thyself), (handle_pad_block), (gst_pad_push),
|
||||
(gst_pad_check_pull_range), (gst_pad_pull_range),
|
||||
(gst_pad_template_get_type), (gst_pad_template_class_init),
|
||||
(gst_pad_template_init), (gst_pad_template_dispose),
|
||||
(name_is_valid), (gst_static_pad_template_get),
|
||||
(gst_pad_template_new), (gst_static_pad_template_get_caps),
|
||||
(gst_pad_template_get_caps), (gst_pad_set_element_private),
|
||||
(gst_pad_get_element_private), (gst_pad_start_task),
|
||||
(gst_pad_pause_task), (gst_pad_stop_task),
|
||||
(gst_ghost_pad_get_type), (gst_ghost_pad_class_init),
|
||||
(gst_ghost_pad_init), (gst_ghost_pad_dispose),
|
||||
(gst_ghost_pad_set_property), (gst_ghost_pad_get_property),
|
||||
(gst_ghost_pad_new):
|
||||
* gst/gstpad.h:
|
||||
* gst/gstquery.c: (_gst_query_initialize), (gst_query_new),
|
||||
(gst_query_new_position), (gst_query_set_position),
|
||||
(gst_query_parse_position), (gst_query_new_convert),
|
||||
(gst_query_set_convert), (gst_query_parse_convert):
|
||||
* gst/gstquery.h:
|
||||
* gst/gstqueryutils.c:
|
||||
* gst/gstqueryutils.h:
|
||||
* gst/gstqueue.c: (gst_queue_init), (gst_queue_getcaps),
|
||||
(gst_queue_bufferalloc), (gst_queue_handle_sink_event),
|
||||
(gst_queue_handle_src_query):
|
||||
* gst/gstutils.c: (gst_element_get_compatible_pad_template),
|
||||
(gst_element_query_position), (gst_element_query_convert),
|
||||
(intersect_caps_func), (gst_pad_query_position),
|
||||
(gst_pad_query_convert):
|
||||
* gst/gstutils.h:
|
||||
* tools/gst-inspect.c: (print_pad_info):
|
||||
* tools/gst-xmlinspect.c: (print_element_info):
|
||||
Remove old query functions. Ported old code.
|
||||
Added position/convert helper functions to gstutils.
|
||||
Reordered gstpad.c code, grouping relevant things.
|
||||
Remove gst_message_new(), always need to speficy a specific
|
||||
message.
|
||||
|
||||
|
||||
2005-05-09 Andy Wingo <wingo@pobox.com>
|
||||
|
||||
* gst/gstiterator.h: Add some includes.
|
||||
|
|
|
@ -80,9 +80,31 @@ Proposition:
|
|||
decision.
|
||||
|
||||
|
||||
Things to query:
|
||||
|
||||
- pad can do real random access (downstream peer can ask for offset != -1)
|
||||
- min offset
|
||||
- suggest sequential access
|
||||
- max offset
|
||||
- align: all offsets should be aligned with this value.
|
||||
- pad can give ranges from A to B length (peer can ask for A <= length <= B)
|
||||
- min length
|
||||
- suggested length
|
||||
- max length
|
||||
|
||||
Use cases:
|
||||
|
||||
- An audio source can provide random access to the samples queued in its
|
||||
DMA buffer, it however suggests sequential access method.
|
||||
An audio source can provide a random number of samples but prefers
|
||||
reading from the hardware using a fixed segment size.
|
||||
|
||||
- A caching network source would suggest sequential access but is seekable
|
||||
in the cached region. Applications can query for the already downloaded
|
||||
portion and update the GUI, a seek can be done in that area.
|
||||
|
||||
- a live video source can only provide buffers sequentialy. It exposes
|
||||
offsets as -1. lengths are also -1.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -89,9 +89,11 @@ static void gst_basesrc_get_property (GObject * object, guint prop_id,
|
|||
GValue * value, GParamSpec * pspec);
|
||||
static gboolean gst_basesrc_event_handler (GstPad * pad, GstEvent * event);
|
||||
|
||||
static gboolean gst_basesrc_query2 (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_basesrc_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *gst_basesrc_get_event_mask (GstPad * pad);
|
||||
#endif
|
||||
|
||||
static gboolean gst_basesrc_unlock (GstBaseSrc * basesrc);
|
||||
static gboolean gst_basesrc_get_size (GstBaseSrc * basesrc, guint64 * size);
|
||||
|
@ -158,9 +160,7 @@ gst_basesrc_init (GstBaseSrc * basesrc, gpointer g_class)
|
|||
|
||||
gst_pad_set_activate_function (pad, gst_basesrc_activate);
|
||||
gst_pad_set_event_function (pad, gst_basesrc_event_handler);
|
||||
gst_pad_set_event_mask_function (pad, gst_basesrc_get_event_mask);
|
||||
|
||||
gst_pad_set_query2_function (pad, gst_basesrc_query2);
|
||||
gst_pad_set_query_function (pad, gst_basesrc_query);
|
||||
|
||||
gst_pad_set_checkgetrange_function (pad, gst_basesrc_check_get_range);
|
||||
|
||||
|
@ -193,7 +193,7 @@ gst_basesrc_set_dataflow_funcs (GstBaseSrc * this)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_basesrc_query2 (GstPad * pad, GstQuery * query)
|
||||
gst_basesrc_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean b;
|
||||
guint64 ui64;
|
||||
|
@ -207,7 +207,7 @@ gst_basesrc_query2 (GstPad * pad, GstQuery * query)
|
|||
{
|
||||
GstFormat format;
|
||||
|
||||
gst_query_parse_position_query (query, &format);
|
||||
gst_query_parse_position (query, &format, NULL, NULL);
|
||||
switch (format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
case GST_FORMAT_BYTES:
|
||||
|
@ -243,10 +243,11 @@ gst_basesrc_query2 (GstPad * pad, GstQuery * query)
|
|||
case GST_QUERY_RATE:
|
||||
case GST_QUERY_CONVERT:
|
||||
default:
|
||||
return gst_pad_query2_default (pad, query);
|
||||
return gst_pad_query_default (pad, query);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *
|
||||
gst_basesrc_get_event_mask (GstPad * pad)
|
||||
{
|
||||
|
@ -260,6 +261,7 @@ gst_basesrc_get_event_mask (GstPad * pad)
|
|||
};
|
||||
return masks;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_basesrc_do_seek (GstBaseSrc * src, GstEvent * event)
|
||||
|
|
|
@ -80,7 +80,7 @@ static gboolean gst_filesink_event (GstBaseSink * sink, GstEvent * event);
|
|||
static GstFlowReturn gst_filesink_render (GstBaseSink * sink,
|
||||
GstBuffer * buffer);
|
||||
|
||||
static gboolean gst_filesink_query2 (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_filesink_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
static void gst_filesink_uri_handler_init (gpointer g_iface,
|
||||
gpointer iface_data);
|
||||
|
@ -144,7 +144,7 @@ gst_filesink_init (GstFileSink * filesink)
|
|||
|
||||
pad = GST_BASESINK_PAD (filesink);
|
||||
|
||||
gst_pad_set_query2_function (pad, gst_filesink_query2);
|
||||
gst_pad_set_query_function (pad, gst_filesink_query);
|
||||
|
||||
filesink->filename = NULL;
|
||||
filesink->file = NULL;
|
||||
|
@ -255,7 +255,7 @@ gst_filesink_close_file (GstFileSink * sink)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_filesink_query2 (GstPad * pad, GstQuery * query)
|
||||
gst_filesink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstFileSink *self;
|
||||
GstFormat format;
|
||||
|
@ -264,7 +264,7 @@ gst_filesink_query2 (GstPad * pad, GstQuery * query)
|
|||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
gst_query_parse_position_query (query, &format);
|
||||
gst_query_parse_position (query, &format, NULL, NULL);
|
||||
switch (format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
case GST_FORMAT_BYTES:
|
||||
|
@ -280,7 +280,7 @@ gst_filesink_query2 (GstPad * pad, GstQuery * query)
|
|||
return TRUE;
|
||||
|
||||
default:
|
||||
return gst_pad_query2_default (pad, query);
|
||||
return gst_pad_query_default (pad, query);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,11 +115,13 @@ static void gst_type_find_element_set_property (GObject * object,
|
|||
static void gst_type_find_element_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad);
|
||||
#endif
|
||||
|
||||
static gboolean gst_type_find_element_src_event (GstPad * pad,
|
||||
GstEvent * event);
|
||||
static gboolean gst_type_find_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value);
|
||||
static gboolean gst_type_find_handle_src_query (GstPad * pad, GstQuery * query);
|
||||
static GstFlowReturn push_buffer_store (GstTypeFindElement * typefind);
|
||||
|
||||
static gboolean gst_type_find_element_handle_event (GstPad * pad,
|
||||
|
@ -219,8 +221,6 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
|
|||
gst_type_find_element_checkgetrange);
|
||||
gst_pad_set_getrange_function (typefind->src, gst_type_find_element_getrange);
|
||||
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
|
||||
gst_pad_set_event_mask_function (typefind->src,
|
||||
gst_type_find_element_src_event_mask);
|
||||
gst_pad_set_query_function (typefind->src,
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_handle_src_query));
|
||||
gst_pad_use_fixed_caps (typefind->src);
|
||||
|
@ -295,32 +295,48 @@ gst_type_find_element_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_type_find_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value)
|
||||
gst_type_find_handle_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstTypeFindElement *typefind =
|
||||
GST_TYPE_FIND_ELEMENT (gst_pad_get_parent (pad));
|
||||
GstTypeFindElement *typefind;
|
||||
gboolean res;
|
||||
|
||||
res = gst_pad_query (GST_PAD_PEER (typefind->sink), type, fmt, value);
|
||||
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
|
||||
|
||||
res = gst_pad_query (GST_PAD_PEER (typefind->sink), query);
|
||||
if (!res)
|
||||
return FALSE;
|
||||
|
||||
if (type == GST_QUERY_POSITION && typefind->store != NULL) {
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (*fmt) {
|
||||
case GST_FORMAT_BYTES:
|
||||
*value -= gst_buffer_store_get_size (typefind->store, 0);
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
gint64 peer_pos, peer_total;
|
||||
GstFormat format;
|
||||
|
||||
if (typefind->store == NULL)
|
||||
return TRUE;
|
||||
|
||||
gst_query_parse_position (query, &format, &peer_pos, &peer_total);
|
||||
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= gst_buffer_store_get_size (typefind->store, 0);
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
}
|
||||
gst_query_set_position (query, format, peer_pos, peer_total);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *
|
||||
gst_type_find_element_src_event_mask (GstPad * pad)
|
||||
{
|
||||
|
@ -334,6 +350,7 @@ gst_type_find_element_src_event_mask (GstPad * pad)
|
|||
|
||||
return mask;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_type_find_element_src_event (GstPad * pad, GstEvent * event)
|
||||
|
@ -462,24 +479,29 @@ find_element_get_length (gpointer data)
|
|||
return 0;
|
||||
}
|
||||
if (entry->self->stream_length == 0) {
|
||||
typefind->stream_length_available =
|
||||
gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
|
||||
&format, (gint64 *) & entry->self->stream_length);
|
||||
if (format != GST_FORMAT_BYTES)
|
||||
if (!gst_pad_query_position (GST_PAD_PEER (entry->self->sink), &format,
|
||||
NULL, (gint64 *) & entry->self->stream_length))
|
||||
goto no_length;
|
||||
|
||||
if (format != GST_FORMAT_BYTES) {
|
||||
typefind->stream_length_available = FALSE;
|
||||
if (!typefind->stream_length_available) {
|
||||
GST_DEBUG_OBJECT (entry->self,
|
||||
"'%s' called get_length () but it's not available",
|
||||
GST_PLUGIN_FEATURE_NAME (entry->factory));
|
||||
return 0;
|
||||
entry->self->stream_length = 0;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (entry->self,
|
||||
"'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes",
|
||||
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
|
||||
}
|
||||
}
|
||||
|
||||
return entry->self->stream_length;
|
||||
|
||||
no_length:
|
||||
{
|
||||
typefind->stream_length_available = FALSE;
|
||||
GST_DEBUG_OBJECT (entry->self,
|
||||
"'%s' called get_length () but it's not available",
|
||||
GST_PLUGIN_FEATURE_NAME (entry->factory));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
157
gst/gstelement.c
157
gst/gstelement.c
|
@ -1049,48 +1049,6 @@ wrong_direction:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_element_get_event_masks:
|
||||
* @element: a #GstElement to query
|
||||
*
|
||||
* Get an array of event masks from the element.
|
||||
* If the element doesn't implement an event masks function,
|
||||
* the query will be forwarded to a random linked sink pad.
|
||||
*
|
||||
* Returns: An array of #GstEventMask elements. The array
|
||||
* cannot be modified or freed.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
const GstEventMask *
|
||||
gst_element_get_event_masks (GstElement * element)
|
||||
{
|
||||
GstElementClass *oclass;
|
||||
const GstEventMask *result = NULL;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
||||
|
||||
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||
|
||||
if (oclass->get_event_masks) {
|
||||
result = oclass->get_event_masks (element);
|
||||
} else {
|
||||
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
|
||||
|
||||
if (pad) {
|
||||
GstPad *peer = gst_pad_get_peer (pad);
|
||||
|
||||
if (peer) {
|
||||
result = gst_pad_get_event_masks (peer);
|
||||
gst_object_unref (GST_OBJECT (peer));
|
||||
}
|
||||
gst_object_unref (GST_OBJECT (pad));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_element_send_event:
|
||||
* @element: a #GstElement to send the event to.
|
||||
|
@ -1156,9 +1114,12 @@ gst_element_send_event (GstElement * element, GstEvent * event)
|
|||
gboolean
|
||||
gst_element_seek (GstElement * element, GstSeekType seek_type, guint64 offset)
|
||||
{
|
||||
GstEvent *event = gst_event_new_seek (seek_type, offset);
|
||||
GstEvent *event;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
event = gst_event_new_seek (seek_type, offset);
|
||||
result = gst_element_send_event (element, event);
|
||||
|
||||
return result;
|
||||
|
@ -1224,25 +1185,23 @@ gst_element_get_query_types (GstElement * element)
|
|||
* MT safe.
|
||||
*/
|
||||
gboolean
|
||||
gst_element_query (GstElement * element, GstQueryType type,
|
||||
GstFormat * format, gint64 * value)
|
||||
gst_element_query (GstElement * element, GstQuery * query)
|
||||
{
|
||||
GstElementClass *oclass;
|
||||
gboolean result = FALSE;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
g_return_val_if_fail (format != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
g_return_val_if_fail (query != NULL, FALSE);
|
||||
|
||||
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||
|
||||
if (oclass->query) {
|
||||
result = oclass->query (element, type, format, value);
|
||||
result = oclass->query (element, query);
|
||||
} else {
|
||||
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SRC);
|
||||
|
||||
if (pad) {
|
||||
result = gst_pad_query (pad, type, format, value);
|
||||
result = gst_pad_query (pad, query);
|
||||
|
||||
gst_object_unref (GST_OBJECT (pad));
|
||||
} else {
|
||||
|
@ -1251,7 +1210,7 @@ gst_element_query (GstElement * element, GstQueryType type,
|
|||
GstPad *peer = gst_pad_get_peer (pad);
|
||||
|
||||
if (peer) {
|
||||
result = gst_pad_query (peer, type, format, value);
|
||||
result = gst_pad_query (peer, query);
|
||||
|
||||
gst_object_unref (GST_OBJECT (peer));
|
||||
}
|
||||
|
@ -1262,104 +1221,6 @@ gst_element_query (GstElement * element, GstQueryType type,
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_element_get_formats:
|
||||
* @element: a #GstElement to query
|
||||
*
|
||||
* Get an array of formats from the element.
|
||||
* If the element doesn't implement a formats function,
|
||||
* the query will be forwarded to a random sink pad.
|
||||
*
|
||||
* Returns: An array of #GstFormat elements.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
const GstFormat *
|
||||
gst_element_get_formats (GstElement * element)
|
||||
{
|
||||
GstElementClass *oclass;
|
||||
const GstFormat *result = NULL;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
|
||||
|
||||
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||
|
||||
if (oclass->get_formats) {
|
||||
result = oclass->get_formats (element);
|
||||
} else {
|
||||
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
|
||||
|
||||
if (pad) {
|
||||
GstPad *peer = gst_pad_get_peer (pad);
|
||||
|
||||
if (peer) {
|
||||
result = gst_pad_get_formats (peer);
|
||||
|
||||
gst_object_unref (GST_OBJECT (peer));
|
||||
}
|
||||
gst_object_unref (GST_OBJECT (pad));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_element_convert:
|
||||
* @element: a #GstElement to invoke the converter on.
|
||||
* @src_format: the source #GstFormat.
|
||||
* @src_value: the source value.
|
||||
* @dest_format: a pointer to the destination #GstFormat.
|
||||
* @dest_value: a pointer to the destination value.
|
||||
*
|
||||
* Invokes a conversion on the element.
|
||||
* If the element doesn't implement a convert function,
|
||||
* the query will be forwarded to a random sink pad.
|
||||
*
|
||||
* Returns: TRUE if the conversion could be performed.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
gboolean
|
||||
gst_element_convert (GstElement * element,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
GstElementClass *oclass;
|
||||
gboolean result = FALSE;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
g_return_val_if_fail (dest_format != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_value != NULL, FALSE);
|
||||
|
||||
if (src_format == *dest_format) {
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||
|
||||
if (oclass->convert) {
|
||||
result = oclass->convert (element,
|
||||
src_format, src_value, dest_format, dest_value);
|
||||
} else {
|
||||
GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK);
|
||||
|
||||
if (pad) {
|
||||
GstPad *peer = gst_pad_get_peer (pad);
|
||||
|
||||
if (peer) {
|
||||
result = gst_pad_convert (peer,
|
||||
src_format, src_value, dest_format, dest_value);
|
||||
|
||||
gst_object_unref (GST_OBJECT (peer));
|
||||
}
|
||||
gst_object_unref (GST_OBJECT (pad));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_element_post_message:
|
||||
* @element: a #GstElement posting the message
|
||||
|
|
|
@ -249,13 +249,13 @@ struct _GstElementClass
|
|||
void (*release_pad) (GstElement *element, GstPad *pad);
|
||||
|
||||
/* state changes */
|
||||
GstElementStateReturn (*get_state) (GstElement * element, GstElementState * state,
|
||||
GstElementState * pending, GTimeVal * timeout);
|
||||
GstElementStateReturn (*get_state) (GstElement * element, GstElementState * state,
|
||||
GstElementState * pending, GTimeVal * timeout);
|
||||
GstElementStateReturn (*change_state) (GstElement *element);
|
||||
|
||||
/* manager */
|
||||
void (*set_manager) (GstElement * element, GstPipeline * pipeline);
|
||||
void (*set_bus) (GstElement * element, GstBus * bus);
|
||||
void (*set_manager) (GstElement * element, GstPipeline * pipeline);
|
||||
void (*set_bus) (GstElement * element, GstBus * bus);
|
||||
void (*set_scheduler) (GstElement *element, GstScheduler *scheduler);
|
||||
|
||||
/* set/get clocks */
|
||||
|
@ -266,16 +266,11 @@ struct _GstElementClass
|
|||
GstIndex* (*get_index) (GstElement *element);
|
||||
void (*set_index) (GstElement *element, GstIndex *index);
|
||||
|
||||
/* query/convert/events functions */
|
||||
const GstEventMask* (*get_event_masks) (GstElement *element);
|
||||
/* query functions */
|
||||
gboolean (*send_event) (GstElement *element, GstEvent *event);
|
||||
const GstFormat* (*get_formats) (GstElement *element);
|
||||
gboolean (*convert) (GstElement *element,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat *dest_format, gint64 *dest_value);
|
||||
|
||||
const GstQueryType* (*get_query_types) (GstElement *element);
|
||||
gboolean (*query) (GstElement *element, GstQueryType type,
|
||||
GstFormat *format, gint64 *value);
|
||||
gboolean (*query) (GstElement *element, GstQuery *query);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
|
@ -309,10 +304,10 @@ void gst_element_set_index (GstElement *element, GstIndex *index);
|
|||
GstIndex* gst_element_get_index (GstElement *element);
|
||||
|
||||
/* manager and tasks */
|
||||
void gst_element_set_manager (GstElement * element, GstPipeline * pipeline);
|
||||
GstPipeline *gst_element_get_manager (GstElement * element);
|
||||
void gst_element_set_bus (GstElement * element, GstBus * bus);
|
||||
GstBus *gst_element_get_bus (GstElement * element);
|
||||
void gst_element_set_manager (GstElement * element, GstPipeline * pipeline);
|
||||
GstPipeline * gst_element_get_manager (GstElement * element);
|
||||
void gst_element_set_bus (GstElement * element, GstBus * bus);
|
||||
GstBus * gst_element_get_bus (GstElement * element);
|
||||
void gst_element_set_scheduler (GstElement *element, GstScheduler *sched);
|
||||
GstScheduler* gst_element_get_scheduler (GstElement *element);
|
||||
|
||||
|
@ -330,44 +325,37 @@ void gst_element_release_request_pad (GstElement *element, GstPad *pad);
|
|||
GstIterator * gst_element_iterate_pads (GstElement * element);
|
||||
|
||||
/* event/query/format stuff */
|
||||
G_CONST_RETURN GstEventMask*
|
||||
gst_element_get_event_masks (GstElement *element);
|
||||
gboolean gst_element_send_event (GstElement *element, GstEvent *event);
|
||||
gboolean gst_element_seek (GstElement *element, GstSeekType seek_type,
|
||||
guint64 offset);
|
||||
G_CONST_RETURN GstQueryType*
|
||||
gst_element_get_query_types (GstElement *element);
|
||||
gboolean gst_element_query (GstElement *element, GstQueryType type,
|
||||
GstFormat *format, gint64 *value);
|
||||
G_CONST_RETURN GstFormat*
|
||||
gst_element_get_formats (GstElement *element);
|
||||
gboolean gst_element_convert (GstElement *element,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat *dest_format, gint64 *dest_value);
|
||||
gboolean gst_element_query (GstElement *element, GstQuery *query);
|
||||
|
||||
/* messages */
|
||||
gboolean gst_element_post_message (GstElement * element, GstMessage * message);
|
||||
gboolean gst_element_post_message (GstElement * element, GstMessage * message);
|
||||
|
||||
/* error handling */
|
||||
gchar * _gst_element_error_printf (const gchar *format, ...);
|
||||
void gst_element_message_full (GstElement * element, GstMessageType type,
|
||||
GQuark domain, gint code, gchar * text, gchar * debug, const gchar * file,
|
||||
const gchar * function, gint line);
|
||||
void gst_element_message_full (GstElement * element, GstMessageType type,
|
||||
GQuark domain, gint code, gchar * text,
|
||||
gchar * debug, const gchar * file,
|
||||
const gchar * function, gint line);
|
||||
|
||||
/* state management */
|
||||
gboolean gst_element_is_locked_state (GstElement *element);
|
||||
gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
|
||||
gboolean gst_element_sync_state_with_parent (GstElement *element);
|
||||
|
||||
GstElementStateReturn gst_element_get_state (GstElement * element,
|
||||
GstElementState * state,
|
||||
GstElementState * pending,
|
||||
GTimeVal * timeout);
|
||||
GstElementStateReturn gst_element_get_state (GstElement * element,
|
||||
GstElementState * state,
|
||||
GstElementState * pending,
|
||||
GTimeVal * timeout);
|
||||
GstElementStateReturn gst_element_set_state (GstElement *element, GstElementState state);
|
||||
|
||||
void gst_element_abort_state (GstElement * element);
|
||||
void gst_element_commit_state (GstElement * element);
|
||||
void gst_element_lost_state (GstElement * element);
|
||||
void gst_element_abort_state (GstElement * element);
|
||||
void gst_element_commit_state (GstElement * element);
|
||||
void gst_element_lost_state (GstElement * element);
|
||||
|
||||
/* factory management */
|
||||
GstElementFactory* gst_element_get_factory (GstElement *element);
|
||||
|
|
|
@ -128,7 +128,7 @@ gst_message_get_type (void)
|
|||
*
|
||||
* MT safe.
|
||||
*/
|
||||
GstMessage *
|
||||
static GstMessage *
|
||||
gst_message_new (GstMessageType type, GstObject * src)
|
||||
{
|
||||
GstMessage *message;
|
||||
|
|
|
@ -111,7 +111,6 @@ struct _GstMessage
|
|||
void _gst_message_initialize (void);
|
||||
|
||||
GType gst_message_get_type (void);
|
||||
GstMessage * gst_message_new (GstMessageType type, GstObject * src);
|
||||
|
||||
/* refcounting */
|
||||
#define gst_message_ref(msg) GST_MESSAGE (gst_data_ref (GST_DATA (msg)))
|
||||
|
|
1122
gst/gstpad.c
1122
gst/gstpad.c
File diff suppressed because it is too large
Load diff
88
gst/gstpad.h
88
gst/gstpad.h
|
@ -135,26 +135,21 @@ typedef enum {
|
|||
typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstActivateMode mode);
|
||||
|
||||
/* data passing */
|
||||
typedef void (*GstPadLoopFunction) (GstPad *pad);
|
||||
typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstBuffer *buffer);
|
||||
typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset,
|
||||
guint length, GstBuffer **buffer);
|
||||
typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad);
|
||||
typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event);
|
||||
|
||||
/* old, deprecated convert/query/format functions */
|
||||
typedef gboolean (*GstPadConvertFunction) (GstPad *pad,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat *dest_format, gint64 *dest_value);
|
||||
typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQueryType type,
|
||||
GstFormat *format, gint64 *value);
|
||||
/* deprecate me, check range should use seeking query, loop function is internal */
|
||||
typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad);
|
||||
typedef void (*GstPadLoopFunction) (GstPad *pad);
|
||||
|
||||
/* internal links */
|
||||
typedef GList* (*GstPadIntLinkFunction) (GstPad *pad);
|
||||
typedef const GstFormat* (*GstPadFormatsFunction) (GstPad *pad);
|
||||
typedef const GstEventMask* (*GstPadEventMaskFunction) (GstPad *pad);
|
||||
typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
|
||||
|
||||
/* generic query function */
|
||||
typedef gboolean (*GstPadQuery2Function) (GstPad *pad, GstQuery *query);
|
||||
typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
|
||||
typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQuery *query);
|
||||
|
||||
/* linking */
|
||||
typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
|
||||
|
@ -247,29 +242,23 @@ struct _GstRealPad {
|
|||
GstPadGetRangeFunction getrangefunc;
|
||||
GstPadEventFunction eventfunc;
|
||||
|
||||
GstPadEventMaskFunction eventmaskfunc;
|
||||
|
||||
/* ghostpads */
|
||||
GList *ghostpads;
|
||||
guint32 ghostpads_cookie;
|
||||
|
||||
/* old, deprecated query/convert/formats functions */
|
||||
GstPadConvertFunction convertfunc;
|
||||
GstPadQueryFunction queryfunc;
|
||||
GstPadFormatsFunction formatsfunc;
|
||||
/* generic query method */
|
||||
GstPadQueryTypeFunction querytypefunc;
|
||||
GstPadQueryFunction queryfunc;
|
||||
|
||||
/* internal links */
|
||||
GstPadIntLinkFunction intlinkfunc;
|
||||
|
||||
GstPadBufferAllocFunction bufferallocfunc;
|
||||
|
||||
GstProbeDispatcher probedisp;
|
||||
|
||||
/* generic query method */
|
||||
GstPadQuery2Function query2func;
|
||||
|
||||
/*< private >*/
|
||||
/* fixme: bring back to gst_padding when old query functions go away */
|
||||
gpointer _gst_reserved[GST_PADDING - 1];
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstRealPadClass {
|
||||
|
@ -315,13 +304,9 @@ struct _GstGhostPadClass {
|
|||
#define GST_RPAD_CHECKGETRANGEFUNC(pad) (GST_REAL_PAD_CAST(pad)->checkgetrangefunc)
|
||||
#define GST_RPAD_GETRANGEFUNC(pad) (GST_REAL_PAD_CAST(pad)->getrangefunc)
|
||||
#define GST_RPAD_EVENTFUNC(pad) (GST_REAL_PAD_CAST(pad)->eventfunc)
|
||||
#define GST_RPAD_CONVERTFUNC(pad) (GST_REAL_PAD_CAST(pad)->convertfunc)
|
||||
#define GST_RPAD_QUERYTYPEFUNC(pad) (GST_REAL_PAD_CAST(pad)->querytypefunc)
|
||||
#define GST_RPAD_QUERYFUNC(pad) (GST_REAL_PAD_CAST(pad)->queryfunc)
|
||||
#define GST_RPAD_INTLINKFUNC(pad) (GST_REAL_PAD_CAST(pad)->intlinkfunc)
|
||||
#define GST_RPAD_FORMATSFUNC(pad) (GST_REAL_PAD_CAST(pad)->formatsfunc)
|
||||
#define GST_RPAD_QUERYTYPEFUNC(pad) (GST_REAL_PAD_CAST(pad)->querytypefunc)
|
||||
#define GST_RPAD_EVENTMASKFUNC(pad) (GST_REAL_PAD_CAST(pad)->eventmaskfunc)
|
||||
#define GST_RPAD_QUERY2FUNC(pad) (GST_REAL_PAD_CAST(pad)->query2func)
|
||||
|
||||
#define GST_RPAD_PEER(pad) (GST_REAL_PAD_CAST(pad)->peer)
|
||||
#define GST_RPAD_LINKFUNC(pad) (GST_REAL_PAD_CAST(pad)->linkfunc)
|
||||
|
@ -379,11 +364,10 @@ struct _GstGhostPadClass {
|
|||
#define GST_PAD_IS_LINKED(pad) (GST_RPAD_IS_LINKED(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_ACTIVE(pad) (GST_RPAD_IS_ACTIVE(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_BLOCKED(pad) (GST_RPAD_IS_BLOCKED(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_NEGOTIATING(pad) (GST_RPAD_IS_NEGOTIATING(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_FLUSHING(pad) (GST_RPAD_IS_FLUSHING(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_IN_GETCAPS(pad) (GST_RPAD_IS_IN_GETCAPS(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_IN_SETCAPS(pad) (GST_RPAD_IS_IN_SETCAPS(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_USABLE(pad) (GST_RPAD_IS_USABLE(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_CAN_PULL(pad) (GST_RPAD_CAN_PULL(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_SRC(pad) (GST_RPAD_IS_SRC(GST_PAD_REALIZE(pad)))
|
||||
#define GST_PAD_IS_SINK(pad) (GST_RPAD_IS_SINK(GST_PAD_REALIZE(pad)))
|
||||
|
||||
|
@ -492,11 +476,6 @@ void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
|
|||
void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get);
|
||||
void gst_pad_set_checkgetrange_function (GstPad *pad, GstPadCheckGetRangeFunction check);
|
||||
void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
|
||||
void gst_pad_set_event_mask_function (GstPad *pad, GstPadEventMaskFunction mask_func);
|
||||
G_CONST_RETURN GstEventMask*
|
||||
gst_pad_get_event_masks (GstPad *pad);
|
||||
G_CONST_RETURN GstEventMask*
|
||||
gst_pad_get_event_masks_default (GstPad *pad);
|
||||
|
||||
/* pad links */
|
||||
void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
|
||||
|
@ -544,44 +523,21 @@ gboolean gst_pad_start_task (GstPad *pad);
|
|||
gboolean gst_pad_pause_task (GstPad *pad);
|
||||
gboolean gst_pad_stop_task (GstPad *pad);
|
||||
|
||||
/* convert/query/format functions */
|
||||
void gst_pad_set_formats_function (GstPad *pad,
|
||||
GstPadFormatsFunction formats);
|
||||
G_CONST_RETURN GstFormat*
|
||||
gst_pad_get_formats (GstPad *pad);
|
||||
G_CONST_RETURN GstFormat*
|
||||
gst_pad_get_formats_default (GstPad *pad);
|
||||
/* internal links */
|
||||
void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink);
|
||||
GList* gst_pad_get_internal_links (GstPad *pad);
|
||||
GList* gst_pad_get_internal_links_default (GstPad *pad);
|
||||
|
||||
void gst_pad_set_convert_function (GstPad *pad, GstPadConvertFunction convert);
|
||||
gboolean gst_pad_convert (GstPad *pad,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat *dest_format, gint64 *dest_value);
|
||||
gboolean gst_pad_convert_default (GstPad *pad,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat *dest_format, gint64 *dest_value);
|
||||
|
||||
void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
|
||||
/* generic query function */
|
||||
void gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func);
|
||||
G_CONST_RETURN GstQueryType*
|
||||
gst_pad_get_query_types (GstPad *pad);
|
||||
G_CONST_RETURN GstQueryType*
|
||||
gst_pad_get_query_types_default (GstPad *pad);
|
||||
gboolean gst_pad_query (GstPad *pad, GstQueryType type,
|
||||
GstFormat *format, gint64 *value);
|
||||
gboolean gst_pad_query_default (GstPad *pad, GstQueryType type,
|
||||
GstFormat *format, gint64 *value);
|
||||
|
||||
void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink);
|
||||
GList* gst_pad_get_internal_links (GstPad *pad);
|
||||
GList* gst_pad_get_internal_links_default (GstPad *pad);
|
||||
|
||||
gboolean gst_pad_query2 (GstPad *pad, GstQuery *query);
|
||||
void gst_pad_set_query2_function (GstPad *pad, GstPadQuery2Function query);
|
||||
gboolean gst_pad_query2_default (GstPad *pad, GstQuery *query);
|
||||
|
||||
/* util query functions */
|
||||
gboolean gst_pad_query_position (GstPad *pad, GstFormat *format,
|
||||
gint64 *cur, gint64 *end);
|
||||
gboolean gst_pad_query (GstPad *pad, GstQuery *query);
|
||||
void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
|
||||
gboolean gst_pad_query_default (GstPad *pad, GstQuery *query);
|
||||
|
||||
/* misc helper functions */
|
||||
gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch,
|
||||
|
|
110
gst/gstquery.c
110
gst/gstquery.c
|
@ -26,12 +26,14 @@
|
|||
#include "gst_private.h"
|
||||
#include "gstquery.h"
|
||||
#include "gstmemchunk.h"
|
||||
#include "gstenumtypes.h"
|
||||
#include "gstdata_private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
|
||||
#define GST_CAT_DEFAULT gst_query_debug
|
||||
|
||||
GType _gst_query_type;
|
||||
|
||||
|
||||
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||
static GList *_gst_queries = NULL;
|
||||
static GHashTable *_nick_to_query = NULL;
|
||||
|
@ -61,6 +63,8 @@ _gst_query_initialize (void)
|
|||
|
||||
GST_CAT_INFO (GST_CAT_GST_INIT, "init queries");
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_query_debug, "query", 0, "query system");
|
||||
|
||||
g_static_mutex_lock (&mutex);
|
||||
if (_nick_to_query == NULL) {
|
||||
_nick_to_query = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
@ -279,11 +283,115 @@ gst_query_new (GstQueryType type, GstStructure * structure)
|
|||
query->structure = structure;
|
||||
gst_structure_set_parent_refcount (query->structure,
|
||||
&GST_DATA_REFCOUNT (query));
|
||||
} else {
|
||||
query->structure = NULL;
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
GstQuery *
|
||||
gst_query_new_position (GstFormat format)
|
||||
{
|
||||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_new ("GstQueryPosition",
|
||||
"format", GST_TYPE_FORMAT, format,
|
||||
"cur", G_TYPE_INT64, (gint64) - 1,
|
||||
"end", G_TYPE_INT64, (gint64) - 1, NULL);
|
||||
query = gst_query_new (GST_QUERY_POSITION, structure);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_set_position (GstQuery * query, GstFormat format,
|
||||
gint64 cur, gint64 end)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
gst_structure_set (structure,
|
||||
"format", GST_TYPE_FORMAT, format,
|
||||
"cur", G_TYPE_INT64, cur, "end", G_TYPE_INT64, end, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_parse_position (GstQuery * query, GstFormat * format,
|
||||
gint64 * cur, gint64 * end)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
if (format)
|
||||
*format = g_value_get_enum (gst_structure_get_value (structure, "format"));
|
||||
if (cur)
|
||||
*cur = g_value_get_int64 (gst_structure_get_value (structure, "cur"));
|
||||
if (end)
|
||||
*end = g_value_get_int64 (gst_structure_get_value (structure, "end"));
|
||||
}
|
||||
|
||||
GstQuery *
|
||||
gst_query_new_convert (GstFormat src_fmt, gint64 value, GstFormat dest_fmt)
|
||||
{
|
||||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_new ("GstQueryConvert",
|
||||
"src_format", GST_TYPE_FORMAT, src_fmt,
|
||||
"src_value", G_TYPE_INT64, value,
|
||||
"dest_format", GST_TYPE_FORMAT, dest_fmt,
|
||||
"dest_value", G_TYPE_INT64, (gint64) - 1, NULL);
|
||||
query = gst_query_new (GST_QUERY_CONVERT, structure);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_set_convert (GstQuery * query, GstFormat src_format, gint64 src_value,
|
||||
GstFormat dest_format, gint64 dest_value)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
gst_structure_set (structure,
|
||||
"src_format", GST_TYPE_FORMAT, src_format,
|
||||
"src_value", G_TYPE_INT64, src_value,
|
||||
"dest_format", GST_TYPE_FORMAT, dest_format,
|
||||
"dest_value", G_TYPE_INT64, dest_value, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_parse_convert (GstQuery * query, GstFormat * src_format,
|
||||
gint64 * src_value, GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CONVERT);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
if (src_format)
|
||||
*src_format =
|
||||
g_value_get_enum (gst_structure_get_value (structure, "src_format"));
|
||||
if (src_value)
|
||||
*src_value =
|
||||
g_value_get_int64 (gst_structure_get_value (structure, "src_value"));
|
||||
if (dest_format)
|
||||
*dest_format =
|
||||
g_value_get_enum (gst_structure_get_value (structure, "dest_format"));
|
||||
if (dest_value)
|
||||
*dest_value =
|
||||
g_value_get_int64 (gst_structure_get_value (structure, "dest_value"));
|
||||
}
|
||||
|
||||
|
||||
GstQuery *
|
||||
gst_query_new_application (GstQueryType type, GstStructure * structure)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <gst/gstiterator.h>
|
||||
#include <gst/gstdata.h>
|
||||
#include <gst/gststructure.h>
|
||||
#include <gst/gstformat.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -129,9 +130,24 @@ GstIterator* gst_query_type_iterate_definitions (void);
|
|||
#define gst_query_copy(msg) GST_QUERY (gst_data_copy (GST_DATA (msg)))
|
||||
#define gst_query_copy_on_write(msg) GST_QUERY (gst_data_copy_on_write (GST_DATA (msg)))
|
||||
|
||||
/* position query */
|
||||
GstQuery* gst_query_new_position (GstFormat format);
|
||||
void gst_query_set_position (GstQuery *query, GstFormat format,
|
||||
gint64 cur, gint64 end);
|
||||
void gst_query_parse_position (GstQuery *query, GstFormat *format,
|
||||
gint64 *cur, gint64 *end);
|
||||
/* convert query */
|
||||
GstQuery* gst_query_new_convert (GstFormat src_fmt, gint64 value, GstFormat dest_fmt);
|
||||
void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value,
|
||||
GstFormat dest_format, gint64 dest_value);
|
||||
void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value,
|
||||
GstFormat *dest_format, gint64 *dest_value);
|
||||
|
||||
/* application specific query */
|
||||
GstQuery * gst_query_new_application (GstQueryType type,
|
||||
GstStructure *structure);
|
||||
|
||||
|
||||
GstStructure * gst_query_get_structure (GstQuery *query);
|
||||
|
||||
/* hmm */
|
||||
|
|
|
@ -29,59 +29,6 @@
|
|||
|
||||
/* some macros are just waiting to be defined here */
|
||||
|
||||
|
||||
GstQuery *
|
||||
gst_query_new_position (GstFormat format)
|
||||
{
|
||||
GstStructure *structure = gst_structure_new ("query",
|
||||
"format", GST_TYPE_FORMAT, format, NULL);
|
||||
|
||||
return gst_query_new_application (GST_QUERY_POSITION, structure);
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_set_position (GstQuery * query, GstFormat format, gint64 cur,
|
||||
gint64 end)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
gst_structure_set (structure,
|
||||
"format", GST_TYPE_FORMAT, format,
|
||||
"cur", G_TYPE_INT64, cur, "end", G_TYPE_INT64, end, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_parse_position_query (GstQuery * query, GstFormat * format)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
if (format)
|
||||
*format = g_value_get_enum (gst_structure_get_value (structure, "format"));
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_parse_position_response (GstQuery * query, GstFormat * format,
|
||||
gint64 * cur, gint64 * end)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);
|
||||
|
||||
structure = gst_query_get_structure (query);
|
||||
if (format)
|
||||
*format = g_value_get_enum (gst_structure_get_value (structure, "format"));
|
||||
if (cur)
|
||||
*cur = g_value_get_int64 (gst_structure_get_value (structure, "cur"));
|
||||
if (end)
|
||||
*end = g_value_get_int64 (gst_structure_get_value (structure, "end"));
|
||||
}
|
||||
|
||||
void
|
||||
gst_query_parse_seeking_query (GstQuery * query, GstFormat * format)
|
||||
{
|
||||
|
|
|
@ -26,12 +26,6 @@
|
|||
#include <gst/gstquery.h>
|
||||
|
||||
|
||||
GstQuery* gst_query_new_position (GstFormat format);
|
||||
void gst_query_set_position (GstQuery *query, GstFormat format,
|
||||
gint64 cur, gint64 end);
|
||||
void gst_query_parse_position_query (GstQuery *query, GstFormat *format);
|
||||
void gst_query_parse_position_response (GstQuery *query, GstFormat *format,
|
||||
gint64 *cur, gint64 *end);
|
||||
void gst_query_parse_seeking_query (GstQuery *query, GstFormat *format);
|
||||
void gst_query_set_seeking (GstQuery *query, GstFormat format,
|
||||
gboolean seekable, gint64 segment_start,
|
||||
|
|
|
@ -133,8 +133,7 @@ static void gst_queue_loop (GstPad * pad);
|
|||
static gboolean gst_queue_handle_sink_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_queue_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value);
|
||||
static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
static GstCaps *gst_queue_getcaps (GstPad * pad);
|
||||
static GstPadLinkReturn gst_queue_link_sink (GstPad * pad, GstPad * peer);
|
||||
|
@ -811,29 +810,42 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_queue_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value)
|
||||
gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstQueue *queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
||||
|
||||
if (!GST_PAD_PEER (queue->sinkpad))
|
||||
return FALSE;
|
||||
if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), type, fmt, value))
|
||||
if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), query))
|
||||
return FALSE;
|
||||
|
||||
if (type == GST_QUERY_POSITION) {
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (*fmt) {
|
||||
case GST_FORMAT_BYTES:
|
||||
*value -= queue->cur_level.bytes;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
*value -= queue->cur_level.time;
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
gint64 peer_pos, peer_total;
|
||||
GstFormat format;
|
||||
|
||||
/* get peer position */
|
||||
gst_query_parse_position (query, &format, &peer_pos, &peer_total);
|
||||
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= queue->cur_level.bytes;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
peer_pos -= queue->cur_level.time;
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
}
|
||||
/* set updated positions */
|
||||
gst_query_set_position (query, format, peer_pos, peer_total);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
120
gst/gstutils.c
120
gst/gstutils.c
|
@ -1155,6 +1155,55 @@ gst_element_unlink (GstElement * src, GstElement * dest)
|
|||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_element_query_position (GstElement * element, GstFormat * format,
|
||||
gint64 * cur, gint64 * end)
|
||||
{
|
||||
GstQuery *query;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PAD (element), FALSE);
|
||||
g_return_val_if_fail (format != NULL, FALSE);
|
||||
|
||||
query = gst_query_new_position (*format);
|
||||
ret = gst_element_query (element, query);
|
||||
|
||||
if (ret)
|
||||
gst_query_parse_position (query, format, cur, end);
|
||||
|
||||
gst_query_unref (query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_element_query_convert (GstElement * element, GstFormat src_format,
|
||||
gint64 src_val, GstFormat * dest_fmt, gint64 * dest_val)
|
||||
{
|
||||
GstQuery *query;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
g_return_val_if_fail (dest_fmt != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_val != NULL, FALSE);
|
||||
|
||||
if (*dest_fmt == src_format) {
|
||||
*dest_val = src_val;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
query = gst_query_new_convert (src_format, src_val, *dest_fmt);
|
||||
ret = gst_element_query (element, query);
|
||||
|
||||
if (ret)
|
||||
gst_query_parse_convert (query, NULL, NULL, dest_fmt, dest_val);
|
||||
|
||||
gst_query_unref (query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_pad_can_link:
|
||||
* @srcpad: the source #GstPad to link.
|
||||
|
@ -1675,6 +1724,77 @@ gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps)
|
|||
return g_value_get_boolean (&ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_query_position:
|
||||
* @pad: a #GstPad to invoke the position query on.
|
||||
* @format: a pointer to the #GstFormat asked for.
|
||||
* On return contains the #GstFormat used.
|
||||
* @cur: A location in which to store the current position, or NULL.
|
||||
* @end: A location in which to store the end position (length), or NULL.
|
||||
*
|
||||
* Queries a pad for the stream position and length.
|
||||
*
|
||||
* Returns: TRUE if the query could be performed.
|
||||
*/
|
||||
gboolean
|
||||
gst_pad_query_position (GstPad * pad, GstFormat * format, gint64 * cur,
|
||||
gint64 * end)
|
||||
{
|
||||
GstQuery *query;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
||||
g_return_val_if_fail (format != NULL, FALSE);
|
||||
|
||||
query = gst_query_new_position (*format);
|
||||
ret = gst_pad_query (pad, query);
|
||||
|
||||
if (ret)
|
||||
gst_query_parse_position (query, format, cur, end);
|
||||
|
||||
gst_query_unref (query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_query_convert:
|
||||
* @pad: a #GstPad to invoke the convert query on.
|
||||
* @src_format: a #GstFormat to convert from.
|
||||
* @src_val: a value to convert.
|
||||
* @dest_format: a pointer to the #GstFormat to convert to.
|
||||
* @dest_val: a pointer to the result.
|
||||
*
|
||||
* Queries a pad to convert @src_val in @src_format to @dest_format.
|
||||
*
|
||||
* Returns: TRUE if the query could be performed.
|
||||
*/
|
||||
gboolean
|
||||
gst_pad_query_convert (GstPad * pad, GstFormat src_format, gint64 src_val,
|
||||
GstFormat * dest_fmt, gint64 * dest_val)
|
||||
{
|
||||
GstQuery *query;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
||||
g_return_val_if_fail (dest_fmt != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_val != NULL, FALSE);
|
||||
|
||||
if (*dest_fmt == src_format) {
|
||||
*dest_val = src_val;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
query = gst_query_new_convert (src_format, src_val, *dest_fmt);
|
||||
ret = gst_pad_query (pad, query);
|
||||
|
||||
if (ret)
|
||||
gst_query_parse_convert (query, NULL, NULL, dest_fmt, dest_val);
|
||||
|
||||
gst_query_unref (query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_atomic_int_set:
|
||||
|
|
|
@ -251,10 +251,15 @@ gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadn
|
|||
GstElement *dest, const gchar *destpadname);
|
||||
void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname,
|
||||
GstElement *dest, const gchar *destpadname);
|
||||
/* util query functions */
|
||||
gboolean gst_element_query_position (GstElement *element, GstFormat *format,
|
||||
gint64 *cur, gint64 *end);
|
||||
gboolean gst_element_query_convert (GstElement *element, GstFormat src_format, gint64 src_val,
|
||||
GstFormat *dest_fmt, gint64 *dest_val);
|
||||
|
||||
/* element class functions */
|
||||
void gst_element_class_install_std_props (GstElementClass * klass,
|
||||
const gchar * first_name, ...);
|
||||
void gst_element_class_install_std_props (GstElementClass * klass,
|
||||
const gchar * first_name, ...);
|
||||
|
||||
/* pad functions */
|
||||
gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
|
||||
|
@ -264,6 +269,12 @@ GstCaps* gst_pad_get_fixed_caps_func (GstPad *pad);
|
|||
GstCaps* gst_pad_proxy_getcaps (GstPad * pad);
|
||||
gboolean gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps);
|
||||
|
||||
/* util query functions */
|
||||
gboolean gst_pad_query_position (GstPad *pad, GstFormat *format,
|
||||
gint64 *cur, gint64 *end);
|
||||
gboolean gst_pad_query_convert (GstPad *pad, GstFormat src_format, gint64 src_val,
|
||||
GstFormat *dest_fmt, gint64 *dest_val);
|
||||
|
||||
/* bin functions */
|
||||
void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...);
|
||||
void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...);
|
||||
|
|
|
@ -89,9 +89,11 @@ static void gst_basesrc_get_property (GObject * object, guint prop_id,
|
|||
GValue * value, GParamSpec * pspec);
|
||||
static gboolean gst_basesrc_event_handler (GstPad * pad, GstEvent * event);
|
||||
|
||||
static gboolean gst_basesrc_query2 (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_basesrc_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *gst_basesrc_get_event_mask (GstPad * pad);
|
||||
#endif
|
||||
|
||||
static gboolean gst_basesrc_unlock (GstBaseSrc * basesrc);
|
||||
static gboolean gst_basesrc_get_size (GstBaseSrc * basesrc, guint64 * size);
|
||||
|
@ -158,9 +160,7 @@ gst_basesrc_init (GstBaseSrc * basesrc, gpointer g_class)
|
|||
|
||||
gst_pad_set_activate_function (pad, gst_basesrc_activate);
|
||||
gst_pad_set_event_function (pad, gst_basesrc_event_handler);
|
||||
gst_pad_set_event_mask_function (pad, gst_basesrc_get_event_mask);
|
||||
|
||||
gst_pad_set_query2_function (pad, gst_basesrc_query2);
|
||||
gst_pad_set_query_function (pad, gst_basesrc_query);
|
||||
|
||||
gst_pad_set_checkgetrange_function (pad, gst_basesrc_check_get_range);
|
||||
|
||||
|
@ -193,7 +193,7 @@ gst_basesrc_set_dataflow_funcs (GstBaseSrc * this)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_basesrc_query2 (GstPad * pad, GstQuery * query)
|
||||
gst_basesrc_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean b;
|
||||
guint64 ui64;
|
||||
|
@ -207,7 +207,7 @@ gst_basesrc_query2 (GstPad * pad, GstQuery * query)
|
|||
{
|
||||
GstFormat format;
|
||||
|
||||
gst_query_parse_position_query (query, &format);
|
||||
gst_query_parse_position (query, &format, NULL, NULL);
|
||||
switch (format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
case GST_FORMAT_BYTES:
|
||||
|
@ -243,10 +243,11 @@ gst_basesrc_query2 (GstPad * pad, GstQuery * query)
|
|||
case GST_QUERY_RATE:
|
||||
case GST_QUERY_CONVERT:
|
||||
default:
|
||||
return gst_pad_query2_default (pad, query);
|
||||
return gst_pad_query_default (pad, query);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *
|
||||
gst_basesrc_get_event_mask (GstPad * pad)
|
||||
{
|
||||
|
@ -260,6 +261,7 @@ gst_basesrc_get_event_mask (GstPad * pad)
|
|||
};
|
||||
return masks;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_basesrc_do_seek (GstBaseSrc * src, GstEvent * event)
|
||||
|
|
|
@ -80,7 +80,7 @@ static gboolean gst_filesink_event (GstBaseSink * sink, GstEvent * event);
|
|||
static GstFlowReturn gst_filesink_render (GstBaseSink * sink,
|
||||
GstBuffer * buffer);
|
||||
|
||||
static gboolean gst_filesink_query2 (GstPad * pad, GstQuery * query);
|
||||
static gboolean gst_filesink_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
static void gst_filesink_uri_handler_init (gpointer g_iface,
|
||||
gpointer iface_data);
|
||||
|
@ -144,7 +144,7 @@ gst_filesink_init (GstFileSink * filesink)
|
|||
|
||||
pad = GST_BASESINK_PAD (filesink);
|
||||
|
||||
gst_pad_set_query2_function (pad, gst_filesink_query2);
|
||||
gst_pad_set_query_function (pad, gst_filesink_query);
|
||||
|
||||
filesink->filename = NULL;
|
||||
filesink->file = NULL;
|
||||
|
@ -255,7 +255,7 @@ gst_filesink_close_file (GstFileSink * sink)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_filesink_query2 (GstPad * pad, GstQuery * query)
|
||||
gst_filesink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstFileSink *self;
|
||||
GstFormat format;
|
||||
|
@ -264,7 +264,7 @@ gst_filesink_query2 (GstPad * pad, GstQuery * query)
|
|||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
gst_query_parse_position_query (query, &format);
|
||||
gst_query_parse_position (query, &format, NULL, NULL);
|
||||
switch (format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
case GST_FORMAT_BYTES:
|
||||
|
@ -280,7 +280,7 @@ gst_filesink_query2 (GstPad * pad, GstQuery * query)
|
|||
return TRUE;
|
||||
|
||||
default:
|
||||
return gst_pad_query2_default (pad, query);
|
||||
return gst_pad_query_default (pad, query);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,7 @@ static void gst_queue_loop (GstPad * pad);
|
|||
static gboolean gst_queue_handle_sink_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
|
||||
static gboolean gst_queue_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value);
|
||||
static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query);
|
||||
|
||||
static GstCaps *gst_queue_getcaps (GstPad * pad);
|
||||
static GstPadLinkReturn gst_queue_link_sink (GstPad * pad, GstPad * peer);
|
||||
|
@ -811,29 +810,42 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_queue_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value)
|
||||
gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstQueue *queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
||||
|
||||
if (!GST_PAD_PEER (queue->sinkpad))
|
||||
return FALSE;
|
||||
if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), type, fmt, value))
|
||||
if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), query))
|
||||
return FALSE;
|
||||
|
||||
if (type == GST_QUERY_POSITION) {
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (*fmt) {
|
||||
case GST_FORMAT_BYTES:
|
||||
*value -= queue->cur_level.bytes;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
*value -= queue->cur_level.time;
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
gint64 peer_pos, peer_total;
|
||||
GstFormat format;
|
||||
|
||||
/* get peer position */
|
||||
gst_query_parse_position (query, &format, &peer_pos, &peer_total);
|
||||
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= queue->cur_level.bytes;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
peer_pos -= queue->cur_level.time;
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
}
|
||||
/* set updated positions */
|
||||
gst_query_set_position (query, format, peer_pos, peer_total);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -115,11 +115,13 @@ static void gst_type_find_element_set_property (GObject * object,
|
|||
static void gst_type_find_element_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad);
|
||||
#endif
|
||||
|
||||
static gboolean gst_type_find_element_src_event (GstPad * pad,
|
||||
GstEvent * event);
|
||||
static gboolean gst_type_find_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value);
|
||||
static gboolean gst_type_find_handle_src_query (GstPad * pad, GstQuery * query);
|
||||
static GstFlowReturn push_buffer_store (GstTypeFindElement * typefind);
|
||||
|
||||
static gboolean gst_type_find_element_handle_event (GstPad * pad,
|
||||
|
@ -219,8 +221,6 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
|
|||
gst_type_find_element_checkgetrange);
|
||||
gst_pad_set_getrange_function (typefind->src, gst_type_find_element_getrange);
|
||||
gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event);
|
||||
gst_pad_set_event_mask_function (typefind->src,
|
||||
gst_type_find_element_src_event_mask);
|
||||
gst_pad_set_query_function (typefind->src,
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_handle_src_query));
|
||||
gst_pad_use_fixed_caps (typefind->src);
|
||||
|
@ -295,32 +295,48 @@ gst_type_find_element_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_type_find_handle_src_query (GstPad * pad,
|
||||
GstQueryType type, GstFormat * fmt, gint64 * value)
|
||||
gst_type_find_handle_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstTypeFindElement *typefind =
|
||||
GST_TYPE_FIND_ELEMENT (gst_pad_get_parent (pad));
|
||||
GstTypeFindElement *typefind;
|
||||
gboolean res;
|
||||
|
||||
res = gst_pad_query (GST_PAD_PEER (typefind->sink), type, fmt, value);
|
||||
typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
|
||||
|
||||
res = gst_pad_query (GST_PAD_PEER (typefind->sink), query);
|
||||
if (!res)
|
||||
return FALSE;
|
||||
|
||||
if (type == GST_QUERY_POSITION && typefind->store != NULL) {
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (*fmt) {
|
||||
case GST_FORMAT_BYTES:
|
||||
*value -= gst_buffer_store_get_size (typefind->store, 0);
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
gint64 peer_pos, peer_total;
|
||||
GstFormat format;
|
||||
|
||||
if (typefind->store == NULL)
|
||||
return TRUE;
|
||||
|
||||
gst_query_parse_position (query, &format, &peer_pos, &peer_total);
|
||||
|
||||
/* FIXME: this code assumes that there's no discont in the queue */
|
||||
switch (format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
peer_pos -= gst_buffer_store_get_size (typefind->store, 0);
|
||||
break;
|
||||
default:
|
||||
/* FIXME */
|
||||
break;
|
||||
}
|
||||
gst_query_set_position (query, format, peer_pos, peer_total);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *
|
||||
gst_type_find_element_src_event_mask (GstPad * pad)
|
||||
{
|
||||
|
@ -334,6 +350,7 @@ gst_type_find_element_src_event_mask (GstPad * pad)
|
|||
|
||||
return mask;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_type_find_element_src_event (GstPad * pad, GstEvent * event)
|
||||
|
@ -462,24 +479,29 @@ find_element_get_length (gpointer data)
|
|||
return 0;
|
||||
}
|
||||
if (entry->self->stream_length == 0) {
|
||||
typefind->stream_length_available =
|
||||
gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL,
|
||||
&format, (gint64 *) & entry->self->stream_length);
|
||||
if (format != GST_FORMAT_BYTES)
|
||||
if (!gst_pad_query_position (GST_PAD_PEER (entry->self->sink), &format,
|
||||
NULL, (gint64 *) & entry->self->stream_length))
|
||||
goto no_length;
|
||||
|
||||
if (format != GST_FORMAT_BYTES) {
|
||||
typefind->stream_length_available = FALSE;
|
||||
if (!typefind->stream_length_available) {
|
||||
GST_DEBUG_OBJECT (entry->self,
|
||||
"'%s' called get_length () but it's not available",
|
||||
GST_PLUGIN_FEATURE_NAME (entry->factory));
|
||||
return 0;
|
||||
entry->self->stream_length = 0;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (entry->self,
|
||||
"'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes",
|
||||
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length);
|
||||
}
|
||||
}
|
||||
|
||||
return entry->self->stream_length;
|
||||
|
||||
no_length:
|
||||
{
|
||||
typefind->stream_length_available = FALSE;
|
||||
GST_DEBUG_OBJECT (entry->self,
|
||||
"'%s' called get_length () but it's not available",
|
||||
GST_PLUGIN_FEATURE_NAME (entry->factory));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -87,6 +87,7 @@ print_caps (const GstCaps * caps, const gchar * pfx)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
print_formats (const GstFormat * formats)
|
||||
{
|
||||
|
@ -103,6 +104,7 @@ print_formats (const GstFormat * formats)
|
|||
formats++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_query_types (const GstQueryType * types)
|
||||
|
@ -122,6 +124,7 @@ print_query_types (const GstQueryType * types)
|
|||
}
|
||||
|
||||
#ifndef GST_DISABLE_ENUMTYPES
|
||||
#if 0
|
||||
static void
|
||||
print_event_masks (const GstEventMask * masks)
|
||||
{
|
||||
|
@ -169,6 +172,7 @@ print_event_masks (const GstEventMask * masks)
|
|||
masks++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static void
|
||||
print_event_masks (const GstEventMask * masks)
|
||||
|
@ -631,20 +635,9 @@ print_pad_info (GstElement * element)
|
|||
if (realpad->getrangefunc)
|
||||
n_print (" Has getrangefunc(): %s\n",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->getrangefunc));
|
||||
if (realpad->formatsfunc != gst_pad_get_formats_default) {
|
||||
n_print (" Supports seeking/conversion/query formats:\n");
|
||||
print_formats (gst_pad_get_formats (GST_PAD (realpad)));
|
||||
}
|
||||
if (realpad->convertfunc != gst_pad_convert_default)
|
||||
n_print (" Has custom convertfunc(): %s\n",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc));
|
||||
if (realpad->eventfunc != gst_pad_event_default)
|
||||
n_print (" Has custom eventfunc(): %s\n",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc));
|
||||
if (realpad->eventmaskfunc != gst_pad_get_event_masks_default) {
|
||||
n_print (" Provides event masks:\n");
|
||||
print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)));
|
||||
}
|
||||
if (realpad->queryfunc != gst_pad_query_default)
|
||||
n_print (" Has custom queryfunc(): %s\n",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc));
|
||||
|
|
|
@ -73,6 +73,7 @@ print_caps (const GstCaps * caps, gint pfx)
|
|||
g_free (s);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
print_formats (const GstFormat * formats, gint pfx)
|
||||
{
|
||||
|
@ -89,6 +90,7 @@ print_formats (const GstFormat * formats, gint pfx)
|
|||
formats++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_query_types (const GstQueryType * types, gint pfx)
|
||||
|
@ -107,6 +109,7 @@ print_query_types (const GstQueryType * types, gint pfx)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
print_event_masks (const GstEventMask * masks, gint pfx)
|
||||
{
|
||||
|
@ -156,6 +159,7 @@ print_event_masks (const GstEventMask * masks, gint pfx)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
output_hierarchy (GType type, gint level, gint * maxlevel)
|
||||
|
@ -606,24 +610,9 @@ print_element_info (GstElementFactory * factory)
|
|||
if (realpad->getrangefunc)
|
||||
PUT_STRING (4, "<get-range-based function=\"%s\"/>",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->getrangefunc));
|
||||
if (realpad->formatsfunc != gst_pad_get_formats_default) {
|
||||
PUT_STRING (4, "<formats-function function=\"%s\">",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->formatsfunc));
|
||||
print_formats (gst_pad_get_formats (GST_PAD (realpad)), 5);
|
||||
PUT_END_TAG (4, "formats-function");
|
||||
}
|
||||
if (realpad->convertfunc != gst_pad_convert_default)
|
||||
PUT_STRING (4, "<convert-function function=\"%s\"/>",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc));
|
||||
if (realpad->eventfunc != gst_pad_event_default)
|
||||
PUT_STRING (4, "<event-function function=\"%s\"/>",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc));
|
||||
if (realpad->eventmaskfunc != gst_pad_get_event_masks_default) {
|
||||
PUT_STRING (4, "<event-mask-func function=\"%s\">",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->eventmaskfunc));
|
||||
print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)), 5);
|
||||
PUT_END_TAG (4, "event-mask-func");
|
||||
}
|
||||
if (realpad->queryfunc != gst_pad_query_default)
|
||||
PUT_STRING (4, "<query-function function=\"%s\"/>",
|
||||
GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc));
|
||||
|
|
Loading…
Reference in a new issue