BUG with queue element ?

Stefan Sauer ensonic at hora-obscura.de
Wed Sep 17 04:38:38 PDT 2014


On 09/15/2014 08:56 PM, Prabhakar Lad wrote:
> Hi Tim,
>
> Thanks for your response!
>
> On Mon, Sep 15, 2014 at 6:01 PM, Tim Müller <tim at centricular.com> wrote:
>> On Mon, 2014-09-15 at 17:03 +0100, Prabhakar Lad wrote:
>>
>> Hi,
>>
>> What GStreamer version are you using?
>>
> I am using GStreamer-1.0
>
>> Perhaps you could distill this into a minimal test case that
>> demonstrates the issue?
>>
> I attaching the c file test-case and also pasting the code, so
> that its easier to review.

How do you stop the program? With Ctrl-C? You should send an EOS to the
pipeline before stopping to ensure the queue is flushed.
Stefan

>
> #include <stdio.h>
> #include <termios.h>
> #include <unistd.h>
>
> #include <gst/gst.h>
> #include <gst/app/gstappsrc.h>
>
> /* to compile gcc gst.c -o test_case -Wall `pkg-config --cflags --libs
> gstreamer-1.0` */
>
> GstElement *pipeline = NULL;
> static GMainLoop *loop;
>
> int mygetch ( void )
> {
>     int ch;
>     struct termios oldt, newt;
>
>     tcgetattr ( STDIN_FILENO, &oldt );
>     newt = oldt;
>     newt.c_lflag &= ~( ICANON | ECHO );
>     tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
>     ch = getchar();
>     tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
>
>     return ch;
> }
>
> static gboolean bus_handler (GstBus *bus, GstMessage *msg, gpointer data)
> {
>     GMainLoop *loop;
>
>     loop = (GMainLoop*)data;
>
>     switch (GST_MESSAGE_TYPE (msg)) {
>     case GST_MESSAGE_EOS:
>     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;
>     }
>     case GST_MESSAGE_STATE_CHANGED:
>     {
>         GstState state;
>
>         gst_message_parse_state_changed (msg, NULL, &state, NULL);
>
>         break;
>     }
>     default:
>     break;
>     }
>
>     return TRUE;
> }
>
> int main(int argc, char *argv[])
> {
>     GstElement *avimux, *filesink, *v4l2src ,*rlvvalve, *rlvideoqueue;
>     GstBus *bus;
>     guint bus_id;
>
>     gst_init (NULL, NULL);
>
>     loop = g_main_loop_new (NULL, FALSE);
>
>     pipeline = gst_pipeline_new ("test_pipeline");
>     v4l2src = gst_element_factory_make ("v4l2src", "v4l2src");
>     avimux = gst_element_factory_make ("avimux", "avimux");
>     filesink = gst_element_factory_make ("filesink", "filesink");
>     rlvvalve = gst_element_factory_make ("valve", "rlvvalve");
>     rlvideoqueue = gst_element_factory_make ("queue", "rlvideoqueue");
>
>     if (!pipeline || !avimux || !filesink || !v4l2src ||
>         !rlvideoqueue || !rlvvalve) {
>         printf ("Could not create all gstreamer elements.\n");
>         return 0;
>     }
>
>     bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>     bus_id = gst_bus_add_watch (bus, bus_handler, loop);
>     gst_object_unref (bus);
>
>     g_object_set (G_OBJECT (filesink), "location", "test.avi",
> "async", FALSE, NULL);
>
>     gst_bin_add_many (GST_BIN (pipeline), avimux, filesink, v4l2src,
> rlvideoqueue,
>               rlvvalve, NULL);
>
>     /* v4l2src ! queue ! valve ! avimux ! filesink location=test.avi */
>     gst_element_link_many (v4l2src, rlvideoqueue, rlvvalve, avimux,
> filesink, NULL);
>
>     /* initially set the drop to TRUE */
>     g_object_set (G_OBJECT (rlvvalve), "drop", (gboolean)TRUE, NULL);
>
>     /* configure to hold 15 seconds of data */
>     g_object_set (G_OBJECT (rlvideoqueue), "min-threshold-time",
> (guint64)15000000000, NULL);
>     g_object_set (G_OBJECT (rlvideoqueue), "min-threshold-buffers",
> (guint64)0, NULL);
>     g_object_set (G_OBJECT (rlvideoqueue), "min-threshold-bytes",
> (guint64)0, NULL);
>     g_object_set (G_OBJECT (rlvideoqueue), "max-size-bytes", (guint64)0, NULL);
>     g_object_set (G_OBJECT (rlvideoqueue), "max-size-buffers",
> (guint64)0, NULL);
>     g_object_set (G_OBJECT (rlvideoqueue), "max-size-time",
> (guint64)150000000000, NULL);
>
>     gst_element_set_state (pipeline, GST_STATE_PLAYING);
>
>     /* wait for a key press */
>     mygetch();
>
>     /* attach the valve back to pipeline */
>     g_object_set (G_OBJECT (rlvvalve), "drop", (gboolean)FALSE, NULL);
>     printf("Writing to file now!!!\n");
>     g_main_loop_run (loop);
>
>     gst_element_set_state (pipeline, GST_STATE_NULL);
>     gst_object_unref (GST_OBJECT (pipeline));
>     g_source_remove (bus_id);
>     g_main_loop_unref (loop);
>     gst_deinit ();
>
>     return 0;
> }
>
> Thanks,
> --Prabhakar
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140917/11db820d/attachment.html>


More information about the gstreamer-devel mailing list