I am using Gstreamer 1.0
I have run this following sample code on terminal:
gst-launch-1.0 -v videotestsrc ! videoconvert ! autovideosink
And the response of this is (This is the output on terminal):
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, format=(string)YV12, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, format=(string)YV12, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, format=(string)YV12, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage.GstPad:sink: caps = video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, format=(string)YV12, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, format=(string)YV12, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, width=(int)320, height=(int)240, framerate=(fraction)30/1, multiview-mode=(string)mono, format=(string)YV12, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
I have created the elements and the Pas templates, I am not sure where in the code do I add (if that is the term here to use) or initialise them.
Objective. I want to exactly replicate the command (that is given above) in C++. My code up till now is given below:
#include <iostream>
#include <gst/gst.h>
#include <gst/rtp/gstrtpbuffer.h>
GstStaticPadTemplate my_srctemplate = GST_STATIC_PAD_TEMPLATE ("src", // the name of the pad
GST_PAD_SRC, // the direction of the pad
GST_PAD_ALWAYS, // when this pad will be present
GST_STATIC_CAPS ( // the capabilities of the padtemplate
"video/x-raw, "
"width=(int)320,"
"height=(int)240,"
"framerate=(fraction)30/1,"
"multiview-mode=(string)mono"
"format=(string)YV12,"
"pixel-aspect-ratio=(fraction)1/1,"
"framerate=(fraction)30/1,"
"interlace-mode=(string)progressive"
)
);
GstStaticPadTemplate my_sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", // the name of the pad
GST_PAD_SINK, // the direction of the pad
GST_PAD_ALWAYS, // when this pad will be present
GST_STATIC_CAPS ( // the capabilities of the padtemplate
"video/x-raw, "
"width=(int)320,"
"height=(int)240,"
"framerate=(fraction)30/1,"
"multiview-mode=(string)mono"
"format=(string)YV12,"
"pixel-aspect-ratio=(fraction)1/1,"
"framerate=(fraction)30/1,"
"interlace-mode=(string)progressive"
)
);
gchar *ElementName(GstElement *varname)
{
gchar *givenname;
g_object_get (G_OBJECT(varname), "name", &givenname, NULL);
return(givenname);
}
int createLocalElement(GstElement *varname,GstElementFactory *factoryname,const gchar *givenname)
{
gchar *elementname;
varname = gst_element_factory_create(factoryname, givenname);
if (!varname)
return(-1);
elementname = ElementName(varname);
std::cout << "Element created : " << elementname << std::endl;
//g_free (elementname);
return(0);
}
The Main function:
int main(int argc, char *argv[])
{
GstElement *pipeline,*sink,*convertVdo,*source;
GstElementFactory *source_factory, *sink_factory,*middlelayer_factory;
GstStateChangeReturn ReturnStat;
gst_init (&argc, &argv);
/* Find factories for the elements */
source_factory = gst_element_factory_find ("videotestsrc");
sink_factory = gst_element_factory_find ("autovideosink");
middlelayer_factory = gst_element_factory_find ("videoconvert");
/* create element */
if(0!=createLocalElement(sink, sink_factory, "VdoSink")){
g_print ("Failed to create element of type 'autovideosink'\n");
return(-1);
}
if(0!=createLocalElement(convertVdo, middlelayer_factory, "VdoCnvrt")){
g_print ("Failed to create element of type 'videoconvert'\n");
return(-1);
}
if(0!=createLocalElement(source, source_factory, "VdoSrc")){
g_print ("Failed to create element of type 'videotestsrc'\n");
return(-1);
}
/* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");
/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
/* Link the elemnts in pipeline */
if(gst_element_link_many (source, convertVdo, sink, NULL) != TRUE) {
g_printerr ("Elements could not be linked : %s to %s to %s\n",ElementName(source), ElementName(convertVdo), ElementName(sink));
gst_object_unref (pipeline);
return -1;
}
/* Start playing */
ReturnStat = gst_element_set_state (pipeline, GST_STATE_PAUSED);
if (ReturnStat == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state (check the bus for error messages).\n");
}
g_printerr ("Pipeline set to the Paused state \n");
// gst_object_unref (GST_OBJECT (pipeline));
std::cout << "Elements unreferenced" << std::endl;
//std::cout << "This program is linked against GStreamer" << std::endl;
return(0);
}
Any help is appreciated :)
Regards,
Aucun commentaire:
Enregistrer un commentaire