+2005-05-09 Wim Taymans <wim@fluendo.com>
+
+ * examples/seeking/seek.c: (make_theora_pipeline),
+ (make_vorbis_theora_pipeline), (make_avi_msmpeg4v3_mp3_pipeline),
+ (query_rates), (query_positions_elems), (query_positions_pads),
+ (update_scale), (play_cb), (pause_cb), (stop_cb), (main):
+ * ext/ogg/gstoggdemux.c: (gst_ogg_pad_init),
+ (gst_ogg_pad_query_types), (gst_ogg_pad_src_query),
+ (gst_ogg_pad_typefind), (gst_ogg_demux_init),
+ (gst_ogg_demux_perform_seek), (gst_ogg_demux_read_chain),
+ (gst_ogg_demux_read_end_chain), (gst_ogg_demux_sink_activate):
+ * ext/ogg/gstoggmux.c: (gst_ogg_mux_init),
+ (gst_ogg_mux_request_new_pad), (gst_ogg_mux_next_buffer),
+ (gst_ogg_mux_push_page), (gst_ogg_mux_queue_pads),
+ (gst_ogg_mux_get_headers), (gst_ogg_mux_send_headers),
+ (gst_ogg_mux_collected), (gst_ogg_mux_change_state):
+ * ext/ogg/gstogmparse.c: (gst_ogm_audio_parse_init),
+ (gst_ogm_video_parse_init), (gst_ogm_text_parse_init),
+ (gst_ogm_parse_sink_query), (gst_ogm_parse_chain):
+ * ext/theora/theoradec.c: (gst_theora_dec_init), (_inc_granulepos),
+ (theora_dec_src_convert), (theora_dec_sink_convert),
+ (theora_dec_src_query), (theora_dec_sink_query),
+ (theora_dec_src_event), (theora_dec_sink_event),
+ (theora_handle_comment_packet), (theora_handle_type_packet),
+ (theora_handle_header_packet), (theora_handle_data_packet),
+ (theora_dec_chain):
+ * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
+ (vorbis_dec_convert), (vorbis_dec_src_query),
+ (vorbis_dec_sink_query), (vorbis_dec_src_event),
+ (vorbis_dec_sink_event), (vorbis_handle_comment_packet),
+ (vorbis_handle_type_packet), (vorbis_handle_header_packet),
+ (copy_samples), (vorbis_handle_data_packet), (vorbis_dec_chain):
+ * ext/vorbis/vorbisenc.c: (gst_vorbisenc_src_query),
+ (gst_vorbisenc_sink_query), (gst_vorbisenc_init),
+ (gst_vorbisenc_sink_event), (gst_vorbisenc_chain):
+ * gst/playback/gstplaybin.c: (gst_play_bin_class_init),
+ (gst_play_bin_query):
+ * gst/playback/test3.c: (update_scale):
+ * gst/sine/gstsinesrc.c: (gst_sinesrc_setcaps),
+ (gst_sinesrc_src_query), (gst_sinesrc_create), (gst_sinesrc_start):
+ * gst/subparse/gstsubparse.c: (gst_subparse_init):
+ * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_init),
+ (gst_videotestsrc_src_query):
+ * gst/videotestsrc/videotestsrc.c: (paint_hline_I420),
+ (paint_hline_Y41B), (paint_hline_Y42B), (paint_hline_Y800),
+ (paint_hline_YUV9):
+ * sys/ximage/ximagesink.c: (gst_ximagesink_show_frame):
+ Port to new query API.
+ Updated seek.
+ Cleanups in x[v]imagesink
+
2005-05-09 Andy Wingo <wingo@pobox.com>
* ext/alsa/gstalsasink.h:
static GList *seekable_elements = NULL;
static GstElement *pipeline;
-static guint64 duration;
+static gint64 position;
+static gint64 duration;
static GtkAdjustment *adjustment;
static GtkWidget *hscale;
static gboolean stats = FALSE;
#define SOURCE "gnomevfssrc"
#define ASINK "alsasink"
//#define ASINK "osssink"
+#define VSINK "xvimagesink"
+//#define VSINK "ximagesink"
+//#define VSINK "aasink"
#define UPDATE_INTERVAL 500
queue = gst_element_factory_make_or_warn ("queue", "queue");
decoder = gst_element_factory_make_or_warn ("theoradec", "decoder");
convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "convert");
- videosink = gst_element_factory_make_or_warn ("xvimagesink", "sink");
+ videosink = gst_element_factory_make_or_warn (VSINK, "sink");
g_object_set (G_OBJECT (src), "location", location, NULL);
v_decoder = gst_element_factory_make_or_warn ("theoradec", "v_dec");
v_convert =
gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert");
- videosink = gst_element_factory_make_or_warn ("xvimagesink", "v_sink");
+ videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
gst_bin_add (GST_BIN (video_bin), v_queue);
v_decoder = gst_element_factory_make_or_warn ("ffdec_msmpeg4", "v_dec");
v_convert =
gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert");
- videosink = gst_element_factory_make_or_warn ("xvimagesink", "v_sink");
+ videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
gst_bin_add (GST_BIN (video_bin), v_queue);
format = seek_formats[i].format;
- if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
+ if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
+ &value)) {
g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
G_GNUC_UNUSED static void
-query_durations_elems ()
-{
- GList *walk = seekable_elements;
-
- while (walk) {
- GstElement *element = GST_ELEMENT (walk->data);
- gint i = 0;
-
- g_print ("durations %8.8s: ", GST_ELEMENT_NAME (element));
- while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
- GstFormat format;
-
- format = seek_formats[i].format;
- res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
- } else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
- }
- i++;
- }
- g_print (" %s\n", GST_ELEMENT_NAME (element));
-
- walk = g_list_next (walk);
- }
-}
-
-G_GNUC_UNUSED static void
-query_durations_pads ()
-{
- GList *walk = seekable_pads;
-
- while (walk) {
- GstPad *pad = GST_PAD (walk->data);
- gint i = 0;
-
- g_print ("durations %8.8s: ", GST_PAD_NAME (pad));
- while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
- GstFormat format;
-
- format = seek_formats[i].format;
- res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
- } else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
- }
- i++;
- }
- g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
-
- walk = g_list_next (walk);
- }
-}
-
-G_GNUC_UNUSED static void
query_positions_elems ()
{
GList *walk = seekable_elements;
g_print ("positions %8.8s: ", GST_ELEMENT_NAME (element));
while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
+ gint64 position, total;
GstFormat format;
format = seek_formats[i].format;
- res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
+
+ if (gst_element_query_position (element, &format, &position, &total)) {
+ g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
+ seek_formats[i].name, position, total);
} else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
+ "*NA*");
}
i++;
}
g_print ("positions %8.8s: ", GST_PAD_NAME (pad));
while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
GstFormat format;
+ gint64 position, total;
format = seek_formats[i].format;
- res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
+
+ if (gst_pad_query_position (pad, &format, &position, &total)) {
+ g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
+ seek_formats[i].name, position, total);
} else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
+ "*NA*");
}
+
i++;
}
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
update_scale (gpointer data)
{
GstClock *clock;
- guint64 position;
- GstFormat format = GST_FORMAT_TIME;
- gboolean res;
+ GstFormat format;
+ position = 0;
duration = 0;
clock = gst_pipeline_get_clock (GST_PIPELINE (pipeline));
+ format = GST_FORMAT_TIME;
+
if (elem_seek) {
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
- res = gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
- if (!res)
- duration = 0;
- res = gst_element_query (element, GST_QUERY_POSITION, &format, &position);
- if (!res)
- position = 0;
+ gst_element_query_position (element, &format, &position, &duration);
}
} else {
if (seekable_pads) {
GstPad *pad = GST_PAD (seekable_pads->data);
- res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration);
- if (!res)
- duration = 0;
- res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position);
- if (!res)
- position = 0;
+ gst_pad_query_position (pad, &format, &position, &duration);
}
}
}
if (elem_seek) {
- query_durations_elems ();
query_positions_elems ();
} else {
- query_durations_pads ();
query_positions_pads ();
}
query_rates ();
gst_element_get_state (pipeline, &state, NULL, NULL);
if (state != GST_STATE_PLAYING) {
+ g_print ("PLAY pipeline\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
gst_element_get_state (pipeline, &state, NULL, NULL);
if (state != GST_STATE_PAUSED) {
+ g_print ("PAUSE pipeline\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
}
gst_element_get_state (pipeline, &state, NULL, NULL);
if (state != GST_STATE_READY) {
+ g_print ("READY pipeline\n");
gst_element_set_state (pipeline, GST_STATE_READY);
gtk_adjustment_set_value (adjustment, 0.0);
gtk_timeout_remove (update_id);
}
gtk_main ();
+ g_print ("NULL pipeline\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
+ g_print ("free pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
static void gst_ogg_pad_init (GstOggPad * pad);
static void gst_ogg_pad_dispose (GObject * object);
static void gst_ogg_pad_finalize (GObject * object);
+
+#if 0
static const GstFormat *gst_ogg_pad_formats (GstPad * pad);
static const GstEventMask *gst_ogg_pad_event_masks (GstPad * pad);
+#endif
static const GstQueryType *gst_ogg_pad_query_types (GstPad * pad);
-static gboolean gst_ogg_pad_src_convert (GstPad * pad,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value);
-static gboolean gst_ogg_pad_src_query (GstPad * pad, GstQueryType type,
- GstFormat * format, gint64 * value);
+static gboolean gst_ogg_pad_src_query (GstPad * pad, GstQuery * query);
static gboolean gst_ogg_pad_event (GstPad * pad, GstEvent * event);
static GstCaps *gst_ogg_pad_getcaps (GstPad * pad);
static GstCaps *gst_ogg_type_find (ogg_packet * packet);
{
gst_pad_set_event_function (GST_PAD (pad),
GST_DEBUG_FUNCPTR (gst_ogg_pad_event));
- gst_pad_set_event_mask_function (GST_PAD (pad),
- GST_DEBUG_FUNCPTR (gst_ogg_pad_event_masks));
gst_pad_set_getcaps_function (GST_PAD (pad),
GST_DEBUG_FUNCPTR (gst_ogg_pad_getcaps));
gst_pad_set_query_type_function (GST_PAD (pad),
GST_DEBUG_FUNCPTR (gst_ogg_pad_query_types));
- gst_pad_set_formats_function (GST_PAD (pad),
- GST_DEBUG_FUNCPTR (gst_ogg_pad_formats));
- gst_pad_set_convert_function (GST_PAD (pad),
- GST_DEBUG_FUNCPTR (gst_ogg_pad_src_convert));
gst_pad_set_query_function (GST_PAD (pad),
GST_DEBUG_FUNCPTR (gst_ogg_pad_src_query));
G_OBJECT_CLASS (ogg_pad_parent_class)->finalize (object);
}
+#if 0
static const GstFormat *
gst_ogg_pad_formats (GstPad * pad)
{
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
}
+#endif
+#if 0
static const GstEventMask *
gst_ogg_pad_event_masks (GstPad * pad)
{
return src_event_masks;
}
+#endif
static const GstQueryType *
gst_ogg_pad_query_types (GstPad * pad)
{
static const GstQueryType query_types[] = {
GST_QUERY_POSITION,
- GST_QUERY_TOTAL,
0
};
}
static gboolean
-gst_ogg_pad_src_convert (GstPad * pad,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value)
-{
- gboolean res = FALSE;
- GstOggDemux *ogg;
-
- ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
-
- /* fill me, not sure with what... */
-
- return res;
-}
-
-static gboolean
-gst_ogg_pad_src_query (GstPad * pad, GstQueryType type,
- GstFormat * format, gint64 * value)
+gst_ogg_pad_src_query (GstPad * pad, GstQuery * query)
{
gboolean res = TRUE;
GstOggDemux *ogg;
ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad));
cur = GST_OGG_PAD (pad);
- switch (type) {
+ switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
- *value = cur->current_granule;
+ gst_query_set_position (query, GST_FORMAT_TIME, -1, ogg->total_time);
break;
- case GST_QUERY_TOTAL:
- *value = ogg->total_time;
+ case GST_QUERY_CONVERT:
+ /* hmm .. */
+ res = FALSE;
break;
default:
res = FALSE;
ogg->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&ogg_demux_sink_template_factory), "sink");
- gst_pad_set_formats_function (ogg->sinkpad, gst_ogg_pad_formats);
gst_pad_set_loop_function (ogg->sinkpad,
(GstPadLoopFunction) gst_ogg_demux_loop);
gst_pad_set_event_function (ogg->sinkpad, gst_ogg_demux_handle_event);
} else {
gint64 granulepos;
GstClockTime granuletime;
- GstFormat format = GST_FORMAT_TIME;
+ GstFormat format;
GstOggPad *pad;
granulepos = ogg_page_granulepos (&og);
if (pad == NULL)
continue;
- gst_pad_convert (pad->elem_pad,
- GST_FORMAT_DEFAULT, granulepos, &format, (gint64 *) & granuletime);
+ format = GST_FORMAT_TIME;
+ if (!gst_pad_query_convert (pad->elem_pad,
+ GST_FORMAT_DEFAULT, granulepos, &format,
+ (gint64 *) & granuletime)) {
+ g_warning ("could not convert granulepos to time");
+ granuletime = target;
+ }
GST_DEBUG_OBJECT (ogg,
"found page with granule %" G_GINT64_FORMAT " and time %"
/* now we can fill in the missing info using queries */
for (i = 0; i < chain->streams->len; i++) {
GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, i);
- GstFormat target = GST_FORMAT_TIME;
+ GstFormat target;
- gst_pad_convert (pad->elem_pad,
- GST_FORMAT_DEFAULT, pad->first_granule, &target,
- (gint64 *) & pad->first_time);
+ target = GST_FORMAT_TIME;
+ if (!gst_pad_query_convert (pad->elem_pad,
+ GST_FORMAT_DEFAULT, pad->first_granule, &target,
+ (gint64 *) & pad->first_time)) {
+ g_warning ("could not convert granule to time");
+ }
pad->mode = GST_OGG_PAD_MODE_STREAMING;
pad->packetno = 0;
/* now we can fill in the missing info using queries */
for (i = 0; i < chain->streams->len; i++) {
GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, i);
- GstFormat target = GST_FORMAT_TIME;
+ GstFormat target;
- gst_pad_convert (pad->elem_pad,
- GST_FORMAT_DEFAULT, pad->last_granule, &target,
- (gint64 *) & pad->last_time);
+ target = GST_FORMAT_TIME;
+ if (!gst_pad_query_convert (pad->elem_pad,
+ GST_FORMAT_DEFAULT, pad->last_granule, &target,
+ (gint64 *) & pad->last_time)) {
+ g_warning ("could not convert granule to time");
+ }
}
return 0;
}
}
+#if 0
static const GstEventMask *
gst_ogg_mux_get_sink_event_masks (GstPad * pad)
{
return gst_ogg_mux_sink_event_masks;
}
+#endif
static void
gst_ogg_mux_init (GstOggMux * ogg_mux)
/* setup some pad functions */
gst_pad_set_link_function (newpad, gst_ogg_mux_sinkconnect);
- gst_pad_set_event_mask_function (newpad, gst_ogg_mux_get_sink_event_masks);
/* dd the pad to the element */
gst_element_add_pad (element, newpad);
static void gst_ogm_audio_parse_init (GstOgmParse * ogm);
static void gst_ogm_text_parse_init (GstOgmParse * ogm);
+#if 0
static const GstFormat *gst_ogm_parse_get_sink_formats (GstPad * pad);
+#endif
+
static const GstQueryType *gst_ogm_parse_get_sink_querytypes (GstPad * pad);
+static gboolean gst_ogm_parse_sink_query (GstPad * pad, GstQuery * query);
static gboolean gst_ogm_parse_sink_convert (GstPad * pad, GstFormat src_format,
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
-static gboolean gst_ogm_parse_sink_query (GstPad * pad, GstQueryType type,
- GstFormat * fmt, gint64 * val);
static GstFlowReturn gst_ogm_parse_chain (GstPad * pad, GstBuffer * buffer);
/* create the pads */
templ = gst_static_pad_template_get (&ogm_audio_parse_sink_template_factory);
ogm->sinkpad = gst_pad_new_from_template (templ, "sink");
- gst_pad_set_convert_function (ogm->sinkpad, gst_ogm_parse_sink_convert);
- gst_pad_set_formats_function (ogm->sinkpad, gst_ogm_parse_get_sink_formats);
+ gst_pad_set_query_function (ogm->sinkpad, gst_ogm_parse_sink_query);
gst_pad_set_chain_function (ogm->sinkpad, gst_ogm_parse_chain);
gst_element_add_pad (GST_ELEMENT (ogm), ogm->sinkpad);
/* create the pads */
templ = gst_static_pad_template_get (&ogm_video_parse_sink_template_factory);
ogm->sinkpad = gst_pad_new_from_template (templ, "sink");
- gst_pad_set_convert_function (ogm->sinkpad, gst_ogm_parse_sink_convert);
- gst_pad_set_formats_function (ogm->sinkpad, gst_ogm_parse_get_sink_formats);
+ gst_pad_set_query_function (ogm->sinkpad, gst_ogm_parse_sink_query);
gst_pad_set_chain_function (ogm->sinkpad, gst_ogm_parse_chain);
gst_element_add_pad (GST_ELEMENT (ogm), ogm->sinkpad);
/* create the pads */
templ = gst_static_pad_template_get (&ogm_text_parse_sink_template_factory);
ogm->sinkpad = gst_pad_new_from_template (templ, "sink");
- gst_pad_set_convert_function (ogm->sinkpad, gst_ogm_parse_sink_convert);
- gst_pad_set_formats_function (ogm->sinkpad, gst_ogm_parse_get_sink_formats);
gst_pad_set_query_type_function (ogm->sinkpad,
gst_ogm_parse_get_sink_querytypes);
gst_pad_set_query_function (ogm->sinkpad, gst_ogm_parse_sink_query);
ogm->srcpadtempl = text_src_templ;
}
+#if 0
static const GstFormat *
gst_ogm_parse_get_sink_formats (GstPad * pad)
{
return formats;
}
+#endif
static const GstQueryType *
gst_ogm_parse_get_sink_querytypes (GstPad * pad)
}
static gboolean
-gst_ogm_parse_sink_query (GstPad * pad,
- GstQueryType type, GstFormat * fmt, gint64 * val)
+gst_ogm_parse_sink_query (GstPad * pad, GstQuery * query)
{
- GstOgmParse *ogm = GST_OGM_PARSE (gst_pad_get_parent (pad));
+ GstOgmParse *ogm = GST_OGM_PARSE (GST_PAD_PARENT (pad));
+ GstFormat format;
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_POSITION:
+ {
+ gint64 val;
+
+ gst_query_parse_position (query, &format, NULL, NULL);
- if (type != GST_QUERY_POSITION)
- return FALSE;
- if (*fmt != GST_FORMAT_DEFAULT && *fmt != GST_FORMAT_TIME)
- return FALSE;
+ if (format != GST_FORMAT_DEFAULT && format != GST_FORMAT_TIME)
+ return FALSE;
- return gst_pad_convert (pad,
- GST_FORMAT_DEFAULT, ogm->next_granulepos, fmt, val);
+ if ((res = gst_ogm_parse_sink_convert (pad,
+ GST_FORMAT_DEFAULT, ogm->next_granulepos, &format, &val))) {
+ /* don't know the total length here.. */
+ gst_query_set_position (query, format, val, -1);
+ }
+ break;
+ }
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ /* peel off input */
+ gst_query_parse_convert (query, &src_fmt, &src_val, NULL, NULL);
+ if ((res = gst_ogm_parse_sink_convert (pad, src_fmt, src_val,
+ &dest_fmt, &dest_val))) {
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ }
+ break;
+ }
+ default:
+ res = FALSE;
+ break;
+ }
+ return res;
}
static GstFlowReturn
static GstFlowReturn theora_dec_chain (GstPad * pad, GstBuffer * buffer);
static GstElementStateReturn theora_dec_change_state (GstElement * element);
static gboolean theora_dec_src_event (GstPad * pad, GstEvent * event);
-static gboolean theora_dec_src_query (GstPad * pad,
- GstQueryType query, GstFormat * format, gint64 * value);
+static gboolean theora_dec_src_query (GstPad * pad, GstQuery * query);
static gboolean theora_dec_src_convert (GstPad * pad,
GstFormat src_format, gint64 src_value,
GstFormat * dest_format, gint64 * dest_value);
static gboolean theora_dec_sink_convert (GstPad * pad,
GstFormat src_format, gint64 src_value,
GstFormat * dest_format, gint64 * dest_value);
+static gboolean theora_dec_sink_query (GstPad * pad, GstQuery * query);
+
+#if 0
static const GstFormat *theora_get_formats (GstPad * pad);
+#endif
+#if 0
static const GstEventMask *theora_get_event_masks (GstPad * pad);
+#endif
static const GstQueryType *theora_get_query_types (GstPad * pad);
dec->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&theora_dec_sink_factory), "sink");
- gst_pad_set_formats_function (dec->sinkpad, theora_get_formats);
- gst_pad_set_convert_function (dec->sinkpad, theora_dec_sink_convert);
+ gst_pad_set_query_function (dec->sinkpad, theora_dec_sink_query);
gst_pad_set_event_function (dec->sinkpad, theora_dec_sink_event);
gst_pad_set_chain_function (dec->sinkpad, theora_dec_chain);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
dec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&theora_dec_src_factory), "src");
- gst_pad_set_event_mask_function (dec->srcpad, theora_get_event_masks);
gst_pad_set_event_function (dec->srcpad, theora_dec_src_event);
gst_pad_set_query_type_function (dec->srcpad, theora_get_query_types);
gst_pad_set_query_function (dec->srcpad, theora_dec_src_query);
- gst_pad_set_formats_function (dec->srcpad, theora_get_formats);
- gst_pad_set_convert_function (dec->srcpad, theora_dec_src_convert);
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
dec->granulepos = (framecount << ilog);
}
+#if 0
static const GstFormat *
theora_get_formats (GstPad * pad)
{
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
}
+#endif
+#if 0
static const GstEventMask *
theora_get_event_masks (GstPad * pad)
{
return theora_src_event_masks;
}
+#endif
static const GstQueryType *
theora_get_query_types (GstPad * pad)
if (dec->packetno < 1)
return FALSE;
+ if (src_format == *dest_format) {
+ *dest_value = src_value;
+ return TRUE;
+ }
+
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
if (dec->packetno < 1)
return FALSE;
+ if (src_format == *dest_format) {
+ *dest_value = src_value;
+ return TRUE;
+ }
+
switch (src_format) {
case GST_FORMAT_DEFAULT:
{
}
static gboolean
-theora_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
- gint64 * value)
+theora_dec_src_query (GstPad * pad, GstQuery * query)
{
- gint64 granulepos;
GstTheoraDec *dec = GST_THEORA_DEC (GST_PAD_PARENT (pad));
- GstFormat my_format = GST_FORMAT_DEFAULT;
- guint64 time;
+ gboolean res = FALSE;
- if (query == GST_QUERY_POSITION) {
- /* this is easy, we can convert a granule position to everything */
- granulepos = dec->granulepos;
- } else {
- /* for the total, we just forward the query to the peer */
- return gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, format, value);
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_POSITION:
+ {
+ gboolean res;
+ gint64 granulepos, total, value;
+ GstFormat my_format, format;
+ gint64 time;
+
+ /* forward to peer for total */
+ if (!(res = gst_pad_query (GST_PAD_PEER (dec->sinkpad), query)))
+ goto error;
+
+ /* we can convert a granule position to everything */
+ granulepos = dec->granulepos;
+
+ /* parse total time from peer and format */
+ gst_query_parse_position (query, &format, NULL, &total);
+
+ /* and convert to the final format in two steps with time as the
+ * intermediate step */
+ my_format = GST_FORMAT_TIME;
+ if (!(res =
+ theora_dec_sink_convert (dec->sinkpad, GST_FORMAT_DEFAULT,
+ granulepos, &my_format, &time)))
+ goto error;
+
+ if (!(res =
+ theora_dec_src_convert (pad, my_format, time, &format, &value)))
+ goto error;
+
+ gst_query_set_position (query, format, value, total);
+
+ GST_LOG_OBJECT (dec,
+ "query %u: peer returned granulepos: %llu - we return %llu (format %u)",
+ query, granulepos, value, format);
+
+ res = TRUE;
+ break;
+ }
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if ((res =
+ theora_dec_src_convert (pad, src_fmt, src_val, &dest_fmt,
+ &dest_val)))
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
+ default:
+ res = FALSE;
+ break;
}
- /* and convert to the final format in two steps with time as the
- * intermediate step */
- my_format = GST_FORMAT_TIME;
- if (!theora_dec_sink_convert (dec->sinkpad, GST_FORMAT_DEFAULT, granulepos,
- &my_format, (gint64 *) & time))
- return FALSE;
- if (!gst_pad_convert (pad, my_format, time, format, value))
- return FALSE;
+error:
+ return res;
+}
+
+static gboolean
+theora_dec_sink_query (GstPad * pad, GstQuery * query)
+{
+ gboolean res = FALSE;
- GST_LOG_OBJECT (dec,
- "query %u: peer returned granulepos: %llu - we return %llu (format %u)",
- query, granulepos, *value, *format);
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if (!(res =
+ theora_dec_sink_convert (pad, src_fmt, src_val, &dest_fmt,
+ &dest_val)))
+ goto error;
+
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
+ default:
+ res = FALSE;
+ break;
+ }
- return TRUE;
+error:
+ return res;
}
static gboolean
* First bring the requested format to time
*/
format = GST_FORMAT_TIME;
- res = gst_pad_convert (pad, GST_EVENT_SEEK_FORMAT (event),
- GST_EVENT_SEEK_OFFSET (event), &format, &value);
- if (!res)
+ if (!(res = theora_dec_src_convert (pad, GST_EVENT_SEEK_FORMAT (event),
+ GST_EVENT_SEEK_OFFSET (event), &format, &value)))
goto error;
/* then seek with time on the peer */
static gboolean vorbis_dec_sink_event (GstPad * pad, GstEvent * event);
static GstFlowReturn vorbis_dec_chain (GstPad * pad, GstBuffer * buffer);
static GstElementStateReturn vorbis_dec_change_state (GstElement * element);
+
+#if 0
static const GstFormat *vorbis_dec_get_formats (GstPad * pad);
+#endif
static gboolean vorbis_dec_src_event (GstPad * pad, GstEvent * event);
-static gboolean vorbis_dec_src_query (GstPad * pad,
- GstQueryType query, GstFormat * format, gint64 * value);
+static gboolean vorbis_dec_src_query (GstPad * pad, GstQuery * query);
static gboolean vorbis_dec_convert (GstPad * pad,
GstFormat src_format, gint64 src_value,
GstFormat * dest_format, gint64 * dest_value);
+static gboolean vorbis_dec_sink_query (GstPad * pad, GstQuery * query);
static void
gst_vorbis_dec_base_init (gpointer g_class)
gstelement_class->change_state = vorbis_dec_change_state;
}
+#if 0
static const GstFormat *
vorbis_dec_get_formats (GstPad * pad)
{
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
}
+#endif
+#if 0
static const GstEventMask *
vorbis_get_event_masks (GstPad * pad)
{
return vorbis_dec_src_event_masks;
}
+#endif
static const GstQueryType *
vorbis_get_query_types (GstPad * pad)
(&vorbis_dec_sink_factory), "sink");
gst_pad_set_event_function (dec->sinkpad, vorbis_dec_sink_event);
gst_pad_set_chain_function (dec->sinkpad, vorbis_dec_chain);
- gst_pad_set_formats_function (dec->sinkpad, vorbis_dec_get_formats);
- gst_pad_set_convert_function (dec->sinkpad, vorbis_dec_convert);
+ gst_pad_set_query_function (dec->sinkpad, vorbis_dec_sink_query);
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
dec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&vorbis_dec_src_factory), "src");
- gst_pad_set_event_mask_function (dec->srcpad, vorbis_get_event_masks);
gst_pad_set_event_function (dec->srcpad, vorbis_dec_src_event);
gst_pad_set_query_type_function (dec->srcpad, vorbis_get_query_types);
gst_pad_set_query_function (dec->srcpad, vorbis_dec_src_query);
- gst_pad_set_formats_function (dec->srcpad, vorbis_dec_get_formats);
- gst_pad_set_convert_function (dec->srcpad, vorbis_dec_convert);
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
}
if (dec->packetno < 1)
return FALSE;
+ if (src_format == *dest_format) {
+ *dest_value = src_value;
+ return TRUE;
+ }
+
if (dec->sinkpad == pad &&
(src_format == GST_FORMAT_BYTES || *dest_format == GST_FORMAT_BYTES))
return FALSE;
}
static gboolean
-vorbis_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
- gint64 * value)
+vorbis_dec_src_query (GstPad * pad, GstQuery * query)
{
- gint64 granulepos = 0;
- GstVorbisDec *dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
+ gint64 granulepos;
+ GstVorbisDec *dec;
+ gboolean res;
- if (query == GST_QUERY_POSITION) {
- granulepos = dec->granulepos;
- } else {
- /* query peer in default format */
- return gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, format, value);
+ dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_POSITION:
+ {
+ GstFormat format;
+ gint64 value, total;
+
+ /* query peer for total length */
+ if (!(res = gst_pad_query (GST_PAD_PEER (dec->sinkpad), query)))
+ goto error;
+
+ granulepos = dec->granulepos;
+
+ gst_query_parse_position (query, &format, NULL, &total);
+
+ /* and convert to the final format */
+ if (!(res =
+ vorbis_dec_convert (pad, GST_FORMAT_DEFAULT, granulepos, &format,
+ &value)))
+ goto error;
+
+ gst_query_set_position (query, format, value, total);
+
+ GST_LOG_OBJECT (dec,
+ "query %u: peer returned granulepos: %llu - we return %llu (format %u)",
+ query, granulepos, value, format);
+
+ break;
+ }
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if (!(res =
+ vorbis_dec_convert (pad, src_fmt, src_val, &dest_fmt, &dest_val)))
+ goto error;
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
+ default:
+ res = FALSE;
+ break;
}
+ return res;
- /* and convert to the final format */
- if (!gst_pad_convert (pad, GST_FORMAT_DEFAULT, granulepos, format, value))
- return FALSE;
+error:
+ {
+ GST_DEBUG ("error handling event");
+ return res;
+ }
+}
- GST_LOG_OBJECT (dec,
- "query %u: peer returned granulepos: %llu - we return %llu (format %u)",
- query, granulepos, *value, *format);
- return TRUE;
+static gboolean
+vorbis_dec_sink_query (GstPad * pad, GstQuery * query)
+{
+ GstVorbisDec *dec;
+ gboolean res;
+
+ dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if (!(res =
+ vorbis_dec_convert (pad, src_fmt, src_val, &dest_fmt, &dest_val)))
+ goto error;
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
+ default:
+ res = FALSE;
+ break;
+ }
+error:
+ return res;
}
static gboolean
GstFormat my_format = GST_FORMAT_TIME;
/* convert to time */
- res = gst_pad_convert (pad, GST_EVENT_SEEK_FORMAT (event),
+ res = vorbis_dec_convert (pad, GST_EVENT_SEEK_FORMAT (event),
GST_EVENT_SEEK_OFFSET (event), &my_format, &value);
if (res) {
GstEvent *real_seek = gst_event_new_seek (
return (-1);
}
+#if 0
static const GstFormat *
gst_vorbisenc_get_formats (GstPad * pad)
{
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
}
+#endif
#define MAX_BITRATE_DEFAULT -1
#define BITRATE_DEFAULT -1
}
static gboolean
-gst_vorbisenc_src_query (GstPad * pad, GstQueryType type,
- GstFormat * format, gint64 * value)
+gst_vorbisenc_src_query (GstPad * pad, GstQuery * query)
{
gboolean res = TRUE;
VorbisEnc *vorbisenc;
- vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
+ vorbisenc = GST_VORBISENC (GST_PAD_PARENT (pad));
- switch (type) {
- case GST_QUERY_TOTAL:
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_POSITION:
{
+#if 0
switch (*format) {
case GST_FORMAT_BYTES:
case GST_FORMAT_TIME:
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
- res = gst_pad_convert (vorbisenc->sinkpad,
+ res = gst_vorbisenc_convert_sink (vorbisenc->sinkpad,
peer_format, peer_value, &conv_format, value);
/* and to final format */
- res &= gst_pad_convert (pad,
+ res &= gst_vorbisenc_convert_src (pad,
GST_FORMAT_TIME, *value, format, value);
}
peer_formats++;
res = FALSE;
break;
}
+#endif
+ res = FALSE;
break;
}
- case GST_QUERY_POSITION:
- switch (*format) {
- default:
- {
- /* we only know about our samples, convert to requested format */
- res = gst_pad_convert (pad,
- GST_FORMAT_BYTES, vorbisenc->bytes_out, format, value);
- break;
- }
- }
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if (!(res =
+ gst_vorbisenc_convert_src (pad, src_fmt, src_val, &dest_fmt,
+ &dest_val)))
+ goto error;
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
+ default:
+ res = FALSE;
break;
+ }
+
+error:
+ return res;
+}
+
+static gboolean
+gst_vorbisenc_sink_query (GstPad * pad, GstQuery * query)
+{
+ gboolean res = TRUE;
+ VorbisEnc *vorbisenc;
+
+ vorbisenc = GST_VORBISENC (GST_PAD_PARENT (pad));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ if (!(res =
+ gst_vorbisenc_convert_sink (pad, src_fmt, src_val, &dest_fmt,
+ &dest_val)))
+ goto error;
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
default:
res = FALSE;
break;
}
+
+error:
return res;
}
gst_pad_set_event_function (vorbisenc->sinkpad, gst_vorbisenc_sink_event);
gst_pad_set_chain_function (vorbisenc->sinkpad, gst_vorbisenc_chain);
gst_pad_set_setcaps_function (vorbisenc->sinkpad, gst_vorbisenc_sink_setcaps);
- gst_pad_set_convert_function (vorbisenc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_sink));
- gst_pad_set_formats_function (vorbisenc->sinkpad,
- GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
+ gst_pad_set_query_function (vorbisenc->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_vorbisenc_sink_query));
vorbisenc->srcpad =
gst_pad_new_from_template (gst_vorbisenc_src_template, "src");
GST_DEBUG_FUNCPTR (gst_vorbisenc_src_query));
gst_pad_set_query_type_function (vorbisenc->srcpad,
GST_DEBUG_FUNCPTR (gst_vorbisenc_get_query_types));
- gst_pad_set_convert_function (vorbisenc->srcpad,
- GST_DEBUG_FUNCPTR (gst_vorbisenc_convert_src));
- gst_pad_set_formats_function (vorbisenc->srcpad,
- GST_DEBUG_FUNCPTR (gst_vorbisenc_get_formats));
gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->srcpad);
vorbisenc->channels = -1;
GValue * value, GParamSpec * spec);
static GstElementStateReturn gst_play_bin_change_state (GstElement * element);
-static const GstEventMask *gst_play_bin_get_event_masks (GstElement * element);
static gboolean gst_play_bin_send_event (GstElement * element,
GstEvent * event);
-static const GstFormat *gst_play_bin_get_formats (GstElement * element);
-static gboolean gst_play_bin_convert (GstElement * element,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value);
static const GstQueryType *gst_play_bin_get_query_types (GstElement * element);
-static gboolean gst_play_bin_query (GstElement * element, GstQueryType type,
- GstFormat * format, gint64 * value);
+static gboolean gst_play_bin_query (GstElement * element, GstQuery * query);
static GstElementClass *parent_class;
gstelement_klass->change_state =
GST_DEBUG_FUNCPTR (gst_play_bin_change_state);
- gstelement_klass->get_event_masks =
- GST_DEBUG_FUNCPTR (gst_play_bin_get_event_masks);
gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_play_bin_send_event);
- gstelement_klass->get_formats = GST_DEBUG_FUNCPTR (gst_play_bin_get_formats);
- gstelement_klass->convert = GST_DEBUG_FUNCPTR (gst_play_bin_convert);
gstelement_klass->get_query_types =
GST_DEBUG_FUNCPTR (gst_play_bin_get_query_types);
gstelement_klass->query = GST_DEBUG_FUNCPTR (gst_play_bin_query);
}
+#if 0
static const GstEventMask *
gst_play_bin_get_event_masks (GstElement * element)
{
/* FIXME, get the list from the number of installed sinks */
return NULL;
}
+#endif
/* send an event to all the sinks */
static gboolean
return res;
}
+#if 0
static const GstFormat *
gst_play_bin_get_formats (GstElement * element)
{
return formats;
}
-
-static gboolean
-gst_play_bin_convert (GstElement * element,
- GstFormat src_format, gint64 src_value,
- GstFormat * dest_format, gint64 * dest_value)
-{
- gboolean res = FALSE;
- GList *s;
- GstPlayBin *play_bin;
-
- play_bin = GST_PLAY_BIN (element);
-
- /* do a conversion, loop over all sinks, stop as soon as one of the
- * sinks returns a successful result */
- for (s = play_bin->seekables; s; s = g_list_next (s)) {
- GstElement *element = GST_ELEMENT (s->data);
-
- res = gst_element_convert (element, src_format, src_value,
- dest_format, dest_value);
- if (res)
- break;
- }
- return res;
-}
+#endif
static const GstQueryType *
gst_play_bin_get_query_types (GstElement * element)
}
static gboolean
-gst_play_bin_query (GstElement * element, GstQueryType type,
- GstFormat * format, gint64 * value)
+gst_play_bin_query (GstElement * element, GstQuery * query)
{
gboolean res = FALSE;
GList *s;
for (s = play_bin->seekables; s; s = g_list_next (s)) {
GstElement *element = GST_ELEMENT (s->data);
- res = gst_element_query (element, type, format, value);
+ res = gst_element_query (element, query);
if (res)
break;
}
gint64 position;
GstFormat format = GST_FORMAT_TIME;
- gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
- gst_element_query (element, GST_QUERY_POSITION, &format, &position);
+ gst_element_query_position (element, &format, &position, &duration);
g_print ("%" G_GINT64_FORMAT " %" G_GINT64_FORMAT "\n", duration, position);
static inline void gst_sinesrc_update_table_inc (GstSineSrc * src);
static const GstQueryType *gst_sinesrc_get_query_types (GstPad * pad);
-static gboolean gst_sinesrc_src_query (GstPad * pad,
- GstQueryType type, GstFormat * format, gint64 * value);
+static gboolean gst_sinesrc_src_query (GstPad * pad, GstQuery * query);
static GstFlowReturn gst_sinesrc_create (GstBaseSrc * basesrc, guint64 offset,
guint length, GstBuffer ** buffer);
}
static gboolean
-gst_sinesrc_src_query (GstPad * pad,
- GstQueryType type, GstFormat * format, gint64 * value)
+gst_sinesrc_src_query (GstPad * pad, GstQuery * query)
{
gboolean res = FALSE;
GstSineSrc *src;
src = GST_SINESRC (GST_PAD_PARENT (pad));
- switch (type) {
+ switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
- switch (*format) {
+ {
+ GstFormat format;
+ gint64 current;
+
+ gst_query_parse_position (query, &format, NULL, NULL);
+
+ switch (format) {
case GST_FORMAT_TIME:
- *value = src->timestamp;
+ current = src->timestamp;
res = TRUE;
break;
case GST_FORMAT_DEFAULT: /* samples */
- *value = src->offset / 2; /* 16bpp audio */
+ current = src->offset / 2; /* 16bpp audio */
res = TRUE;
break;
case GST_FORMAT_BYTES:
- *value = src->offset;
+ current = src->offset;
res = TRUE;
break;
default:
break;
+
+ if (res) {
+ gst_query_set_position (query, format, current, -1);
+ }
}
break;
+ }
default:
break;
}
static void gst_subparse_class_init (GstSubparseClass * klass);
static void gst_subparse_init (GstSubparse * subparse);
+#if 0
static const GstFormat *gst_subparse_formats (GstPad * pad);
static const GstEventMask *gst_subparse_src_eventmask (GstPad * pad);
+#endif
static gboolean gst_subparse_src_event (GstPad * pad, GstEvent * event);
static GstElementStateReturn gst_subparse_change_state (GstElement * element);
subparse->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get (&src_templ),
"src");
- gst_pad_set_formats_function (subparse->srcpad, gst_subparse_formats);
gst_pad_set_event_function (subparse->srcpad, gst_subparse_src_event);
- gst_pad_set_event_mask_function (subparse->srcpad,
- gst_subparse_src_eventmask);
gst_element_add_pad (GST_ELEMENT (subparse), subparse->srcpad);
subparse->textbuf = g_string_new (NULL);
* Source pad functions.
*/
+#if 0
static const GstFormat *
gst_subparse_formats (GstPad * pad)
{
return masks;
}
+#endif
static gboolean
gst_subparse_src_event (GstPad * pad, GstEvent * event)
static void gst_videotestsrc_loop (GstPad * pad);
static const GstQueryType *gst_videotestsrc_get_query_types (GstPad * pad);
-static gboolean gst_videotestsrc_src_query (GstPad * pad,
- GstQueryType type, GstFormat * format, gint64 * value);
+static gboolean gst_videotestsrc_src_query (GstPad * pad, GstQuery * query);
+
+#if 0
static const GstEventMask *gst_videotestsrc_get_event_masks (GstPad * pad);
+#endif
static gboolean gst_videotestsrc_handle_src_event (GstPad * pad,
GstEvent * event);
gst_pad_set_query_function (videotestsrc->srcpad, gst_videotestsrc_src_query);
gst_pad_set_query_type_function (videotestsrc->srcpad,
gst_videotestsrc_get_query_types);
- gst_pad_set_event_mask_function (videotestsrc->srcpad,
- gst_videotestsrc_get_event_masks);
gst_pad_set_event_function (videotestsrc->srcpad,
gst_videotestsrc_handle_src_event);
}
static gboolean
-gst_videotestsrc_src_query (GstPad * pad,
- GstQueryType type, GstFormat * format, gint64 * value)
+gst_videotestsrc_src_query (GstPad * pad, GstQuery * query)
{
gboolean res = FALSE;
GstVideotestsrc *videotestsrc = GST_VIDEOTESTSRC (GST_PAD_PARENT (pad));
- switch (type) {
+ switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
- switch (*format) {
+ {
+ GstFormat format;
+ gint64 current;
+
+ gst_query_parse_position (query, &format, NULL, NULL);
+
+ switch (format) {
case GST_FORMAT_TIME:
- *value = videotestsrc->running_time;
+ current = videotestsrc->running_time;
res = TRUE;
break;
case GST_FORMAT_DEFAULT: /* frames */
- *value = videotestsrc->n_frames;
+ current = videotestsrc->n_frames;
res = TRUE;
break;
default:
break;
}
+ if (res) {
+ gst_query_set_position (query, format, current, -1);
+ }
break;
+ }
default:
break;
}
return res;
}
+#if 0
static const GstEventMask *
gst_videotestsrc_get_event_masks (GstPad * pad)
{
return src_event_masks;
}
+#endif
static gboolean
gst_videotestsrc_handle_src_event (GstPad * pad, GstEvent * event)
static void
paint_hline_I420 (paintinfo * p, int x, int y, int w)
{
+#ifdef oil_splat_u8_ns
int x1 = x / 2;
int x2 = (x + w) / 2;
int offset = y * p->ystride;
oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+#endif
}
static void
static void
paint_hline_Y41B (paintinfo * p, int x, int y, int w)
{
+#ifdef oil_splat_u8_ns
int x1 = x / 4;
int x2 = (x + w) / 4;
int offset = y * p->ystride;
oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+#endif
}
static void
static void
paint_hline_Y42B (paintinfo * p, int x, int y, int w)
{
+#ifdef oil_splat_u8_ns
int x1 = x / 2;
int x2 = (x + w) / 2;
int offset = y * p->ystride;
oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+#endif
}
static void
static void
paint_hline_Y800 (paintinfo * p, int x, int y, int w)
{
+#ifdef oil_splat_u8_ns
int offset = y * p->ystride;
oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
+#endif
}
#if 0
static void
paint_hline_YUV9 (paintinfo * p, int x, int y, int w)
{
+#ifdef oil_splat_u8_ns
int x1 = x / 4;
int x2 = (x + w) / 4;
int offset = y * p->ystride;
oil_splat_u8_ns (p->yp + offset + x, &p->color->Y, w);
oil_splat_u8_ns (p->up + offset1 + x1, &p->color->U, x2 - x1);
oil_splat_u8_ns (p->vp + offset1 + x1, &p->color->V, x2 - x1);
+#endif
}
static void
ximagesink = GST_XIMAGESINK (bsink);
-#if 0
- if (GST_IS_EVENT (data)) {
- gst_pad_event_default (pad, GST_EVENT (data));
- return;
- }
-#endif
-
g_mutex_lock (ximagesink->stream_lock);
-#if 0
- /* update time */
- if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
- ximagesink->time = GST_BUFFER_TIMESTAMP (buf);
- }
- GST_LOG_OBJECT (ximagesink, "clock wait: %" GST_TIME_FORMAT,
- GST_TIME_ARGS (ximagesink->time));
-#endif
-
- /* FIXME */
-#if 0
- if (GST_VIDEOSINK_CLOCK (ximagesink)) {
- gst_element_wait (GST_ELEMENT (ximagesink), ximagesink->time);
- }
-#endif
-
/* If this buffer has been allocated using our buffer management we simply
put the ximage which is in the PRIVATE pointer */
if (GST_BUFFER_FREE_DATA_FUNC (buf) == gst_ximagesink_buffer_free) {
gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage);
}
-#if 0
- /* set correct time for next buffer */
- if (!GST_BUFFER_TIMESTAMP_IS_VALID (buf) && ximagesink->framerate > 0) {
- ximagesink->time += GST_SECOND / ximagesink->framerate;
- }
-#endif
-
gst_ximagesink_handle_xevents (ximagesink);
#if 0
gst_ximagesink_send_pending_navigation (ximagesink);
static GList *seekable_elements = NULL;
static GstElement *pipeline;
-static guint64 duration;
+static gint64 position;
+static gint64 duration;
static GtkAdjustment *adjustment;
static GtkWidget *hscale;
static gboolean stats = FALSE;
#define SOURCE "gnomevfssrc"
#define ASINK "alsasink"
//#define ASINK "osssink"
+#define VSINK "xvimagesink"
+//#define VSINK "ximagesink"
+//#define VSINK "aasink"
#define UPDATE_INTERVAL 500
queue = gst_element_factory_make_or_warn ("queue", "queue");
decoder = gst_element_factory_make_or_warn ("theoradec", "decoder");
convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "convert");
- videosink = gst_element_factory_make_or_warn ("xvimagesink", "sink");
+ videosink = gst_element_factory_make_or_warn (VSINK, "sink");
g_object_set (G_OBJECT (src), "location", location, NULL);
v_decoder = gst_element_factory_make_or_warn ("theoradec", "v_dec");
v_convert =
gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert");
- videosink = gst_element_factory_make_or_warn ("xvimagesink", "v_sink");
+ videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
gst_bin_add (GST_BIN (video_bin), v_queue);
v_decoder = gst_element_factory_make_or_warn ("ffdec_msmpeg4", "v_dec");
v_convert =
gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert");
- videosink = gst_element_factory_make_or_warn ("xvimagesink", "v_sink");
+ videosink = gst_element_factory_make_or_warn (VSINK, "v_sink");
gst_element_link_many (v_queue, v_decoder, v_convert, videosink, NULL);
gst_bin_add (GST_BIN (video_bin), v_queue);
format = seek_formats[i].format;
- if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
+ if (gst_pad_query_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format,
+ &value)) {
g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
G_GNUC_UNUSED static void
-query_durations_elems ()
-{
- GList *walk = seekable_elements;
-
- while (walk) {
- GstElement *element = GST_ELEMENT (walk->data);
- gint i = 0;
-
- g_print ("durations %8.8s: ", GST_ELEMENT_NAME (element));
- while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
- GstFormat format;
-
- format = seek_formats[i].format;
- res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
- } else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
- }
- i++;
- }
- g_print (" %s\n", GST_ELEMENT_NAME (element));
-
- walk = g_list_next (walk);
- }
-}
-
-G_GNUC_UNUSED static void
-query_durations_pads ()
-{
- GList *walk = seekable_pads;
-
- while (walk) {
- GstPad *pad = GST_PAD (walk->data);
- gint i = 0;
-
- g_print ("durations %8.8s: ", GST_PAD_NAME (pad));
- while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
- GstFormat format;
-
- format = seek_formats[i].format;
- res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
- } else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
- }
- i++;
- }
- g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
-
- walk = g_list_next (walk);
- }
-}
-
-G_GNUC_UNUSED static void
query_positions_elems ()
{
GList *walk = seekable_elements;
g_print ("positions %8.8s: ", GST_ELEMENT_NAME (element));
while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
+ gint64 position, total;
GstFormat format;
format = seek_formats[i].format;
- res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
+
+ if (gst_element_query_position (element, &format, &position, &total)) {
+ g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
+ seek_formats[i].name, position, total);
} else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
+ "*NA*");
}
i++;
}
g_print ("positions %8.8s: ", GST_PAD_NAME (pad));
while (seek_formats[i].name) {
- gboolean res;
- gint64 value;
GstFormat format;
+ gint64 position, total;
format = seek_formats[i].format;
- res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
- if (res) {
- g_print ("%s %13" G_GINT64_FORMAT " | ", seek_formats[i].name, value);
+
+ if (gst_pad_query_position (pad, &format, &position, &total)) {
+ g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
+ seek_formats[i].name, position, total);
} else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
+ "*NA*");
}
+
i++;
}
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
update_scale (gpointer data)
{
GstClock *clock;
- guint64 position;
- GstFormat format = GST_FORMAT_TIME;
- gboolean res;
+ GstFormat format;
+ position = 0;
duration = 0;
clock = gst_pipeline_get_clock (GST_PIPELINE (pipeline));
+ format = GST_FORMAT_TIME;
+
if (elem_seek) {
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
- res = gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
- if (!res)
- duration = 0;
- res = gst_element_query (element, GST_QUERY_POSITION, &format, &position);
- if (!res)
- position = 0;
+ gst_element_query_position (element, &format, &position, &duration);
}
} else {
if (seekable_pads) {
GstPad *pad = GST_PAD (seekable_pads->data);
- res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration);
- if (!res)
- duration = 0;
- res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position);
- if (!res)
- position = 0;
+ gst_pad_query_position (pad, &format, &position, &duration);
}
}
}
if (elem_seek) {
- query_durations_elems ();
query_positions_elems ();
} else {
- query_durations_pads ();
query_positions_pads ();
}
query_rates ();
gst_element_get_state (pipeline, &state, NULL, NULL);
if (state != GST_STATE_PLAYING) {
+ g_print ("PLAY pipeline\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
update_id =
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
gst_element_get_state (pipeline, &state, NULL, NULL);
if (state != GST_STATE_PAUSED) {
+ g_print ("PAUSE pipeline\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
}
gst_element_get_state (pipeline, &state, NULL, NULL);
if (state != GST_STATE_READY) {
+ g_print ("READY pipeline\n");
gst_element_set_state (pipeline, GST_STATE_READY);
gtk_adjustment_set_value (adjustment, 0.0);
gtk_timeout_remove (update_id);
}
gtk_main ();
+ g_print ("NULL pipeline\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
+ g_print ("free pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;