input selector help

Thomas Green TGreen2 at Sorenson.com
Fri May 2 11:18:23 PDT 2014


I'm trying to use an input selector using as inputs a filesrc and an appsrc.  The pipeline goes to playing state, and if I start with either source as the active pad, it works well.  I can see input on both sinks, and drops for the inactive pad.  When I change the active pad, I now no longer receive anything  on that sink.  When I change the active pad back, I now no longer receive anything on either sink.  Is there something basic about an input selector that I'm missing?

Here is the code for creating the sources and input-selector, then the code for changing the active pad...

      m_pDecodePipeline = gst_pipeline_new ("decode_pipeline_element");
        g_assert (m_pDecodePipeline);

/*
* Create the static screen source
*/
        GstElement *pStaticScreenSourceElement = gst_element_factory_make("filesrc", "static_screen_source_element");
        g_assert(pStaticScreenSourceElement);
        g_object_set(G_OBJECT(pStaticScreenSourceElement), "location", "./static_screen.jpg", "do-timestamp", TRUE, NULL);

        GstElement *pStaticScreenDecoder = gst_element_factory_make("nv_omx_jpegdec", "static_screen_decoder_element");
        g_assert(pStaticScreenDecoder);

        GstElement *pImageFreezeElement = gst_element_factory_make("imagefreeze", "static_screen_freeze_element");
        g_assert(pImageFreezeElement);

/*
* now the appsrc part of the pipeline
*/
        m_pDecodeAppSrcElement = gst_element_factory_make ("appsrc", "decode_app_src_element");
        g_assert(m_pDecodeAppSrcElement);

        GstAppSrcCallbacks callbacks;
        callbacks.need_data = need_data;
        callbacks.enough_data = enough_data;
        callbacks.seek_data = NULL;                 // we won't ever be seeking on this
        gst_app_src_set_callbacks(GST_APP_SRC(m_pDecodeAppSrcElement), &callbacks, this, notify);
        g_object_set(G_OBJECT(m_pDecodeAppSrcElement), "is-live", TRUE, "do-timestamp", TRUE, NULL);

        m_pDecodeElement = gst_element_factory_make("nv_omx_h264dec", "decode_element");
        g_assert(m_pDecodeElement);
/*
* get the input multiplexer
*/
        m_pDecodePipelineInputSelector = gst_element_factory_make("input-selector", "decode_pipeline_input_selector");
        g_assert(m_pDecodePipelineInputSelector);
        g_object_set(G_OBJECT(m_pDecodePipelineInputSelector), "sync-streams", TRUE, NULL);

..... more elements on the other side.....


bool bDecodePipelineLinked = gst_element_link_many(pStaticScreenSourceElement,
                        pStaticScreenDecoder,
                        pImageFreezeElement,
                        NULL);
        if (!bDecodePipelineLinked)
        {
                Trace("StaticScreen link failed\n");
                assert(FALSE);
        }

        bDecodePipelineLinked = gst_element_link_many(m_pDecodeAppSrcElement,
                        m_pDecodeElement,
                        NULL);
        if (!bDecodePipelineLinked)
        {
                Trace("Appsrc link failed\n");
               assert(FALSE);
        }

        bDecodePipelineLinked = gst_element_link(
                        m_pDecodePipelineInputSelector,
                        m_pDecodeOutputBin);
        if (!bDecodePipelineLinked)
        {
                Trace("m_pDecodePipeline didn't link\n");
                assert(FALSE);
        }
bDecodePipelineLinked = gst_element_link(m_pDecodeElement, m_pDecodePipelineInputSelector);
        if (!bDecodePipelineLinked)
        {
                Trace("DecodeElement->InputsSelector link failed\n");
                 assert(FALSE);
         }
        bDecodePipelineLinked = gst_element_link(pImageFreezeElement, m_pDecodePipelineInputSelector);
        if (!bDecodePipelineLinked)
        {
                Trace("ImageFreezeElement->InputsSelector link failed\n");
                assert(FALSE);
        }
        GstPad *pSinkpad;
        pSinkpad = gst_element_get_static_pad(m_pDecodePipelineInputSelector, "sink0");
        g_object_set(G_OBJECT(m_pDecodePipelineInputSelector), "active-pad", pSinkpad, NULL);
        gst_object_unref(pSinkpad);

and the rest of the pipeline..... code for selecting the active pad....


int myClass::SwitchSinks(int which)
{
        gint64 stop_time = 0;
        GstPad *pad;

        if (which == m_Which)      // is anything changing?
        {
                return(SUCCESS);
        }

        if (which)
        {
                pad = gst_element_get_static_pad(m_pDecodePipelineInputSelector, "sink1");
        }
        else
        {
                pad = gst_element_get_static_pad(m_pDecodePipelineInputSelector, "sink0");
        }
        g_signal_emit_by_name(m_pDecodePipelineInputSelector, "block", &stop_time);
        g_signal_emit_by_name(m_pDecodePipelineInputSelector, "switch", pad, -1, -1);
        gst_object_unref(pad);
        m_which = which;

        return(SUCCESS);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140502/cbc7275e/attachment.html>


More information about the gstreamer-devel mailing list