我想创建一个动态管道,它需要根据读取文件".ts"进行修改
在读取中,文件i可能只有一个视频流,也可能有两个视频流,或者也可能有文本数据。
如果文件有两个视频,那么如果我添加两个videosinks和一个appsink用于文本数据,那么我就无法播放视频。
然后,我尝试在回调函数中添加该元素,然后无论何时文本数据来,它都不工作。
我附上了代码。
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;
我将视频解码器和xvimagesink元素添加到管道bin。,
我尝试将tsdemux与视频解码器连接,然后连接xvimagesink。
但是视频没有播放。如果我在回调函数之外添加这些,那么它会工作得很好。
我在使用gst1-java-core java绑定时遇到了类似的问题。我必须在pad回调中添加到管道中的箱子上调用play()。我不确定在你的非java代码中确切的方法调用是什么。
也许https://groups.google.com/d/msg/gstreamer-java/Zvf-3ZAhAwg/fekxcsJDCAAJ上讨论的其他元素会帮助你取得进展。