Error is request_pad and gst_pad_link_full

JongIlLee lji890214 at naver.com
Fri Jun 17 08:28:28 UTC 2016


Hi!

I try to work to save the Data Webcam now to File.

But a problem for me.

gstreamer-critical **: gst_pad_link_full: assertion 'GST_IS_PAD (srcpad)'
failed

I do not know why the error occurred , such as the above .

Please Ask advice. Thank you. 

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

#include <stdio.h>
#include <stdlib.h>
#include "gst/gst.h"
#include <glib.h>
#include <string.h>

gboolean bus_call(GstBus *bus, GstMessage *msg, void *data){
        gchar *debug;
        GError *err;
        GMainLoop *loop = (GMainLoop*)data;

        switch (GST_MESSAGE_TYPE(msg)){
                case GST_MESSAGE_APPLICATION:
                        g_print("APP received on OBJ NAME
%s\n",GST_OBJECT_NAME(msg->src));
                        break;
                case GST_MESSAGE_EOS:
                        g_print("EOS received on OBJ NAME
%s\n",GST_OBJECT_NAME(msg->src));
                        g_main_loop_quit (loop);
                        break;
                case GST_MESSAGE_ERROR:
                        gst_message_parse_error(msg, &err, &debug);
                        g_free(debug);
                        g_print("BUS CALL %s\n", err->message);
                        g_error_free(err);
                        g_main_loop_quit (loop);
                        break;
                default:
                        break;
        }
        return TRUE;
}



int main(int argc, char* argv[]){
        GMainLoop *loop;
        gst_init(&argc,&argv);
        loop = g_main_loop_new (NULL, FALSE);
        GstElement  *pipeline, *vsource, *vtee, *vqueue, *tover, *xvsink,
*evqueue, *vencoder, *muxer, *filesink;
        GstBin *recording;
        GstBus *bus;
        GstPad *srcpad, *sinkpad;

        // Create gstreamer element
        pipeline   = gst_pipeline_new ("Live Recording");
        vsource    = gst_element_factory_make
("v4l2src","viewing-file-source");
        vtee       = gst_element_factory_make ("tee","viewing-tee");
        vqueue     = gst_element_factory_make ("queue2","viewing-queue");
        tover      = gst_element_factory_make
("timeoverlay","viewing-overlay");
xvsink     = gst_element_factory_make ("xvimagesink","viewing-xvsink");

        GstElement  *asource, *atee, *aqueue, *aequeue, *aencoder, *asink;
        asource    = gst_element_factory_make ("alsasrc","source");
        atee       = gst_element_factory_make ("tee","viewing-audio-tee");
        aqueue     = gst_element_factory_make
("queue2","viewing-audio-queue");
        asink      = gst_element_factory_make
("pulsesink","viewing-audio-sink");
        aequeue    = gst_element_factory_make
("queue2","encoding-audio-queue");
        aencoder   = gst_element_factory_make
("vorbisenc","encoding-audio-encoder");

        recording  = GST_BIN(gst_bin_new("recording-bin"));
        evqueue    = gst_element_factory_make ("queue2","encoding-queue");
        vencoder   = gst_element_factory_make
("ffenc_mpeg4","encoding-encoder");
        muxer      = gst_element_factory_make ("avimux","encoding-muxer");
//avimux change mp4mux
        filesink   = gst_element_factory_make
("filesink","encoding-filesink");


        //checking element
        if(!pipeline || !vsource || !vtee || !vqueue || !tover || !xvsink){
                g_print("no create pipe and video element\n");
                return -1;
        }

        if(!asource || !atee || !aqueue || !asink || !aequeue || !aencoder){
                g_print("no create audio element\n");
                return -1;
        }

        if(!recording || !evqueue || !vencoder || !muxer || !filesink ){
                g_print("no create mux and sink element\n");
                return -1;
        }
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
        gst_bus_add_watch (bus, bus_call, loop);
        gst_object_unref (bus);
        g_object_set(G_OBJECT(vsource), "num-buffers",300, NULL);
        g_object_set(G_OBJECT(filesink),"location","output.avi", NULL);
        g_object_set (G_OBJECT (tover), "halign", "right", NULL);
        g_object_set (G_OBJECT (tover), "valign", "top", NULL);
        g_object_set (G_OBJECT (tover), "shaded-background", TRUE, NULL);

        /* create the recording bin */
        //if eles checking
        gst_bin_add_many (recording, aequeue, aencoder, evqueue, vencoder,
muxer, filesink, NULL);

        //jilee 06.17 recoding  
        //gst_bin_add_many (recording, evqueue, vencoder, muxer, filesink,
NULL);
        //if eles checking

        sinkpad       = gst_element_get_static_pad(evqueue,"sink");
        GstPad *ghost = gst_ghost_pad_new("vsink",sinkpad);

        if(ghost == NULL)
                g_error("no create ghostpad!\n");

        gst_element_add_pad(GST_ELEMENT(recording),ghost);
        gst_object_unref(GST_OBJECT(sinkpad));
        gst_element_link_many(evqueue,vencoder,muxer,filesink,NULL);

        //#ifdef INCLUDE_AUDIO
        sinkpad = gst_element_get_static_pad(aequeue,"sink");
       
gst_element_add_pad(GST_ELEMENT(recording),gst_ghost_pad_new("asink",sinkpad));
        gst_object_unref(GST_OBJECT(sinkpad));
        gst_element_link_many(aequeue,aencoder,muxer,NULL);
        //#endif

        /* we add all elements into the pipeline */
        //#ifdef INCLUDE_AUDIO
        gst_bin_add_many (GST_BIN (pipeline), asource, atee, aqueue, asink,
vsource, vtee, vqueue, tover, xvsink, recording, NULL);

//#else
        //jilee 06.17 recoding
        //gst_bin_add_many (GST_BIN (pipeline), vsource, vtee, vqueue,
tover, xvsink, recording, NULL);
        //#endif



        /* link video elements */
        gst_element_link_many(vsource,tover,vtee,NULL);
        srcpad  = gst_element_get_request_pad(vtee,"src%d"); //src0
        sinkpad = gst_element_get_static_pad(vqueue,"sink");
        //gst_pad_link(srcpad,sinkpad);
        //gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT);
       
if(gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT)!=GST_PAD_LINK_OK)
                g_error("fail video link");
        gst_element_link(vqueue,xvsink);
        /* link the viewing pipeline into the bin */
        srcpad  = gst_element_get_request_pad(vtee,"src%d");//src1
        sinkpad =
