The linking filter and sink failed.

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

The linking filter and sink failed.

Igor Mironchick
Hi, Can anybody help me with this:

/*!
    Initialize the the Gstreamer pipeline. Below is a diagram
    of the pipeline that will be created:

                                    |Screen|  |Screen|  |Screen|
                                  ->|queue |->|filter|->|sink  |-> Display
    |Camera|  |Camera    |  |Tee|/
    |src   |->|CSP filter|->|   |\  |Image |  |Image |  |Image |
                                  ->|queue |->|filter|->|sink  |-> JPEG file
*/
void initPipeline( GstElement * pipeline,
    GstElement * imageSink, GstCaps * caps )
{
    // Create pipeline and attach a callback to it's message bus.
    pipeline = gst_pipeline_new( "camera" );

    // Create elements.
    GstElement * cameraSrc = gst_element_factory_make(
        "v4l2src", cameraSourceName.c_str() );

    GstElement * cspFilter = gst_element_factory_make(
        "ffmpegcolorspace", "cspFilter" );

    GstElement * tee = gst_element_factory_make( "tee", "tee" );

    GstElement * screenQueue = gst_element_factory_make(
        "queue", "screenQueue" );

    GstElement * screenFilter = gst_element_factory_make(
        "ffmpegcolorspace", "screenFilter" );

    GstElement * screenSink = gst_element_factory_make(
        "xvimagesink", screenSinkName.c_str() );

    GstElement * imageQueue = gst_element_factory_make(
        "queue", "imageQueue" );

    GstElement * imageFilter = gst_element_factory_make(
        "ffmpegcolorspace", "imageFilter" );

    imageSink = gst_element_factory_make(
        "fakesink", imageSinkName.c_str() );

    // Check that elements are correctly initialized.
    if( !( pipeline && cameraSrc && cspFilter && tee &&
        screenQueue && screenFilter && screenSink && imageQueue &&
        imageFilter && imageSink ) )
    {
        throw std::runtime_error( "Unable to initialize pipeline's elemets." );
    }

    // Add elements to the pipeline. This has to be done prior to linking them.
    gst_bin_add_many( GST_BIN( pipeline ), cameraSrc, cspFilter,
        tee, screenQueue, screenFilter, screenSink, imageQueue,
        imageFilter, imageSink, NULL );

    if( !gst_element_link_many( cameraSrc, cspFilter, tee, NULL ) )
        throw std::runtime_error( "Unable to link camera source, "
            "colorspace filter and tee." );

    if( !gst_element_link_many( tee, imageQueue, imageFilter, NULL ) )
        throw std::runtime_error( "Unable to link tee, image queue "
            "and image filter." );

    // Capabilities for preview.
    caps = gst_caps_new_simple( "video/x-raw-rgb",
        "width", G_TYPE_INT, cameraMAXXResolution,
        "height", G_TYPE_INT, cameraMAXYResolution,
        "bpp", G_TYPE_INT, cameraBitsPerPixel,
        "depth", G_TYPE_INT, cameraColorDepth,
        "framerate", GST_TYPE_FRACTION, cameraVideoFramerate, 1,
        NULL );

    if( !gst_element_link_filtered( imageFilter, imageSink, caps ) )
    {
        gst_caps_unref( caps );

        throw std::runtime_error( "Unable to link image filter and "
            "image sink." );
    }

    gst_caps_unref( caps );

    if( !gst_element_link_many( tee, screenQueue, screenFilter, NULL ) )
        throw std::runtime_error( "Unable to link tee, screen queue and "
            "screen filter." );

    // Capabilities for image capturing.
    caps = gst_caps_new_simple( "video/x-raw-rgb",
        "width", G_TYPE_INT, cameraPreviewXResolution,
        "height", G_TYPE_INT, cameraPreviewYResolution,
        NULL );

    if( !gst_element_link_filtered( screenFilter, screenSink, caps ) )
    {
        gst_caps_unref( caps );

        throw std::runtime_error( "Unable to link screen filter and "
            "screen sink." );
    }

    gst_element_set_state( pipeline, GST_STATE_READY );
} // initPipeline

Last gst_element_link_filtered failed and I can't understand why.

--
Regards,
Igor Mironchick

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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: The linking filter and sink failed.

wl2776
Administrator
Igor Mironchick wrote
Hi, Can anybody help me with this:

/*!
    Initialize the the Gstreamer pipeline. Below is a diagram
    of the pipeline that will be created:

                                    |Screen|  |Screen|  |Screen|
                                  ->|queue |->|filter|->|sink  |-> Display
    |Camera|  |Camera    |  |Tee|/
    |src   |->|CSP filter|->|   |\  |Image |  |Image |  |Image |
                                  ->|queue |->|filter|->|sink  |-> JPEG file
*/

Last gst_element_link_filtered failed and I can't understand why.
Probably, because of the difference in image sizes. Try adding videoscale between ffmpegcolorspace and xvimagesink.  Also, there is no need to set caps.
Reply | Threaded
Open this post in threaded view
|

Re: The linking filter and sink failed.

Igor Mironchick


2010/4/22 wl2776 <[hidden email]>


Igor Mironchick wrote:
>
> Hi, Can anybody help me with this:
>
> /*!
>     Initialize the the Gstreamer pipeline. Below is a diagram
>     of the pipeline that will be created:
>
>                                     |Screen|  |Screen|  |Screen|
>                                   ->|queue |->|filter|->|sink  |-> Display
>     |Camera|  |Camera    |  |Tee|/
>     |src   |->|CSP filter|->|   |\  |Image |  |Image |  |Image |
>                                   ->|queue |->|filter|->|sink  |-> JPEG
> file
> */
>
> Last gst_element_link_filtered failed and I can't understand why.
>
Probably, because of the difference in image sizes. Try adding videoscale
between ffmpegcolorspace and xvimagesink.  Also, there is no need to set
caps.

Probably you are right, I have to chec it.

You mean that I nedd not to set caps if the resolution is MAX_X x MAX_Y ?

Thx.


--
Regards,
Igor Mironchick

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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: The linking filter and sink failed.

wl2776
Administrator
Igor Mironchick wrote
You mean that I need not to set caps if the resolution is MAX_X x MAX_Y ?
Yes.
You restrict the stream very much, by setting caps filter. You won't see anything in this case, if the camera will change the stream parameters.
Also, consider using queues, otherwise your camera playback may freeze during image record.
Using queues forces creation of several threads in the application.