How can I dynamically add a source to nvmultisrcbin when using service marker
When I tried using gst-nvmultisrcbincreator. h, I found that the service marker Pipeline.add() does not support * GstElement
Is there any other way
//pipeline.hpp
class Pipeline {
...
Pipeline& add(const std::string& element_type, const std::string& element_name, const Args&... args) {
Element element = Element(element_type, element_name);
if constexpr (sizeof...(args) > 0) {
element.set(args...);
}
return this->add(element);
}
/** @brief Add a given element to the pipeline */
Pipeline& add(Element element);
}
//element.hpp
class Element : public Object {
public:
/**
* @brief Constructor
*
* @param[in] type_name ehe type name for a specific element defined with Deepstream SDK
* @param[in] name name given to the Element instance
*/
Element(const std::string& type_name, std::string name = std::string());
/** @brief Downcast copy constructor from Object class */
Element(const Object&);
/** @brief Downcast move constructor from Object class */
Element(Object&&);
/** @brief Destructor */
virtual ~Element();
/**
* @brief Link two Element instances using hint
*
* @param[in] dst target element to which this element links
* @param[in] hint hint for the link, providing the source pad name and target pad name
* @return target element
*/
Element & link(Element &dst, std::pair<std::string, std::string> hint);
/**
* @brief Link two Element instances directly
*
* @param[in] dst target element to which this element links
* @return target element
*/
Element& link(Element &other);
/** @brief Find the buffer probe attached to the elmenent by name */
BufferProbe* getProbe(const std::string& name) {
return find_<BufferProbe>(name);
}
/**
* @brief Create and add a buffer probe to the element
*
* A buffer probe will be automatically created by the factory in the plugin.
*
* @param[in] plugin_name name of the plugin where the factory for the buffer probe is defined
* @param[in] probe_name name of the buffer probe to be added
* @param[in] probe_tip extra information for adding the probe, e.g name of the pad
*
*/
Element& addProbe(const std::string& plugin_name,
const std::string& probe_name,
const std::string probe_tip = "");
/** @brief Template function for creating and adding buffer probe with properties */
template<typename... Args>
Element& addProbe(const std::string& plugin_name,
const std::string& probe_name,
const std::string probe_tip = "",
const Args&... args) {
addProbe(plugin_name, probe_name, probe_tip);
auto probe = getProbe(probe_name);
if (probe && (sizeof...(args) > 0)) {
probe->set(args...);
}
return *this;
}
/**
* @brief Add a BufferProbe instance to the element
*
* Once the probe is added, the element will take the ownership
*
* @param[in] probe pointer to the buffer probe
* @param[in] probe_tip extra information for adding the probe, e.g name of the pad
*
*/
Element& addProbe(BufferProbe* probe, const std::string probe_tip = "");
/** @brief Find the signal handler attached to the element by name */
SignalHandler* getSignalHandler(const std::string& name) {
return find_<SignalHandler>(name);
}
/**
* @brief Connect a signal handler to the element
*
* A signal handler is responsible for handling the asynchronous signals emitted from
* the element. Signals behave like events and are defined by their names. Detailed
* information of signal types available within an element can be found from the Plugin
* Manual of Deepstream.
*
* Once connected, the element takes the ownership of the signal handler
*
* @param[in] signal_name name of the signal to which the handler is connected
* @param[in] probe_tip pointer to the signal handler
*
*/
Element& connectSignal(const std::string&signal_name, SignalHandler* handler);
/**
* @brief Create and connect a handler to element's signal
*
* A signal handler will be created automatically by the factory defined in the plugin
*
* @param[in] plugin_name name of the plugin where the factory of the signal handler is defined
* @param[in] handler_name name of the signal handler to be added
* @param[in] signal_names names of the signals for the handler to connect, separated by "/"
*
*/
Element& connectSignal(const std::string& plugin_name,
const std::string& handler_name,
const std::string& signal_names);
/** @brief Template function for creating and connecting signal with properties */
template<typename... Args>
Element& connectSignal(const std::string& plugin_name,
const std::string& handler_name,
const std::string& signal_names,
const Args&... args) {
connectSignal(plugin_name, handler_name, signal_names);
auto handler = getSignalHandler(handler_name);
if (handler && (sizeof...(args) > 0)) {
handler->set(args...);
}
return *this;
}
protected:
Element(GstObject* object);
Element& add_(CustomObject* object);
/**
* buffer probes, signal handlers, signal emitters are held by its target element as shared pointers.
*/
std::unordered_map<std::string, std::shared_ptr<CustomObject>> objects_;
template<class T>
T* find_(const std::string& name) {
auto itr = find_if(
objects_.begin(),
objects_.end(),
[&](const auto& pair) {
return pair.first == name && dynamic_cast<T*>(pair.second.get());
}
);
if (itr != objects_.end()) return dynamic_cast<T*>(itr->second.get());
return nullptr;
}
};
//gst-nvmultiurisrcbincreator.h
GstElement
*gst_nvmultiurisrcbincreator_get_bin (NvDst_Handle_NvMultiUriSrcCreator
apiHandle);
NvDst_Handle_NvMultiUriSrcCreator gst_nvmultiurisrcbincreator_init (gchar *
binName, NvDsMultiUriMode mode, GstDsNvStreammuxConfig * muxConfig);
gboolean
gst_nvmultiurisrcbincreator_add_source (NvDst_Handle_NvMultiUriSrcCreator
apiHandle, GstDsNvUriSrcConfig * sourceConfig);