fakesrc for audio stream.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

fakesrc for audio stream.

rasnaut
Hi to All!
I working with gstreamer-1.0 and try use fakesrc for work with audiostream. For start trying I copy only 0 in buffer (I used MapInfo structure). So, my code:

main()
{
    gst_init (NULL,NULL);
    loop = g_main_loop_new (NULL, FALSE);

    /* setup pipeline */
    pipeline = gst_pipeline_new ("pipeline");
    g_assert(pipeline);
    fakesrc = gst_element_factory_make ("fakesrc", "source");
    g_assert(fakesrc);
    flt = gst_element_factory_make ("capsfilter", "flt");
    g_assert(flt);
    rate = gst_element_factory_make ("audiorate", "rate");
    g_assert(rate);
    conv = gst_element_factory_make ("audioconvert", "conv");
    g_assert(conv);
    audiosink = gst_element_factory_make ("alsasink", "asink");
    g_assert(videosink);

    /* setup */
    g_object_set (G_OBJECT (flt), "caps",
                 gst_caps_new_simple ("audio/x-raw",
                 "format",G_TYPE_STRING,"S16LE",
                 "rate", G_TYPE_INT,16000,
                  "channels", G_TYPE_INT, 1,
                   NULL), NULL);
    gst_bin_add_many (GST_BIN (pipeline), fakesrc, flt,rate, conv, audiosink, NULL);
    if(!gst_element_link_many (fakesrc, flt, rate, conv, audiosink, NULL))
    {
        g_error("Link Error\n");
    }

    /* setup fake source */
    g_object_set (G_OBJECT (fakesrc),
          "signal-handoffs", TRUE,
          "sizemax", 16000,
          "sizetype", 2, NULL);
    g_signal_connect (fakesrc, "handoff", G_CALLBACK (cb_handoff), NULL);

    /* play */
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
    g_main_loop_run (loop);

    /* clean up */
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (GST_OBJECT (pipeline));
    g_main_loop_unref (loop);
}

So, when I start my programm apear next error:
GStreamer-CRITICAL **: gst_segment_to_running_time: assertion `segment->format == format' failed

When I changed alsasink on fakesink, all work. Maybe it's because my audiocard is working with another details:
format = SL32_LE
rate = 48000
channels = 2

I tryed change my details:
    g_object_set (G_OBJECT (flt), "caps",
                 gst_caps_new_simple ("audio/x-raw",
                 "format",G_TYPE_STRING,"S32LE",
                 "rate", G_TYPE_INT,48000,
                  "channels", G_TYPE_INT, 2,
                   NULL), NULL);

    g_object_set (G_OBJECT (fakesrc),
          "signal-handoffs", TRUE,
          "sizemax", 48000*2,
          "sizetype", 8, NULL);

 but error still stayed.
Anybody know, what I do wrong?
Reply | Threaded
Open this post in threaded view
|

Re: fakesrc for audio stream.

Tiago Katcipis
Hi,


On Wed, Oct 24, 2012 at 6:26 PM, rasnaut <[hidden email]> wrote:
Hi to All!
I working with gstreamer-1.0 and try use fakesrc for work with audiostream.
For start trying I copy only 0 in buffer (I used MapInfo structure). So, my
code:

Have you tried to use audiotestsrc instead of fakesrc ? (you will not need the audiorate element)

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-audiotestsrc.html

Best regards,
Tiago Katcipis
 

main()
{
    gst_init (NULL,NULL);
    loop = g_main_loop_new (NULL, FALSE);

    /* setup pipeline */
    pipeline = gst_pipeline_new ("pipeline");
    g_assert(pipeline);
    fakesrc = gst_element_factory_make ("fakesrc", "source");
    g_assert(fakesrc);
    flt = gst_element_factory_make ("capsfilter", "flt");
    g_assert(flt);
    rate = gst_element_factory_make ("audiorate", "rate");
    g_assert(rate);
    conv = gst_element_factory_make ("audioconvert", "conv");
    g_assert(conv);
    audiosink = gst_element_factory_make ("alsasink", "asink");
    g_assert(videosink);

    /* setup */
    g_object_set (G_OBJECT (flt), "caps",
                 gst_caps_new_simple ("audio/x-raw",
                 "format",G_TYPE_STRING,"S16LE",
                 "rate", G_TYPE_INT,16000,
                  "channels", G_TYPE_INT, 1,
                   NULL), NULL);
    gst_bin_add_many (GST_BIN (pipeline), fakesrc, flt,rate, conv,
audiosink, NULL);
    if(!gst_element_link_many (fakesrc, flt, rate, conv, audiosink, NULL))
    {
        g_error("Link Error\n");
    }

    /* setup fake source */
    g_object_set (G_OBJECT (fakesrc),
          "signal-handoffs", TRUE,
          "sizemax", 16000,
          "sizetype", 2, NULL);
    g_signal_connect (fakesrc, "handoff", G_CALLBACK (cb_handoff), NULL);

    /* play */
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
    g_main_loop_run (loop);

    /* clean up */
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (GST_OBJECT (pipeline));
    g_main_loop_unref (loop);
}

So, when I start my programm apear next error:
GStreamer-CRITICAL **: gst_segment_to_running_time: assertion
`segment->format == format' failed

When I changed alsasink on fakesink, all work. Maybe it's because my
audiocard is working with another details:
format = SL32_LE
rate = 48000
channels = 2

I tryed change my details:
    g_object_set (G_OBJECT (flt), "caps",
                 gst_caps_new_simple ("audio/x-raw",
                 "format",G_TYPE_STRING,"S32LE",
                 "rate", G_TYPE_INT,48000,
                  "channels", G_TYPE_INT, 2,
                   NULL), NULL);

    g_object_set (G_OBJECT (fakesrc),
          "signal-handoffs", TRUE,
          "sizemax", 48000*2,
          "sizetype", 8, NULL);

 but error still stayed.
Anybody know, what I do wrong?



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/fakesrc-for-audio-stream-tp4656701.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel