无法向BIN添加元素,在"回放功能"

时间:2016-09-09 06:47:20

标签: udp gstreamer

我想创建一个动态管道,需要根据读取文件进行修改" .ts"

在阅读中,文件我可能只有一个视频流,或者可能是两个视频,或者它也可能有文本数据。

如果文件有两个视频,那么如果我为文本数据添加两个视频链接和一个应用程序链接,那么我将无法播放该视频。

然后,我尝试在回调函数中添加该元素,然后每当文本数据到来时,它就不起作用。

这里我附上了代码。

void uuCMediaPlayer::DemuxLinking(GstElement *Demux, GstPad *DeMuxPad, gpointer data)
{
    uuCMediaPlayer* pObjPlayer = (uuCMediaPlayer *)data;
    int linkFlag = 0;

    char* pad_name = gst_pad_get_name(DeMuxPad);
    UU_PRINT("Player :: In dynamic ADDING PAD %s", pad_name);

    if(g_str_has_prefix(pad_name, "metadata"))
    {
        if(!gst_bin_add(GST_BIN(pObjPlayer->mpPlayerPipe), pObjPlayer->mpMetaSink))
        printf"Failed to Add Meta Sink !!");
        printf(" Player :: In dynamic ADDING Meta PAD %s", pad_name);
        GstPad *metasink = gst_element_get_static_pad(pObjPlayer->mpMetaQueue, "sink");
        if(GST_IS_PAD(DeMuxPad) && GST_IS_PAD(metasink))
        {
            if(gst_pad_link(DeMuxPad, metasink) != GST_PAD_LINK_OK)
            {
                UU_PRINT( "Player ::Failed to Link Demux with Meta Queue !!");
                pObjPlayer->mRunFlag = 0;
            }
            else
            {


                    gst_element_link_many(pObjPlayer->mpMetaQueue, pObjPlayer->mpMetaCapsFilter,
                        pObjPlayer->mpMetaKlvParse, pObjPlayer->mpMetaParseCapsFilter,
                        pObjPlayer->mpMetaSubParse, pObjPlayer->mpMetaSink, NULL);
                    //gst_bin_add_many(GST_BIN(pObjPlayer->mpPlayerPipe), pObjPlayer->mpMetaSink, NULL);
            }
        }
        else
        {
            UU_PRINT( "Player ::Failed to Link Demux with Meta Queue !!");
            pObjPlayer->mRunFlag = 0;
        }
    }
else if(g_str_has_prefix(pad_name, "video"))
{
    UU_PRINT("Player :: In dynamic ADDING VIDEO PAD %s", pad_name);
    if((!pObjPlayer->mDlLinkFlag) && (!linkFlag))
    {
        GstPad *dlsink = gst_element_get_static_pad(pObjPlayer->mpDlQueue, "sink");
        if(GST_IS_PAD(DeMuxPad) && GST_IS_PAD(dlsink))
        {
            if(gst_pad_link(DeMuxPad, dlsink) != GST_PAD_LINK_OK)
            {
                UU_PRINT( "Player :: Failed to Link Demux with DL Video Queue !!");
                pObjPlayer->mRunFlag = 0;
            }
            else
            {
                /** adding elements to bin */
                 gst_bin_add_many(GST_BIN(pObjPlayer->mpPlayerPipe), pObjPlayer->mpDLVideoDecoder,
                    pObjPlayer->mpDLVideoParse, pObjPlayer->mpDLVideoSink,
                    NULL);
                gst_element_link_many(pObjPlayer->mpMetaQueue, pObjPlayer->mpDLVideoDecoder,
                    pObjPlayer->mpDLVideoParse, pObjPlayer->mpDLVideoSink,
                    NULL);
            }
        }
        else
        {
            UU_PRINT( "Player :: Failed to Link Demux with DL Video Queue !!");
            pObjPlayer->mRunFlag = 0;
        }
    }
    else if((!pObjPlayer->mIrLinkFlag) && (!linkFlag))
    {
        GstPad *dlsink = gst_element_get_static_pad(pObjPlayer->mpIrQueue, "sink");
        if(GST_IS_PAD(DeMuxPad) && GST_IS_PAD(dlsink))
        {
            if(gst_pad_link(DeMuxPad, dlsink) != GST_PAD_LINK_OK)
            {
                UU_PRINT( "Player :: Failed to Link Demux with DL Video Queue !!");
                pObjPlayer->mRunFlag = 0;
            }
            else
            {
                pObjPlayer->mIrLinkFlag = 1;
                linkFlag = 1;
            }
        }
        else
        {
            UU_PRINT( "Player :: Failed to Link Demux with DL Video Queue !!");
            pObjPlayer->mRunFlag = 0;
        }
    }
    else
        UU_PRINT("Player :: Ignoring the Video Stream !!");
}

取代

pObjPlayer->mDlLinkFlag = 1;
                linkFlag = 1;

我将videodecoder和xvimagesink元素添加到管道箱。和,

我尝试将tsdemux与视频解码器和xvimagesink相关联。

但视频没有播放。如果我在回调函数之外添加那些,那么它工作正常。

1 个答案:

答案 0 :(得分:0)

使用gst1-java-core java绑定时遇到了类似的问题。我不得不在我在pad回调中添加到管道的bin上调用play()。我不确定你的非java代码中的确切方法调用是什么。

也许https://groups.google.com/d/msg/gstreamer-java/Zvf-3ZAhAwg/fekxcsJDCAAJ讨论的其他内容可以帮助您取得进步。