Appsrc : Error in the internal data flow

Matias Hernandez Arellano msdark at archlinux.cl
Wed Mar 30 06:37:25 PDT 2011


(sorry for mi english)..

Hi!! .. i'm trying to build a simple app with gstreamer.
The idea is capture images from webcam, processing and stream the result.

The capture and processing part is do with OpenCV ... so i just need to add the streaming part.

For this i made this test code: (this test code try to create a video file with the captured and processing images)

typedef struct _App App;
struct _App{
    GstElement *pipeline;
    GstElement *appsrc;
    GMainLoop *loop;
    guint sourceid;
    GTimer *timer;
};
App s_app;
CvCapture *capture;
static gboolean read_data(App *app){
    GstFlowReturn ret;
    GstBuffer *buffer = gst_buffer_new();
    IplImage* frame = cvQueryFrame(capture); //Capture a image from camera
    GST_BUFFER_DATA(buffer) = (uchar*)frame->imageData; //Get only the data from the image
    GST_BUFFER_SIZE(buffer) = frame->width*frame->height*sizeof(uchar*);
    g_signal_emit_by_name(app->appsrc,"push-buffer",buffer,&ret); //Push the data into appsrc
    gst_buffer_unref(buffer);
    if(ret != GST_FLOW_OK){
        GST_DEBUG("Error al alimentar buffer");
        return FALSE;
    }
    return TRUE;
}

/***...
...
...
...
...
*/
static void start_feed(GstElement* pipeline,guint size, App* app){
    if(app->sourceid == 0){
        GST_DEBUG("Alimentando");
        app->sourceid = g_idle_add((GSourceFunc) read_data, app);
    }
}


int main(int argc, char* argv[]){
    App *app = &s_app;
    GError *error = NULL;
    GstBus *bus;
    GstCaps *caps;
    capture = cvCaptureFromCAM(0);
    gst_init(&argc,&argv);
    app->loop = g_main_loop_new (NULL, TRUE);
    app->timer = g_timer_new();
    char pipe_str[256] = "";
    IplImage* frame = cvQueryFrame(capture); //Capture a image from camera
    sprintf(pipe_str,"appsrc name=mysource ! video/x-raw-bgr,width=%d,height=%d,depth=%d ! ffmpegcolorspace ! jpegenc ! avimux ! filesink location=video.avi    ",frame->width,frame->height,frame->depth);
    app->pipeline = gst_parse_launch(pipe_str,NULL);
    g_assert (app->pipeline);
    bus = gst_pipeline_get_bus (GST_PIPELINE (app->pipeline));
    g_assert(bus);
    /* add watch for messages */
    gst_bus_add_watch (bus, (GstBusFunc) bus_message, app);
    /* get the appsrc */
    app->appsrc = gst_bin_get_by_name (GST_BIN(app->pipeline), "mysource");
    g_assert(app->appsrc);
    g_assert(GST_IS_APP_SRC(app->appsrc));
    g_signal_connect (app->appsrc, "need-data", G_CALLBACK (start_feed), app);
    g_signal_connect (app->appsrc, "enough-data", G_CALLBACK (stop_feed), app);
    /* set the caps on the source */
    caps = gst_caps_new_simple ("video/x-raw-bgr",
    "depth",G_TYPE_INT,frame->depth,
     "width", G_TYPE_INT, frame->width,
     "height", G_TYPE_INT, frame->height,
     NULL);
     gst_app_src_set_caps(GST_APP_SRC(app->appsrc), caps);
    //cvReleaseImage(&frame);
    /* go to playing and wait in a mainloop. */
    gst_element_set_state (app->pipeline, GST_STATE_PLAYING);
    /* this mainloop is stopped when we receive an error or EOS */
    g_main_loop_run (app->loop);
    GST_DEBUG ("stopping");
    gst_element_set_state (app->pipeline, GST_STATE_NULL);
    gst_object_unref (bus);
    g_main_loop_unref (app->loop);
    cvReleaseCapture(&capture);
    return 0;
}

Pero este código presenta el siguiente error:

ERROR from element mysource: Error in the internal data flow
Debugging info: gstbasesrc.c(2574): gst_base_src_loop (): /GstPipeline:pipeline0/GstAppSrc:mysource:
streaming task paused, reason not-linked (-1)

i'm just don't know what is wrong... any idea?

Thanks in advance

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl




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


More information about the gstreamer-devel mailing list