/* compile with: * gcc bgo-650258.c `pkg-config --cflags --libs gstreamer-0.10` */ #include int main (int argc, char ** argv) { GstBus *bus; GstElement *pipe, *src, *demux; GstFormat fmt = GST_FORMAT_TIME; GstMessage *msg; gint64 len = -1; gchar *location; gst_init (&argc, &argv); if (argc < 2 || !gst_uri_is_valid (argv[1])) g_error ("Usage: %s file:///path/to/file", argv[0]); pipe = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("filesrc", NULL); demux = gst_element_factory_make ("matroskademux", NULL); location = gst_uri_get_location (argv[1]); g_object_set (src, "location", location, NULL); g_free (location); gst_bin_add_many (GST_BIN (pipe), src, demux, NULL); gst_element_link (src, demux); gst_element_set_state (pipe, GST_STATE_PAUSED); while (TRUE) { GstTagList *tags = NULL; msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe), GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_TAG | GST_MESSAGE_ERROR); if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_TAG) /* error or async_done */ break; gst_message_unref (msg); }; gst_element_query_duration (demux, &fmt, &len); g_printf ("gst_element_query_duration: %" G_GINT64_FORMAT "\n", len); gst_element_set_state (pipe, GST_STATE_NULL); gst_object_unref (pipe); return 0; }