Upgraded gstreamer 0.1 to 1.0 pipeline stopped to work!
atelyshev
aleksey.telyshev at gmail.com
Mon Oct 30 01:19:35 UTC 2017
Hello,
probably anybody can point me to the problem. I am reading from ip-camara,
make some framerate and size corrections and pass it to my own code.
Gstreamer 0.1 was fine, but I wanted to upgrade code base and currently in
troubles. Here the code:
GstElement* IpCameraPipeline::CreateSource()
{
GstElement* source = gst_element_factory_make("uridecodebin", "source");
//g_object_set (pipelineBase->_uriDecodeBin, "uri",
"http://193.201.74.114:80/mjpg/video.mjpg", NULL);
g_object_set(G_OBJECT(source), "uri", _uri.c_str(), nullptr);
//Connect to the pad-added signal of the uridecodebin element
g_signal_connect(source, "pad-added", G_CALLBACK(PadAddedHandler), this);
//Connect to the source-setup signal of the uridecodebin element
g_signal_connect(source, "source-setup", G_CALLBACK(SourceSetupHandler),
this);
g_signal_connect(source, "drained", G_CALLBACK(DrainedHandler), this);
return source;
}
*Then build pipeline
*
GSPipelineBase *pipelineBase = (GSPipelineBase*)data;
pipelineBase->_sourceElement = pipelineBase->CreateSource();
pipelineBase->_videoScale = gst_element_factory_make("videoscale",
"videoscale");
pipelineBase->_videoRate = gst_element_factory_make("videorate",
"videorate");
pipelineBase->_videoScaleCapsFilter =
gst_element_factory_make("capsfilter", "videoscalecapsfilter");
pipelineBase->_videoRateCapsFilter = gst_element_factory_make("capsfilter",
"videoratecapsfilter");
pipelineBase->_videoConverter = gst_element_factory_make("videoconvert",
"videoconverter");
pipelineBase->_appSinkQueue = gst_element_factory_make("queue",
"appsinkqueue");
pipelineBase->_appSink = gst_element_factory_make("appsink", "sink");
gst_bin_add_many(GST_BIN(pipelineBase->_pipeline),
pipelineBase->_sourceElement,
pipelineBase->_videoRate,
pipelineBase->_videoRateCapsFilter,
pipelineBase->_videoScale,
pipelineBase->_videoScaleCapsFilter,
pipelineBase->_videoConverter,
pipelineBase->_appSinkQueue,
pipelineBase->_appSink,
nullptr);
if (!pipelineBase->LinkElements())
{
LOG_ERROR("GSPipelineBase error: Unable to link all elements");
return false;
}
//Sets relevant properties for the elements in the pipeline
//Set the caps filter to DCIF size. This will force the videoscale element
to scale the video to DCIF size.
rawVideoScaleCaps = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, "YUY2",
"width", G_TYPE_INT, GSPipelineBase::FRAME_WIDTH,
"height", G_TYPE_INT, GSPipelineBase::FRAME_HEIGHT, nullptr);
g_object_set(pipelineBase->_videoScaleCapsFilter, "caps",
rawVideoScaleCaps, nullptr);
gst_caps_unref(rawVideoScaleCaps);
rawVideoRateCaps = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, "YUY2",
"framerate", GST_TYPE_FRACTION, GSPipelineBase::FRAMERATE_NUMERATOR,
GSPipelineBase::FRAMERATE_DENOMINATOR, nullptr);
g_object_set(pipelineBase->_videoRateCapsFilter, "caps", rawVideoRateCaps,
nullptr);
gst_caps_unref(rawVideoRateCaps);
//Configure the appsink element
appSinkCaps = gst_caps_from_string("video/x-raw");
g_object_set(pipelineBase->_appSink, "emit-signals", TRUE, "caps",
appSinkCaps, nullptr);
//g_object_set(pipelineBase->_appSink, "emit-signals", TRUE, NULL);
gst_caps_unref(appSinkCaps);
//Connect to the new-buffer signal so we can retrieve samples without
blocking
g_signal_connect(pipelineBase->_appSink, "new-sample",
G_CALLBACK(pipelineBase->NewSampleHandler), pipelineBase);
if (!GSPipelineBase::ChangeElementState(pipelineBase->_pipeline,
GST_STATE_PLAYING))
{
LOG_ERROR("GSPipelineBase: Unable to set the pipeline to the playing
state.");
return false;
}
bus = gst_pipeline_get_bus(GST_PIPELINE(pipelineBase->_pipeline));
pipelineBase->_busWatchId = gst_bus_add_watch(bus, BusWatchHandler,
pipelineBase);
gst_object_unref(bus);
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipelineBase->_pipeline),
GST_DEBUG_GRAPH_SHOW_ALL, "graph.dot");
return false;
}
gboolean GSPipelineBase::LinkElements()
{
if (!gst_element_link_many(
_videoRate,
_videoRateCapsFilter,
_videoScale,
_videoScaleCapsFilter,
_videoConverter,
_appSinkQueue,
_appSink,
nullptr))
{
return false;
}
return true;
}
// And finally link all
gboolean IpCameraPipeline::LinkElements()
{
if (!GSPipelineBase::LinkElements())
{
return false;
}
if (!gst_element_link_many(_sourceElement, _videoRate, nullptr))
{
return false;
}
return true;
}
function
gboolean IpCameraPipeline::LinkElements()
returns false, pipeline cant be created.
Then I removed this part
if (!gst_element_link_many(_sourceElement, _videoRate, nullptr))
{
return false;
}
I did it for web camera and it worked, but it also didnt help.
What is going on, why I cant complete pipeline anymore ?
Thanks
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list