gst_element_get_static_pad(GST_ELEMENT(recording),"vsink");
        //gst_pad_link(srcpad,sinkpad);
        //gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT);
       
if(gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT)!=GST_PAD_LINK_OK)
                g_error("fail video record link");



        //#ifdef INCLUDE_AUDIO
        /* link audio elements */
        gst_element_link_many(asource,atee,NULL);
        srcpad  = gst_element_get_request_pad(atee,"src%d");//src0
        sinkpad = gst_element_get_static_pad(aqueue,"sink");
        //gst_pad_link(srcpad,sinkpad);
        //gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT);
       
if(gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT)!=GST_PAD_LINK_OK)
                g_error("fail audio link");

        gst_element_link(aqueue,asink);
        /* link the viewing pipeline into the bin */
        srcpad  = gst_element_get_request_pad(atee,"src%d");//src1
        sinkpad =
gst_element_get_static_pad(GST_ELEMENT(recording),"asink");
        //gst_pad_link(srcpad,sinkpad);
        //gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT);
       
if(gst_pad_link_full(srcpad,sinkpad,GST_PAD_LINK_CHECK_DEFAULT)!=GST_PAD_LINK_OK)
                g_error("fail audio record link");
        //#endif

/* Iterate */
        g_print ("Running...\n");
        gst_element_set_state(pipeline,GST_STATE_PLAYING);
        g_main_loop_run (loop);

        //unregister
        g_print ("Returned, stopping playback\n");
        gst_element_set_state (pipeline, GST_STATE_NULL);
        g_print ("Deleting pipeline\n");
        gst_object_unref (GST_OBJECT (pipeline));
        return 0;
}




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Error-is-request-pad-and-gst-pad-link-full-tp4678115.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list