Commit 28784508 authored by Ronald S. Bultje's avatar Ronald S. Bultje

examples/gstplay/player.c: Don't iterate.

Original commit message from CVS:
* examples/gstplay/player.c: (main):
Don't iterate.
* examples/seeking/seek.c: (fixate), (make_playerbin_pipeline):
Add visualizations.
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_frame):
Set duration.
* ext/dvdnav/gst-dvd:
Add audioconvert. Fixes #161325.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_get):
Explicitely case to gint64. Possible valgrind error.
* gst-libs/gst/play/play.c: (caps_set), (setup_size),
(gst_play_tick_callback), (gst_play_change_state),
(gst_play_dispose), (gst_play_init), (gst_play_class_init),
(gst_play_set_location), (gst_play_get_location),
(gst_play_seek_to_time), (gst_play_set_data_src),
(gst_play_set_video_sink), (gst_play_set_audio_sink),
(gst_play_set_visualization), (gst_play_connect_visualization),
(gst_play_get_framerate), (gst_play_get_all_by_interface),
(gst_play_new):
Use playbin. Fixes #139749 and #147744.
* gst/apetag/apedemux.c: (gst_ape_demux_parse_tags):
Add genre tag.
* gst/audioscale/gstaudioscale.c: (gst_audioscale_method_get_type),
(audioscale_get_type), (gst_audioscale_base_init),
(gst_audioscale_class_init), (gst_audioscale_expand_caps),
(gst_audioscale_getcaps), (gst_audioscale_fixate),
(gst_audioscale_link), (gst_audioscale_get_buffer),
(gst_audioscale_decrease_rate), (gst_audioscale_increase_rate),
(gst_audioscale_init), (gst_audioscale_dispose),
(gst_audioscale_chain), (gst_audioscale_set_property),
(gst_audioscale_get_property), (plugin_init):
Indent properly.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_process_private):
Fix LPCM.
* gst/qtdemux/qtdemux.c: (qtdemux_parse_udta),
(qtdemux_tag_add_str), (qtdemux_tag_add_num),
(qtdemux_tag_add_gnre), (qtdemux_video_caps):
Add more metadata (fixes #162656).
parent 8e60b18b
2005-01-05 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* examples/gstplay/player.c: (main):
Don't iterate.
* examples/seeking/seek.c: (fixate), (make_playerbin_pipeline):
Add visualizations.
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_frame):
Set duration.
* ext/dvdnav/gst-dvd:
Add audioconvert. Fixes #161325.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_get):
Explicitely case to gint64. Possible valgrind error.
* gst-libs/gst/play/play.c: (caps_set), (setup_size),
(gst_play_tick_callback), (gst_play_change_state),
(gst_play_dispose), (gst_play_init), (gst_play_class_init),
(gst_play_set_location), (gst_play_get_location),
(gst_play_seek_to_time), (gst_play_set_data_src),
(gst_play_set_video_sink), (gst_play_set_audio_sink),
(gst_play_set_visualization), (gst_play_connect_visualization),
(gst_play_get_framerate), (gst_play_get_all_by_interface),
(gst_play_new):
Use playbin. Fixes #139749 and #147744.
* gst/apetag/apedemux.c: (gst_ape_demux_parse_tags):
Add genre tag.
* gst/audioscale/gstaudioscale.c: (gst_audioscale_method_get_type),
(audioscale_get_type), (gst_audioscale_base_init),
(gst_audioscale_class_init), (gst_audioscale_expand_caps),
(gst_audioscale_getcaps), (gst_audioscale_fixate),
(gst_audioscale_link), (gst_audioscale_get_buffer),
(gst_audioscale_decrease_rate), (gst_audioscale_increase_rate),
(gst_audioscale_init), (gst_audioscale_dispose),
(gst_audioscale_chain), (gst_audioscale_set_property),
(gst_audioscale_get_property), (plugin_init):
Indent properly.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_process_private):
Fix LPCM.
* gst/qtdemux/qtdemux.c: (qtdemux_parse_udta),
(qtdemux_tag_add_str), (qtdemux_tag_add_num),
(qtdemux_tag_add_gnre), (qtdemux_video_caps):
Add more metadata (fixes #162656).
2005-01-05 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:
......
......@@ -90,13 +90,6 @@ seek_timer (GstPlay * play)
return FALSE;
}
static gboolean
idle_iterate (GstPlay * play)
{
gst_bin_iterate (GST_BIN (play));
return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING);
}
int
main (int argc, char *argv[])
{
......@@ -168,7 +161,6 @@ main (int argc, char *argv[])
GST_STATE_PLAYING) == GST_STATE_FAILURE)
g_error ("Could not set state to PLAYING");
g_idle_add ((GSourceFunc) idle_iterate, play);
g_timeout_add (20000, (GSourceFunc) seek_timer, play);
g_main_loop_run (loop);
......
......@@ -551,15 +551,45 @@ make_mpegnt_pipeline (const gchar * location)
return pipeline;
}
static GstCaps *
fixate (GstPad * pad, const GstCaps * in_caps, gpointer data)
{
GstCaps *caps;
GstStructure *s;
if (gst_caps_get_size (in_caps) > 1)
return NULL;
/* nothing if fixed already */
s = gst_caps_get_structure (in_caps, 0);
if (gst_structure_has_field_typed (s, "width", G_TYPE_INT) &&
gst_structure_has_field_typed (s, "height", G_TYPE_INT) &&
gst_structure_has_field_typed (s, "framerate", G_TYPE_DOUBLE))
return NULL;
/* fixate */
caps = gst_caps_copy (in_caps);
s = gst_caps_get_structure (caps, 0);
gst_caps_structure_fixate_field_nearest_int (s, "width", 200);
gst_caps_structure_fixate_field_nearest_int (s, "height", 150);
gst_caps_structure_fixate_field_nearest_double (s, "framerate", 10.0);
return caps;
}
static GstElement *
make_playerbin_pipeline (const gchar * location)
{
GstElement *player;
GstElement *player, *vis;
player = gst_element_factory_make ("playbin", "player");
vis = gst_element_factory_make ("synaesthesia", "vis");
g_assert (player);
g_assert (vis);
g_object_set (G_OBJECT (player), "uri", location, NULL);
g_signal_connect (gst_element_get_pad (vis, "src"), "fixate",
G_CALLBACK (fixate), NULL);
g_object_set (G_OBJECT (player), "uri", location, "vis-plugin", vis, NULL);
seekable_elements = g_list_prepend (seekable_elements, player);
......
......@@ -20,10 +20,13 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <unistd.h>
#include <gst/gst.h>
#include <gst/gst-i18n-plugin.h>
#include "play.h"
#include <gst/gst-i18n-plugin.h>
#define TICK_INTERVAL_MSEC 200
......@@ -40,26 +43,21 @@ enum
struct _GstPlayPrivate
{
char *location;
GHashTable *elements;
gint64 time_nanos;
gint64 length_nanos;
/* progress indicators */
guint64 time_nanos;
guint64 length_nanos;
gint get_length_attempt;
gint tick_unblock_remaining; /* how many msecs left
to unblock due to seeking */
guint tick_id;
guint length_id;
gulong handoff_hid;
/* playbin object */
GstElement *playbin;
/* error/debug handling */
GError *error;
gchar *debug;
/* visualization */
gboolean enable_vis;
GstElement *vis_element;
/* location */
char *location;
};
static guint gst_play_signals[LAST_SIGNAL] = { 0 };
......@@ -72,546 +70,130 @@ static GstPipelineClass *parent_class = NULL;
/* */
/* ======================================================= */
static GstCaps *gst_play_video_fixate (GstPad * pad, const GstCaps * caps,
gpointer user_data);
static GstCaps *gst_play_audio_fixate (GstPad * pad, const GstCaps * caps,
gpointer user_data);
static GQuark
gst_play_error_quark (void)
{
static GQuark quark = 0;
if (quark == 0)
quark = g_quark_from_static_string ("gst-play-error-quark");
return quark;
}
/* General GError creation */
static void
gst_play_error_create (GError ** error, const gchar * message)
{
/* check if caller wanted an error reported */
if (error == NULL)
return;
*error = g_error_new (GST_PLAY_ERROR, 0, message);
return;
}
/* GError creation when plugin is missing */
/* FIXME: what if multiple elements could have been used and they're all
* missing ? varargs ? */
static void
gst_play_error_plugin (const gchar * element, GError ** error)
{
gchar *message;
message = g_strdup_printf (_("The %s element could not be found. "
"This element is essential for playback. "
"Please install the right plug-in and verify "
"that it works by running 'gst-inspect %s'"), element, element);
gst_play_error_create (error, message);
g_free (message);
return;
}
#define GST_PLAY_MAKE_OR_ERROR(el, factory, name, error) \
G_STMT_START { \
el = gst_element_factory_make (factory, name); \
if (!GST_IS_ELEMENT (el)) { \
gst_play_error_plugin (factory, error); \
return FALSE; \
} \
} G_STMT_END
/* Create a colorspace element from the list of acceptable ones;
* set error and fail if none found. */
#define GST_PLAY_MAKE_CS_OR_ERROR(el, name, error) \
G_STMT_START { \
el = gst_element_factory_make ("ffmpegcolorspace", name); \
if (!GST_IS_ELEMENT (el)) \
el = gst_element_factory_make ("ffcolorspace", name); \
if (!GST_IS_ELEMENT (el)) \
el = gst_element_factory_make ("hermescolorspace", name); \
if (!GST_IS_ELEMENT (el)) { \
gst_play_error_create (error, \
_("No usable colorspace element could be found.\n" \
"Please install one and restart.")); \
return FALSE; \
} \
} G_STMT_END
#define GST_PLAY_ERROR_RETURN(error, message) \
G_STMT_START { \
gst_play_error_create (error, message); \
return FALSE; \
} G_STMT_END
#define GST_PLAY_HASH_LOOKUP(element, key, retval_if_fail) \
G_STMT_START { \
(element) = g_hash_table_lookup (play->priv->elements, (key));\
if (!element) \
return (retval_if_fail); \
} G_STMT_END
/* setup parts of the pipeline
* only put decoding part in the thread
* create all others and keep them around
*/
static gboolean
gst_play_pipeline_setup (GstPlay * play, GError ** error)
caps_set (GstPad * pad, GParamSpec * pspec, GstPlay * play)
{
/* Threads */
GstElement *work_thread, *audio_thread, *video_thread;
/* output bin */
GstElement *output_bin;
/* Main Thread elements */
GstElement *source, *autoplugger;
/* output bin elements */
GstElement *audioconvert, *volume, *tee, *identity;
GstElement *identity_cs;
/* Visualization bin */
GstElement *vis_bin, *vis_queue, *vis_element, *vis_cs;
/* Video Thread elements */
GstElement *video_queue, *video_switch, *video_cs, *video_balance;
GstElement *balance_cs, *video_scaler, *video_sink;
/* Audio Thread elements */
GstElement *audio_queue, *audio_sink;
/* Some useful pads */
GstPad *tee_pad1, *tee_pad2;
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
GST_DEBUG_OBJECT (play, "setting up pipeline");
/* Creating main thread and its elements */
{
GST_PLAY_MAKE_OR_ERROR (work_thread, "thread", "work_thread", error);
g_hash_table_insert (play->priv->elements, "work_thread", work_thread);
gst_bin_add (GST_BIN (play), work_thread);
/* Placeholder for datasrc */
GST_PLAY_MAKE_OR_ERROR (source, "fakesrc", "source", error);
g_hash_table_insert (play->priv->elements, "source", source);
/* Autoplugger */
GST_PLAY_MAKE_OR_ERROR (autoplugger, "spider", "autoplugger", error);
g_hash_table_insert (play->priv->elements, "autoplugger", autoplugger);
/* adding and linking */
gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, NULL);
if (!gst_element_link (source, autoplugger))
GST_PLAY_ERROR_RETURN (error, "Could not link source and autoplugger");
}
/* output bin */
{
GST_PLAY_MAKE_OR_ERROR (output_bin, "bin", "output_bin", error);
g_hash_table_insert (play->priv->elements, "output_bin", output_bin);
/* Make sure we convert audio to the needed format */
GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert",
error);
g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
/* Duplicate audio signal to audio sink and visualization thread */
GST_PLAY_MAKE_OR_ERROR (tee, "tee", "tee", error);
tee_pad1 = gst_element_get_request_pad (tee, "src%d");
tee_pad2 = gst_element_get_request_pad (tee, "src%d");
g_hash_table_insert (play->priv->elements, "tee_pad1", tee_pad1);
g_hash_table_insert (play->priv->elements, "tee_pad2", tee_pad2);
g_hash_table_insert (play->priv->elements, "tee", tee);
gst_bin_add_many (GST_BIN (output_bin), audioconvert, tee, NULL);
if (!gst_element_link (audioconvert, tee))
GST_PLAY_ERROR_RETURN (error, "Could not link audio thread elements");
/* identity ! colorspace ! switch */
GST_PLAY_MAKE_OR_ERROR (identity, "identity", "identity", error);
g_hash_table_insert (play->priv->elements, "identity", identity);
GST_PLAY_MAKE_CS_OR_ERROR (identity_cs, "identity_cs", error);
g_hash_table_insert (play->priv->elements, "identity_cs", identity_cs);
gst_bin_add_many (GST_BIN (output_bin), identity, identity_cs, NULL);
if (!gst_element_link (identity, identity_cs))
GST_PLAY_ERROR_RETURN (error, "Could not link work thread elements");
/* we ref the output bin so we can put it in and out the work_thread
* whenever we want */
gst_object_ref (GST_OBJECT (output_bin));
GST_DEBUG_OBJECT (play, "adding output bin to work thread in setup");
gst_bin_add (GST_BIN (work_thread), output_bin);
}
/* Visualization bin (note: it s not added to the pipeline yet) */
{
vis_bin = gst_bin_new ("vis_bin");
if (!GST_IS_ELEMENT (vis_bin)) {
gst_play_error_plugin ("bin", error);
return FALSE;
const GstCaps *caps = GST_PAD_CAPS (pad);
GstStructure *s = gst_caps_get_structure (caps, 0);
if (s) {
const GValue *par;
gint w, h;
/* get effective size */
gst_structure_get_int (s, "width", &w);
gst_structure_get_int (s, "height", &h);
if ((par = gst_structure_get_value (s, "pixel-aspect-ratio"))) {
gint num = gst_value_get_fraction_numerator (par),
den = gst_value_get_fraction_denominator (par);
if (num > den)
w *= (gfloat) num / den;
else
h *= (gfloat) den / num;
}
g_hash_table_insert (play->priv->elements, "vis_bin", vis_bin);
/* Buffer queue for video data */
GST_PLAY_MAKE_OR_ERROR (vis_queue, "queue", "vis_queue", error);
g_hash_table_insert (play->priv->elements, "vis_queue", vis_queue);
/* Visualization element placeholder */
GST_PLAY_MAKE_OR_ERROR (vis_element, "identity", "vis_element", error);
g_hash_table_insert (play->priv->elements, "vis_element", vis_element);
/* Colorspace conversion */
GST_PLAY_MAKE_CS_OR_ERROR (vis_cs, "vis_cs", error);
g_hash_table_insert (play->priv->elements, "vis_cs", vis_cs);
gst_bin_add_many (GST_BIN (vis_bin), vis_queue, vis_element, vis_cs, NULL);
if (!gst_element_link_many (vis_queue, vis_element, vis_cs, NULL))
GST_PLAY_ERROR_RETURN (error,
"Could not link visualisation thread elements");
gst_element_add_ghost_pad (vis_bin, gst_element_get_pad (vis_cs, "src"),
"src");
}
/* Creating our video output bin */
{
GST_PLAY_MAKE_OR_ERROR (video_thread, "thread", "video_thread", error);
g_hash_table_insert (play->priv->elements, "video_thread", video_thread);
gst_bin_add (GST_BIN (output_bin), video_thread);
/* Buffer queue for video data */
GST_PLAY_MAKE_OR_ERROR (video_queue, "queue", "video_queue", error);
g_hash_table_insert (play->priv->elements, "video_queue", video_queue);
GST_PLAY_MAKE_OR_ERROR (video_switch, "switch", "video_switch", error);
g_hash_table_insert (play->priv->elements, "video_switch", video_switch);
/* Colorspace conversion */
GST_PLAY_MAKE_CS_OR_ERROR (video_cs, "video_cs", error);
g_hash_table_insert (play->priv->elements, "video_cs", video_cs);
/* Software colorbalance */
GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance",
error);
g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
/* Colorspace conversion */
GST_PLAY_MAKE_CS_OR_ERROR (balance_cs, "balance_cs", error);
g_hash_table_insert (play->priv->elements, "balance_cs", balance_cs);
/* Software scaling of video stream */
GST_PLAY_MAKE_OR_ERROR (video_scaler, "videoscale", "video_scaler", error);
g_hash_table_insert (play->priv->elements, "video_scaler", video_scaler);
g_signal_connect (gst_element_get_pad (video_scaler, "src"), "fixate",
G_CALLBACK (gst_play_video_fixate), play);
/* Placeholder for future video sink bin */
GST_PLAY_MAKE_OR_ERROR (video_sink, "fakesink", "video_sink", error);
g_hash_table_insert (play->priv->elements, "video_sink", video_sink);
gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch,
video_cs, video_balance, balance_cs, video_scaler, video_sink, NULL);
/* break down linking so we can figure out what might be failing */
if (!gst_element_link (video_queue, video_switch))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (queue and switch)");
if (!gst_element_link (video_switch, video_cs))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (switch and cs)");
if (!gst_element_link (video_cs, video_balance))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (cs and balance)");
if (!gst_element_link (video_balance, balance_cs))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (balance and balance_cs)");
if (!gst_element_link (balance_cs, video_scaler))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (balance_cs and scaler)");
if (!gst_element_link (video_scaler, video_sink))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread (balance_cs and scaler)");
gst_element_add_ghost_pad (video_thread, gst_element_get_pad (video_queue,
"sink"), "sink");
if (!gst_element_link (identity_cs, video_thread))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread elements");
g_signal_emit (play, gst_play_signals[HAVE_VIDEO_SIZE], 0, w, h);
g_signal_handlers_disconnect_by_func (pad, caps_set, play);
}
/* Creating our audio output bin
{ queue ! fakesink } */
{
GST_PLAY_MAKE_OR_ERROR (audio_thread, "thread", "audio_thread", error);
g_hash_table_insert (play->priv->elements, "audio_thread", audio_thread);
gst_bin_add (GST_BIN (output_bin), audio_thread);
/* Buffer queue for our audio thread */
GST_PLAY_MAKE_OR_ERROR (audio_queue, "queue", "audio_queue", error);
g_hash_table_insert (play->priv->elements, "audio_queue", audio_queue);
/* Volume control */
GST_PLAY_MAKE_OR_ERROR (volume, "volume", "volume", error);
g_hash_table_insert (play->priv->elements, "volume", volume);
g_signal_connect (gst_element_get_pad (volume, "src"), "fixate",
G_CALLBACK (gst_play_audio_fixate), play);
/* Placeholder for future audio sink bin */
GST_PLAY_MAKE_OR_ERROR (audio_sink, "fakesink", "audio_sink", error);
g_hash_table_insert (play->priv->elements, "audio_sink", audio_sink);
gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink,
NULL);
if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
GST_PLAY_ERROR_RETURN (error,
"Could not link audio output thread elements");
gst_element_add_ghost_pad (audio_thread, gst_element_get_pad (audio_queue,
"sink"), "sink");
gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
}
GST_DEBUG_OBJECT (play, "setting up pipeline succeeded.");
return TRUE;
}
static void
gst_play_have_video_size (GstElement * element, gint width,
gint height, GstPlay * play)
setup_size (GstPlay * play)
{
g_return_if_fail (play != NULL);
g_return_if_fail (GST_IS_PLAY (play));
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIDEO_SIZE],
0, width, height);
}
static gboolean
gst_play_tick_callback (GstPlay * play)
{
GstFormat format = GST_FORMAT_TIME;
gboolean q = FALSE;
GstElement *audio_sink_element = NULL;
g_return_val_if_fail (play != NULL, FALSE);
/* just return without updating the UI when we are in the middle of seeking */
if (play->priv->tick_unblock_remaining > 0) {
play->priv->tick_unblock_remaining -= TICK_INTERVAL_MSEC;
return TRUE;
}
if (!GST_IS_PLAY (play)) {
play->priv->tick_id = 0;
return FALSE;
}
audio_sink_element = g_hash_table_lookup (play->priv->elements,
"audio_sink_element");
if (!GST_IS_ELEMENT (audio_sink_element)) {
play->priv->tick_id = 0;
return FALSE;
const GList *streaminfo = NULL;
GstPad *pad = NULL;
g_object_get (G_OBJECT (play->priv->playbin),
"stream-info", &streaminfo, NULL);
for (; streaminfo != NULL; streaminfo = streaminfo->next) {
GObject *info = streaminfo->data;
gint type;
GParamSpec *pspec;
GEnumValue *val;
g_object_get (info, "type", &type, NULL);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (info), "type");
val = g_enum_get_value (G_PARAM_SPEC_ENUM (pspec)->enum_class, type);
if (g_strrstr (val->value_name, "VIDEO")) {
g_object_get (info, "object", &pad, NULL);
pad = (GstPad *) GST_PAD_REALIZE (pad);
break;
}
}
q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
&(play->priv->time_nanos));
if (q)
g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
0, play->priv->time_nanos);
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING)
return TRUE;
else {
play->priv->tick_id = 0;
return FALSE;
if (pad) {
/* handle explicit caps as well - they're set later */
if (GST_PAD_CAPS (pad))
caps_set (pad, NULL, play);
else
g_signal_connect (pad, "notify::caps", G_CALLBACK (caps_set), play);
}
}
static gboolean
gst_play_get_length_callback (GstPlay * play)
gst_play_tick_callback (GstPlay * play)
{
GstElement *audio_sink_element, *video_sink_element;
GstFormat format = GST_FORMAT_TIME;
GstFormat fmt = GST_FORMAT_TIME;
gint64 value;
gboolean q = FALSE;
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
GST_DEBUG_OBJECT (play, "trying to get length");
/* We try to get length from all real sink elements */
audio_sink_element = g_hash_table_lookup (play->priv->elements,
"audio_sink_element");
video_sink_element = g_hash_table_lookup (play->priv->elements,
"video_sink_element");
if (!GST_IS_ELEMENT (audio_sink_element) &&
!GST_IS_ELEMENT (video_sink_element)) {
play->priv->length_id = 0;
return FALSE;
}
/* Audio first and then Video */
if (GST_IS_ELEMENT (audio_sink_element)) {
GST_DEBUG_OBJECT (play, "querying for length on audio sink");
q = gst_element_query (audio_sink_element, GST_QUERY_TOTAL, &format,
&value);
} else
GST_DEBUG_OBJECT (play, "no audio sink element");
if (!q) {
GST_DEBUG_OBJECT (play, "no query result from audio sink");
if (GST_IS_ELEMENT (video_sink_element)) {
GST_DEBUG_OBJECT (play, "querying for length on video sink");
q = gst_element_query (video_sink_element, GST_QUERY_TOTAL, &format,
&value);
/* check length/pos of stream */
if (!GST_CLOCK_TIME_IS_VALID (play->priv->length_nanos) &&
play->priv->get_length_attempt < 16) {
if (gst_element_query (GST_ELEMENT (play->priv->playbin),
GST_QUERY_TOTAL, &fmt, &value)) {
play->priv->length_nanos = value;
g_signal_emit (G_OBJECT (play), gst_play_signals[STREAM_LENGTH],
0, play->priv->length_nanos);
}
play->priv->get_length_attempt++;
}
if (q) {
play->priv->length_nanos = value;
GST_DEBUG_OBJECT (play, "got length, %" GST_TIME_FORMAT,
GST_TIME_ARGS ((GstClockTime) value));
g_signal_emit (G_OBJECT (play), gst_play_signals[STREAM_LENGTH],
0, play->priv->length_nanos);
play->priv->length_id = 0;
return FALSE;
}
play->priv->get_length_attempt++;
GST_DEBUG_OBJECT (play, "no length yet, was attempt %d",
play->priv->get_length_attempt);