mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-09-25 21:20:07 +00:00
Add typefind element to pad menu
Allow to add and detect pad caps by typefind.
This commit is contained in:
parent
b8f3b20fa3
commit
2280d88b48
3 changed files with 29 additions and 9 deletions
|
@ -545,6 +545,7 @@ void GraphDisplay::showContextMenu(QMouseEvent *event)
|
|||
menu.addAction(new CustomMenuAction("Render", &menu));
|
||||
menu.addAction(new CustomMenuAction("Render anyway", &menu));
|
||||
menu.addAction(new CustomMenuAction("Pad properties", &menu));
|
||||
menu.addAction(new CustomMenuAction("typefind", "ElementName", &menu));
|
||||
}
|
||||
else if(elementId != ((size_t)-1))
|
||||
{
|
||||
|
@ -627,8 +628,8 @@ void GraphDisplay::showContextMenu(QMouseEvent *event)
|
|||
requestPad(elementId);
|
||||
else if (pact -> getName() == "Remove selected")
|
||||
removeSelected();
|
||||
else if(pact->getName() == "ElementName")
|
||||
addPlugin(pact->text());
|
||||
else if (pact->getName() == "ElementName")
|
||||
connectPlugin(elementId, pact->text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -672,11 +673,14 @@ void GraphDisplay::removePlugin(std::size_t id)
|
|||
}
|
||||
}
|
||||
|
||||
void GraphDisplay::addPlugin(const QString& name)
|
||||
void GraphDisplay::connectPlugin(std::size_t elementId, const QString& name)
|
||||
{
|
||||
ElementInfo* element = getElement(elementId);
|
||||
gchar* pluginName = m_pGraph->AddPlugin(name.toStdString().c_str(), NULL);
|
||||
m_pGraph->Connect(element->m_name.c_str(), pluginName);
|
||||
g_free(pluginName);
|
||||
}
|
||||
|
||||
|
||||
void GraphDisplay::showElementProperties(std::size_t id)
|
||||
{
|
||||
ElementInfo* element = getElement(id);
|
||||
|
@ -712,7 +716,6 @@ void GraphDisplay::renderPad(std::size_t elementId, std::size_t padId, bool caps
|
|||
|
||||
for (l = plugins_list; l != NULL; l = l->next) {
|
||||
Plugin* plugin = (Plugin*)(l->data);
|
||||
if (m_pGraph->CanConnect(element->m_name.c_str(), pad->m_name.c_str() , plugin->getName().toStdString().c_str())) {
|
||||
if (m_pGraph->CanConnect(element->m_name.c_str(), pad->m_name.c_str() , plugin->getName().toStdString().c_str(), capsAny)) {
|
||||
gchar* pluginName = m_pGraph->AddPlugin(plugin->getName().toStdString().c_str(), NULL);
|
||||
m_pGraph->Connect(element->m_name.c_str(), pluginName);
|
||||
|
|
|
@ -79,7 +79,7 @@ private:
|
|||
QPoint getPadPosition(std::size_t elementId, std::size_t padId);
|
||||
void disconnect(std::size_t elementId, std::size_t padId);
|
||||
void requestPad(std::size_t elementId);
|
||||
void addPlugin(const QString& name);
|
||||
void connectPlugin(std::size_t elementId, const QString& destElementName);
|
||||
|
||||
ElementInfo* getElement(std::size_t elementId);
|
||||
PadInfo* getPad(std::size_t elementId, std::size_t padId);
|
||||
|
|
|
@ -22,6 +22,16 @@ gchar* get_str_caps_limited(gchar* str)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
typefind_have_type_callback (GstElement * typefind,
|
||||
guint probability, GstCaps * caps, GraphManager * thiz)
|
||||
{
|
||||
gchar *caps_description = gst_caps_to_string (caps);
|
||||
qDebug() << "Found caps " << caps_description << " with probability " << probability;
|
||||
g_free(caps_description);
|
||||
thiz->Pause();
|
||||
}
|
||||
|
||||
GraphManager::GraphManager()
|
||||
{
|
||||
m_pGraph = gst_pipeline_new ("pipeline");
|
||||
|
@ -227,6 +237,14 @@ bool GraphManager::Connect(const char *srcElement, const char *dstElement)
|
|||
|
||||
gboolean seekRes = gst_element_seek_simple(m_pGraph, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 0);
|
||||
|
||||
/* add a callback to handle have-type signal */
|
||||
if (g_str_has_prefix(dstElement,"typefindelement")) {
|
||||
g_signal_connect (dst, "have-type",
|
||||
G_CALLBACK (typefind_have_type_callback),
|
||||
this);
|
||||
Play();
|
||||
}
|
||||
|
||||
gst_object_unref(src);
|
||||
gst_object_unref(dst);
|
||||
|
||||
|
@ -420,7 +438,7 @@ bool GraphManager::Play()
|
|||
qDebug() << "state changing to Play was FAILED";
|
||||
}
|
||||
|
||||
return res == GST_STATE_PLAYING;
|
||||
return state == GST_STATE_PLAYING;
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,10 +455,9 @@ bool GraphManager::Pause()
|
|||
qDebug() << "state changing to Pause was FAILED";
|
||||
}
|
||||
|
||||
return res == GST_STATE_PAUSED;
|
||||
return state == GST_STATE_PAUSED;
|
||||
}
|
||||
|
||||
|
||||
bool GraphManager::Stop()
|
||||
{
|
||||
GstStateChangeReturn res = gst_element_set_state(m_pGraph, GST_STATE_READY);
|
||||
|
|
Loading…
Reference in a new issue