Hello All,
I have a basic understanding of gstreamer, the problem i am facing may be trivial , please bear with me. What I am trying to make use of playbin2 for playing a non-seekable file (I am using pipe & doing "cat *.mp3 > /home/my_pipe after running my app) Here is my app ------------------------------------------------------- include <gst/gst.h> static int cnt = 0; static gboolean cb_print_position (GstElement *pipeline) { GstFormat fmt = GST_FORMAT_TIME; gint64 pos, len; if (gst_element_query_position (pipeline, &fmt, &pos) && gst_element_query_duration (pipeline, &fmt, &len)) { GTimeVal tv_pos, tv_len; GST_TIME_TO_TIMEVAL (pos, tv_pos); GST_TIME_TO_TIMEVAL (len, tv_len); glong pos_min = tv_pos.tv_sec / 60; glong len_min = tv_len.tv_sec / 60; g_print ("\rCount %d) : Time: %01lu:%02lu:%02lu.%02lu", cnt++ , pos_min / 60, pos_min % 60, tv_pos.tv_sec % 60, tv_pos.tv_usec / 10000); if (len > 0) /* streams have len == -1 */ g_print (" of %01lu:%02lu:%02lu.%02lu", len_min / 60, len_min % 60, tv_len.tv_sec % 60, tv_len.tv_usec / 10000); } if(cnt == 50) { printf("Going to Seek for 10 sec \n"); GstFormat fmt = GST_FORMAT_TIME; gint64 cur_pos; if (!(gst_element_query_position (pipeline, &fmt, &cur_pos))) printf("[player] : gst_element_query_position failed \n"); g_print("The cur_pos %" G_GINT64_FORMAT , cur_pos); double new_pos_sec = cur_pos * (1.0 / GST_SECOND) + 10; // 10 sec gint64 new_pos = new_pos_sec * GST_SECOND ; printf("new_pos = %" G_GINT64_FORMAT , new_pos); if(!(gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, new_pos , GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))) printf("\n[player] Seek failed!! \n"); else printf("\n[Player] Seek successful \n"); } return TRUE; } static gboolean my_bus_callback (GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: g_print ("End of stream\n"); g_main_loop_quit (loop); break; case GST_MESSAGE_ERROR: { gchar *debug; GError *error; gst_message_parse_error (msg, &error, &debug); g_free (debug); g_printerr ("Error: %s\n", error->message); g_error_free (error); g_main_loop_quit (loop); break; } default: break; } return TRUE; } gint main (gint argc, gchar *argv[]) { GMainLoop *loop; GstElement *play; GstBus *bus; /* init GStreamer */ gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* make sure we have a URI */ if (argc != 2) { g_print ("Usage: %s <URI>\n", argv[0]); return -1; } /* set up */ play = gst_element_factory_make ("playbin2", "play"); g_object_set (G_OBJECT (play), "uri", argv[1], NULL); bus = gst_pipeline_get_bus (GST_PIPELINE (play)); gst_bus_add_watch (bus, my_bus_callback, loop); gst_object_unref (bus); gst_element_set_state (play, GST_STATE_PLAYING); g_timeout_add (200, (GSourceFunc) cb_print_position, play); /* now run */ g_main_loop_run (loop); /* also clean up */ gst_element_set_state (play, GST_STATE_NULL); gst_object_unref (GST_OBJECT (play)); return 0; } --------------------------------- End -------------------------------- run: <my_app> my_pipe o/p: Count 49) : Time: 0:00:09.85 Going to Seek for 10 sec The cur_pos 9852113000 new_pos = 19852112999 [player] Seek failed!! Count 118) : Time: 0:00:23.63 -------------------------------- observation: 1) Playback successfuly between count 1- 49. 2) At count= 50 i.e., when seek called , the seek fails. & there was no sound though player is in PLAYING state between count <50 to 100> 3) After count = 100 , resumed normal playback. Why there is no sound after seek failed though player was in PLAYING state. The same behavior I observed with my own pipeline [ filesrc ! decodebon2 ! autoaudiosink ] Appreciate your input. -- Thanks & Regards, Satish Pattar _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |