appsrc & appsink usage

Michael White oo1234567892012 at aol.com
Fri May 8 13:48:38 PDT 2015



Hi all,


I'm working with GStreamer 1.4.5 on iOS and am having problems with appsrc and appsink.  I'm using appsrc and appsink to pass data between two pipes that work independently; pipelineA will always be playing while pipelineB may change states based on user input, network conditions, etc....  My basis for testing is the following pipeline:



-----------------------------------

    pipeline1 = gst_parse_launch("videotestsrc is-live=true"
                                 " !video/x-raw,format=(string)RGB,width=(int)640,height=(int)480,framerate=(fraction)30/1"
                                 " !videoconvert"
                                 " !autovideosink"
                                 , &error);
    gst_element_set_state(pipeline1, GST_STATE_READY);

-----------------------------------



Obviously I've trimmed down the code from what's there, but this is the essence of it.  I handle the pipeline state change to GST_STATE_READY callback by setting state to GST_STATE_PLAYING.  This works as expected, i.e. I see the test pattern.  What I want to do is create two pipelines and add appsrc & appsink between the two:


-----------------------------------
init()
{
    pipelineA = gst_parse_launch("videotestsrc is-live=true"
                                         " !video/x-raw,format=(string)RGB,width=(int)640,height=(int)480,framerate=(fraction)30/1"
                                         " !appsink name=myappsink"
                                 , &error);
    pipelineB = gst_parse_launch(" appsrc name=myappsrc format=3 is-live=true"
                                         " !videoconvert"
                                         " !autovideosink"
                                         , &error);
    appSink = gst_bin_get_by_name(GST_BIN(pipelinA), "mayappsink");
    memset(&callbacks, 0, sizeof(callbacks));
    callbacks.new_sample = newPacket;
    gst_app_sink_set_callbacks((GstAppSink *)(appSink), &callbacks, NULL, NULL);
    global_appSrc = gst_bin_get_by_name(GST_BIN(pipelineB), "myappsrc");


    gst_element_set_state(pipelineA, GST_STATE_READY);
    gst_element_set_state(pipelineB, GST_STATE_READY);
}


static GstFlowReturn newPacket(GstAppSink *appsink, gpointer data)
{
    static bool firstSample=YES;
    GstFlowReturn retval = GST_FLOW_OK;
    if (gst_app_sink_is_eos(appsink) == FALSE)
    {
        GstSample *sample = gst_app_sink_pull_sample(appsink);
        if (NULL != sample)
        {
            if (YES == firstSample)
            {
                GstCaps *caps = gst_sample_get_caps(sample);
                gst_caps_ref(caps);
                gst_app_src_set_caps((GstAppSrc *)global_appSrc, caps);
                firstSample = NO;
            }
            GstBuffer *buffer = gst_sample_get_buffer(sample);
            if (NULL != buffer)
            {
                if (((GST_STATE_PLAYING == global_pipelineBState) || (GST_STATE_PAUSED == global_pipelineBState)))
                {
                    retval = gst_app_src_push_buffer((GstAppSrc *)global_appSrc, gst_buffer_ref(buffer));
	            NSLog(@"retval = %d", retval);
                 }
            }
            gst_sample_unref(sample);
        }
    }


    return retval;
}

------------------------------------------------------


Again, I've trimmed the code quite a bit but I believe all the important bits are there.  As before, I handle the pipeline state changes to GST_STATE_READY callback by setting the states to GST_STATE_PLAYING.


This pair of pipelines do not work.  "not work" means I see no errors (I am registering for error, eos, state-changed, and clock-lost callbacks) but I also see no test pattern, just a blank screen.  I see the samples and buffers being handled by newPacket(), as there is a continuous stream of debug output.  I've tried various permutations, including adding the same caps line in pipleineB, i.e.:



------------------------------------------------------

    pipelineB = gst_parse_launch(" appsrc name=myappsrc format=3 is-live=true"

                                         " !video/x-raw,format=(string)RGB,width=(int)640,height=(int)480,framerate=(fraction)30/1"

                                         " !videoconvert"
                                         " !autovideosink"
                                         , &error);

------------------------------------------------------



But I get the same results: no error but also no video.


Any thoughts on what I'm doing wrong here?


Thanks,
Michael

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


More information about the gstreamer-devel mailing list