gstreamermm  1.10.0
basics/element_factory.cc

A gstreamermm Gst::ElementFactory example.

/*
* This example presents how to use Gst::ElementFactory class, getting
* information and create specific element.
*/
#include <gstreamermm.h>
#include <iostream>
int main(int argc, char *argv[])
{
Gst::init(argc, argv);
// Get list of all primary demuxers in the system
std::cout << "List of primary demuxers: " << std::endl;
{
std::cout << " * " << factory->get_name() << std::endl;
}
if (!fakesrc_factory)
{
std::cerr << "Failed to find factory of type 'fakesrc'" << std::endl;
return -1;
}
// Read information about an author of the element
std::cout << "Author of the element '" << fakesrc_factory->get_name() << "' is "
<< fakesrc_factory->get_metadata(GST_ELEMENT_METADATA_AUTHOR) << std::endl << std::endl;
// Read all available information about the element
std::cout << "All information about element '" << fakesrc_factory->get_name() << "':" << std::endl;
for (auto metadata_key : fakesrc_factory->get_metadata_keys())
{
std::cout << " * " << metadata_key << ": " << fakesrc_factory->get_metadata(metadata_key) << std::endl;
}
// Create element fakesrc
// Method 1
{
Glib::RefPtr<Gst::Element> fakesrc = fakesrc_factory->create("source");
if (!fakesrc)
{
std::cerr << "Failed to create element of type 'fakesrc'" << std::endl;
return -1;
}
}
// Method 2
{
if (!fakesrc)
{
std::cerr << "Failed to create element of type 'fakesrc'" << std::endl;
return -1;
}
}
return 0;
}
iostream
Gst::ELEMENT_FACTORY_TYPE_DEMUXER
@ ELEMENT_FACTORY_TYPE_DEMUXER
Definition: elementfactory.h:55
Gst::ElementFactory::find
static Glib::RefPtr< Gst::ElementFactory > find(const Glib::ustring &name)
Search for an element factory of the given name.
std::cout
ostream cout
std::cerr
ostream cerr
Gst::ElementFactory::create_element
static Glib::RefPtr< Gst::Element > create_element(const Glib::ustring &factory_name, const Glib::ustring &name)
Create a new element of the type defined by the given element factory.
Glib::RefPtr
Gst::RANK_PRIMARY
@ RANK_PRIMARY
Definition: pluginfeature.h:79
Gst::init
void init(int &argc, char **&argv)
Initializes gstreamermm parsing command line arguments.
Gst::ElementFactory::get_elements
static std::vector< Glib::RefPtr< Gst::ElementFactory > > get_elements(ElementFactoryListType type, Rank minrank)
Get a list of factories that match the given type.
std::endl
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)