mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
Port to new query API.
Original commit message from CVS: Port to new query API. Updated seek. Cleanups in x[v]imagesink
This commit is contained in:
parent
276f6fe559
commit
0ba57f5816
16 changed files with 534 additions and 425 deletions
51
ChangeLog
51
ChangeLog
|
@ -1,3 +1,54 @@
|
|||
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:
|
||||
|
|
|
@ -9,7 +9,8 @@ static GList *rate_pads = NULL;
|
|||
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;
|
||||
|
@ -24,6 +25,9 @@ static gulong changed_id;
|
|||
#define SOURCE "gnomevfssrc"
|
||||
#define ASINK "alsasink"
|
||||
//#define ASINK "osssink"
|
||||
#define VSINK "xvimagesink"
|
||||
//#define VSINK "ximagesink"
|
||||
//#define VSINK "aasink"
|
||||
|
||||
#define UPDATE_INTERVAL 500
|
||||
|
||||
|
@ -334,7 +338,7 @@ make_theora_pipeline (const gchar * location)
|
|||
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);
|
||||
|
||||
|
@ -407,7 +411,7 @@ make_vorbis_theora_pipeline (const gchar * location)
|
|||
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);
|
||||
|
@ -472,7 +476,7 @@ make_avi_msmpeg4v3_mp3_pipeline (const gchar * location)
|
|||
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);
|
||||
|
@ -794,7 +798,8 @@ query_rates (void)
|
|||
|
||||
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*");
|
||||
|
@ -808,66 +813,6 @@ query_rates (void)
|
|||
}
|
||||
}
|
||||
|
||||
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 ()
|
||||
{
|
||||
|
@ -879,16 +824,17 @@ query_positions_elems ()
|
|||
|
||||
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++;
|
||||
}
|
||||
|
@ -909,17 +855,19 @@ query_positions_pads ()
|
|||
|
||||
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));
|
||||
|
@ -932,34 +880,25 @@ static gboolean
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -970,10 +909,8 @@ update_scale (gpointer data)
|
|||
}
|
||||
|
||||
if (elem_seek) {
|
||||
query_durations_elems ();
|
||||
query_positions_elems ();
|
||||
} else {
|
||||
query_durations_pads ();
|
||||
query_positions_pads ();
|
||||
}
|
||||
query_rates ();
|
||||
|
@ -1107,6 +1044,7 @@ play_cb (GtkButton * button, gpointer data)
|
|||
|
||||
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);
|
||||
|
@ -1120,6 +1058,7 @@ pause_cb (GtkButton * button, gpointer data)
|
|||
|
||||
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);
|
||||
}
|
||||
|
@ -1132,6 +1071,7 @@ stop_cb (GtkButton * button, gpointer data)
|
|||
|
||||
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);
|
||||
|
@ -1260,8 +1200,10 @@ main (int argc, char **argv)
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -186,14 +186,13 @@ static void gst_ogg_pad_class_init (GstOggPadClass * klass);
|
|||
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);
|
||||
|
@ -243,16 +242,10 @@ gst_ogg_pad_init (GstOggPad * pad)
|
|||
{
|
||||
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));
|
||||
|
||||
|
@ -304,6 +297,7 @@ gst_ogg_pad_finalize (GObject * object)
|
|||
G_OBJECT_CLASS (ogg_pad_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
gst_ogg_pad_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -320,7 +314,9 @@ 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)
|
||||
{
|
||||
|
@ -331,13 +327,13 @@ 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
|
||||
};
|
||||
|
||||
|
@ -351,23 +347,7 @@ gst_ogg_pad_getcaps (GstPad * pad)
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -376,12 +356,13 @@ gst_ogg_pad_src_query (GstPad * pad, GstQueryType type,
|
|||
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;
|
||||
|
@ -940,7 +921,6 @@ gst_ogg_demux_init (GstOggDemux * ogg)
|
|||
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);
|
||||
|
@ -1327,7 +1307,7 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gint64 pos)
|
|||
} else {
|
||||
gint64 granulepos;
|
||||
GstClockTime granuletime;
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
GstFormat format;
|
||||
GstOggPad *pad;
|
||||
|
||||
granulepos = ogg_page_granulepos (&og);
|
||||
|
@ -1338,8 +1318,13 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gint64 pos)
|
|||
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 %"
|
||||
|
@ -1575,11 +1560,14 @@ gst_ogg_demux_read_chain (GstOggDemux * ogg)
|
|||
/* 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;
|
||||
|
@ -1637,11 +1625,14 @@ gst_ogg_demux_read_end_chain (GstOggDemux * ogg, GstOggChain * chain)
|
|||
/* 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;
|
||||
}
|
||||
|
|
|
@ -240,6 +240,7 @@ gst_ogg_mux_class_init (GstOggMuxClass * klass)
|
|||
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *
|
||||
gst_ogg_mux_get_sink_event_masks (GstPad * pad)
|
||||
{
|
||||
|
@ -251,6 +252,7 @@ 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)
|
||||
|
@ -353,7 +355,6 @@ gst_ogg_mux_request_new_pad (GstElement * element,
|
|||
|
||||
/* 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);
|
||||
|
||||
|
|
|
@ -140,12 +140,14 @@ static void gst_ogm_video_parse_init (GstOgmParse * ogm);
|
|||
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);
|
||||
|
||||
|
@ -343,8 +345,7 @@ gst_ogm_audio_parse_init (GstOgmParse * ogm)
|
|||
/* 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);
|
||||
|
||||
|
@ -364,8 +365,7 @@ gst_ogm_video_parse_init (GstOgmParse * ogm)
|
|||
/* 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);
|
||||
|
||||
|
@ -385,8 +385,6 @@ gst_ogm_text_parse_init (GstOgmParse * ogm)
|
|||
/* 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);
|
||||
|
@ -401,6 +399,7 @@ gst_ogm_text_parse_init (GstOgmParse * ogm)
|
|||
ogm->srcpadtempl = text_src_templ;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
gst_ogm_parse_get_sink_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -412,6 +411,7 @@ gst_ogm_parse_get_sink_formats (GstPad * pad)
|
|||
|
||||
return formats;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const GstQueryType *
|
||||
gst_ogm_parse_get_sink_querytypes (GstPad * pad)
|
||||
|
@ -485,18 +485,47 @@ gst_ogm_parse_sink_convert (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;
|
||||
|
||||
if (type != GST_QUERY_POSITION)
|
||||
return FALSE;
|
||||
if (*fmt != GST_FORMAT_DEFAULT && *fmt != GST_FORMAT_TIME)
|
||||
return FALSE;
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
gint64 val;
|
||||
|
||||
return gst_pad_convert (pad,
|
||||
GST_FORMAT_DEFAULT, ogm->next_granulepos, fmt, val);
|
||||
gst_query_parse_position (query, &format, NULL, NULL);
|
||||
|
||||
if (format != GST_FORMAT_DEFAULT && format != GST_FORMAT_TIME)
|
||||
return FALSE;
|
||||
|
||||
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
|
||||
|
|
|
@ -115,16 +115,21 @@ static gboolean theora_dec_sink_event (GstPad * pad, GstEvent * event);
|
|||
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);
|
||||
|
||||
|
||||
|
@ -165,8 +170,7 @@ gst_theora_dec_init (GstTheoraDec * dec)
|
|||
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);
|
||||
|
@ -174,12 +178,9 @@ gst_theora_dec_init (GstTheoraDec * dec)
|
|||
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);
|
||||
|
||||
|
@ -221,6 +222,7 @@ _inc_granulepos (GstTheoraDec * dec)
|
|||
dec->granulepos = (framecount << ilog);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
theora_get_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -238,7 +240,9 @@ 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)
|
||||
{
|
||||
|
@ -249,6 +253,7 @@ theora_get_event_masks (GstPad * pad)
|
|||
|
||||
return theora_src_event_masks;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const GstQueryType *
|
||||
theora_get_query_types (GstPad * pad)
|
||||
|
@ -278,6 +283,11 @@ theora_dec_src_convert (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) {
|
||||
|
@ -339,6 +349,11 @@ theora_dec_sink_convert (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_DEFAULT:
|
||||
{
|
||||
|
@ -395,36 +410,98 @@ theora_dec_sink_convert (GstPad * pad,
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (dec,
|
||||
"query %u: peer returned granulepos: %llu - we return %llu (format %u)",
|
||||
query, granulepos, *value, *format);
|
||||
static gboolean
|
||||
theora_dec_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
return TRUE;
|
||||
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;
|
||||
}
|
||||
|
||||
error:
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -448,9 +525,8 @@ theora_dec_src_event (GstPad * pad, GstEvent * event)
|
|||
* 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 */
|
||||
|
|
|
@ -75,15 +75,18 @@ GST_BOILERPLATE (GstVorbisDec, gst_vorbis_dec, GstElement, GST_TYPE_ELEMENT);
|
|||
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)
|
||||
|
@ -105,6 +108,7 @@ gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
|
|||
gstelement_class->change_state = vorbis_dec_change_state;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
vorbis_dec_get_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -123,7 +127,9 @@ 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)
|
||||
{
|
||||
|
@ -134,6 +140,7 @@ vorbis_get_event_masks (GstPad * pad)
|
|||
|
||||
return vorbis_dec_src_event_masks;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const GstQueryType *
|
||||
vorbis_get_query_types (GstPad * pad)
|
||||
|
@ -155,19 +162,15 @@ gst_vorbis_dec_init (GstVorbisDec * dec)
|
|||
(&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);
|
||||
}
|
||||
|
||||
|
@ -185,6 +188,11 @@ vorbis_dec_convert (GstPad * pad,
|
|||
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;
|
||||
|
@ -234,27 +242,94 @@ vorbis_dec_convert (GstPad * pad,
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -269,7 +344,7 @@ vorbis_dec_src_event (GstPad * pad, GstEvent * event)
|
|||
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 (
|
||||
|
|
|
@ -74,6 +74,7 @@ vorbis_granule_time_copy (vorbis_dsp_state * v, ogg_int64_t granulepos)
|
|||
return (-1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
gst_vorbisenc_get_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -91,6 +92,7 @@ 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
|
||||
|
@ -374,17 +376,17 @@ gst_vorbisenc_get_query_types (GstPad * pad)
|
|||
}
|
||||
|
||||
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:
|
||||
|
@ -408,10 +410,10 @@ gst_vorbisenc_src_query (GstPad * pad, GstQueryType type,
|
|||
|
||||
/* 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++;
|
||||
|
@ -422,23 +424,60 @@ gst_vorbisenc_src_query (GstPad * pad, GstQueryType type,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -451,10 +490,8 @@ gst_vorbisenc_init (VorbisEnc * vorbisenc)
|
|||
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");
|
||||
|
@ -462,10 +499,6 @@ gst_vorbisenc_init (VorbisEnc * vorbisenc)
|
|||
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;
|
||||
|
|
|
@ -108,16 +108,10 @@ static void gst_play_bin_get_property (GObject * object, guint prop_id,
|
|||
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;
|
||||
|
@ -206,11 +200,7 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
|
|||
|
||||
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);
|
||||
|
@ -862,12 +852,14 @@ gst_play_bin_change_state (GstElement * element)
|
|||
}
|
||||
|
||||
|
||||
#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
|
||||
|
@ -908,6 +900,7 @@ gst_play_bin_send_event (GstElement * element, GstEvent * event)
|
|||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
gst_play_bin_get_formats (GstElement * element)
|
||||
{
|
||||
|
@ -919,30 +912,7 @@ 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)
|
||||
|
@ -958,8 +928,7 @@ 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;
|
||||
|
@ -970,7 +939,7 @@ gst_play_bin_query (GstElement * element, GstQueryType type,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ update_scale (GstElement * element)
|
|||
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);
|
||||
|
||||
|
|
|
@ -86,8 +86,7 @@ static void gst_sinesrc_populate_sinetable (GstSineSrc * src);
|
|||
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);
|
||||
|
@ -264,33 +263,43 @@ gst_sinesrc_get_query_types (GstPad * pad)
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,10 @@ static void gst_subparse_base_init (GstSubparseClass * klass);
|
|||
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);
|
||||
|
@ -131,10 +133,7 @@ gst_subparse_init (GstSubparse * subparse)
|
|||
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);
|
||||
|
@ -145,6 +144,7 @@ gst_subparse_init (GstSubparse * subparse)
|
|||
* Source pad functions.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static const GstFormat *
|
||||
gst_subparse_formats (GstPad * pad)
|
||||
{
|
||||
|
@ -166,6 +166,7 @@ gst_subparse_src_eventmask (GstPad * pad)
|
|||
|
||||
return masks;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_subparse_src_event (GstPad * pad, GstEvent * event)
|
||||
|
|
|
@ -72,9 +72,11 @@ static void gst_videotestsrc_get_property (GObject * object, guint prop_id,
|
|||
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);
|
||||
|
||||
|
@ -460,8 +462,6 @@ gst_videotestsrc_init (GstVideotestsrc * videotestsrc)
|
|||
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);
|
||||
|
||||
|
@ -491,27 +491,36 @@ gst_videotestsrc_get_query_types (GstPad * pad)
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -519,6 +528,7 @@ gst_videotestsrc_src_query (GstPad * pad,
|
|||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static const GstEventMask *
|
||||
gst_videotestsrc_get_event_masks (GstPad * pad)
|
||||
{
|
||||
|
@ -529,6 +539,7 @@ gst_videotestsrc_get_event_masks (GstPad * pad)
|
|||
|
||||
return src_event_masks;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_videotestsrc_handle_src_event (GstPad * pad, GstEvent * event)
|
||||
|
|
|
@ -698,6 +698,7 @@ paint_setup_I420 (paintinfo * p, unsigned char *dest)
|
|||
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;
|
||||
|
@ -706,6 +707,7 @@ paint_hline_I420 (paintinfo * p, int x, int y, int w)
|
|||
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
|
||||
|
@ -800,6 +802,7 @@ paint_setup_Y41B (paintinfo * p, unsigned char *dest)
|
|||
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;
|
||||
|
@ -808,6 +811,7 @@ paint_hline_Y41B (paintinfo * p, int x, int y, int w)
|
|||
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
|
||||
|
@ -825,6 +829,7 @@ paint_setup_Y42B (paintinfo * p, unsigned char *dest)
|
|||
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;
|
||||
|
@ -833,6 +838,7 @@ paint_hline_Y42B (paintinfo * p, int x, int y, int w)
|
|||
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
|
||||
|
@ -847,9 +853,11 @@ paint_setup_Y800 (paintinfo * p, unsigned char *dest)
|
|||
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
|
||||
|
@ -931,6 +939,7 @@ paint_setup_YUV9 (paintinfo * p, unsigned char *dest)
|
|||
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;
|
||||
|
@ -939,6 +948,7 @@ paint_hline_YUV9 (paintinfo * p, int x, int y, int w)
|
|||
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
|
||||
|
|
|
@ -1129,31 +1129,8 @@ gst_ximagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
|
|||
|
||||
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) {
|
||||
|
@ -1182,13 +1159,6 @@ gst_ximagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
|
|||
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);
|
||||
|
|
|
@ -9,7 +9,8 @@ static GList *rate_pads = NULL;
|
|||
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;
|
||||
|
@ -24,6 +25,9 @@ static gulong changed_id;
|
|||
#define SOURCE "gnomevfssrc"
|
||||
#define ASINK "alsasink"
|
||||
//#define ASINK "osssink"
|
||||
#define VSINK "xvimagesink"
|
||||
//#define VSINK "ximagesink"
|
||||
//#define VSINK "aasink"
|
||||
|
||||
#define UPDATE_INTERVAL 500
|
||||
|
||||
|
@ -334,7 +338,7 @@ make_theora_pipeline (const gchar * location)
|
|||
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);
|
||||
|
||||
|
@ -407,7 +411,7 @@ make_vorbis_theora_pipeline (const gchar * location)
|
|||
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);
|
||||
|
@ -472,7 +476,7 @@ make_avi_msmpeg4v3_mp3_pipeline (const gchar * location)
|
|||
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);
|
||||
|
@ -794,7 +798,8 @@ query_rates (void)
|
|||
|
||||
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*");
|
||||
|
@ -808,66 +813,6 @@ query_rates (void)
|
|||
}
|
||||
}
|
||||
|
||||
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 ()
|
||||
{
|
||||
|
@ -879,16 +824,17 @@ query_positions_elems ()
|
|||
|
||||
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++;
|
||||
}
|
||||
|
@ -909,17 +855,19 @@ query_positions_pads ()
|
|||
|
||||
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));
|
||||
|
@ -932,34 +880,25 @@ static gboolean
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -970,10 +909,8 @@ update_scale (gpointer data)
|
|||
}
|
||||
|
||||
if (elem_seek) {
|
||||
query_durations_elems ();
|
||||
query_positions_elems ();
|
||||
} else {
|
||||
query_durations_pads ();
|
||||
query_positions_pads ();
|
||||
}
|
||||
query_rates ();
|
||||
|
@ -1107,6 +1044,7 @@ play_cb (GtkButton * button, gpointer data)
|
|||
|
||||
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);
|
||||
|
@ -1120,6 +1058,7 @@ pause_cb (GtkButton * button, gpointer data)
|
|||
|
||||
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);
|
||||
}
|
||||
|
@ -1132,6 +1071,7 @@ stop_cb (GtkButton * button, gpointer data)
|
|||
|
||||
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);
|
||||
|
@ -1260,8 +1200,10 @@ main (int argc, char **argv)
|
|||
}
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue