mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2025-01-25 08:08:15 +00:00
commit
efc87dea12
4 changed files with 124 additions and 0 deletions
|
@ -24,6 +24,33 @@ GraphDisplay::GraphDisplay(QWidget *parent, Qt::WindowFlags f):
|
|||
QWidget(parent, f)
|
||||
{
|
||||
setFocusPolicy(Qt::WheelFocus);
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
ElementInfo* GraphDisplay::getElement(std::size_t elementId)
|
||||
{
|
||||
ElementInfo* element = NULL;
|
||||
std::size_t i=0;
|
||||
for(; i<m_info.size(); i++)
|
||||
{
|
||||
if(m_info[i].m_id == elementId) {
|
||||
element = &m_info[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
PadInfo* GraphDisplay::getPad(ElementInfo* element, std::size_t padId)
|
||||
{
|
||||
PadInfo* pad = NULL;
|
||||
std::size_t j=0;
|
||||
for(; j<element->m_pads.size(); j++)
|
||||
if(element->m_pads[j].m_id == padId) {
|
||||
pad = &element->m_pads[j];
|
||||
break;
|
||||
}
|
||||
return pad;
|
||||
}
|
||||
|
||||
void GraphDisplay::updateDisplayInfoIds()
|
||||
|
@ -467,6 +494,18 @@ void GraphDisplay::mouseMoveEvent(QMouseEvent *event)
|
|||
{
|
||||
m_moveInfo.m_position = event -> pos();
|
||||
repaint();
|
||||
} else {
|
||||
std::size_t elementId, padId;
|
||||
getIdByPosition(event -> pos(), elementId, padId);
|
||||
if (padId != ((size_t)-1)) {
|
||||
ElementInfo* element = getElement(elementId);
|
||||
PadInfo* pad = getPad(element, padId);
|
||||
QString caps = m_pGraph->getPadCaps(element,pad,PAD_CAPS_ALL,true);
|
||||
setToolTip(caps);
|
||||
}
|
||||
else
|
||||
setToolTip("");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,9 @@ private:
|
|||
void disconnect(std::size_t elementId, std::size_t padId);
|
||||
void requestPad(std::size_t elementId);
|
||||
|
||||
ElementInfo* getElement(std::size_t elementId);
|
||||
PadInfo* getPad(ElementInfo* element, std::size_t padId);
|
||||
|
||||
std::vector <ElementInfo> m_info;
|
||||
std::vector <ElementDisplayInfo> m_displayInfo;
|
||||
|
||||
|
|
|
@ -8,6 +8,19 @@
|
|||
|
||||
#include "CustomSettings.h"
|
||||
|
||||
#define MAX_STR_CAPS_SIZE 150
|
||||
gchar* get_str_caps_limited(gchar* str)
|
||||
{
|
||||
gchar* result;
|
||||
if(strlen(str) > MAX_STR_CAPS_SIZE) {
|
||||
result = g_strndup(str, MAX_STR_CAPS_SIZE);
|
||||
for(int i = strlen(result)-1;i > strlen(result)-4 ;i--)
|
||||
result[i] = '.';
|
||||
} else
|
||||
result = g_strdup(str);
|
||||
return result;
|
||||
}
|
||||
|
||||
GraphManager::GraphManager()
|
||||
{
|
||||
m_pGraph = gst_pipeline_new ("pipeline");
|
||||
|
@ -19,6 +32,65 @@ GraphManager::~GraphManager()
|
|||
|
||||
}
|
||||
|
||||
QString GraphManager::getPadCaps(ElementInfo* elementInfo, PadInfo* padInfo, ePadCapsSubset subset, bool afTruncated)
|
||||
{
|
||||
QString padCaps = "";
|
||||
if(!elementInfo || !padInfo)
|
||||
return padCaps;
|
||||
|
||||
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraph), elementInfo->m_name.c_str());
|
||||
|
||||
if(!element)
|
||||
return padCaps;
|
||||
GstPad *pad = gst_element_get_static_pad(GST_ELEMENT(element), padInfo->m_name.c_str());
|
||||
if(!pad) {
|
||||
gst_object_unref(element);
|
||||
return padCaps;
|
||||
}
|
||||
GstCaps *caps;
|
||||
switch(subset)
|
||||
{
|
||||
case PAD_CAPS_ALLOWED:
|
||||
caps = gst_pad_get_allowed_caps(pad);
|
||||
break;
|
||||
case PAD_CAPS_NEGOCIATED:
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
caps = gst_pad_get_current_caps(pad, NULL);
|
||||
#else
|
||||
caps = gst_pad_get_negotiated_caps(pad);
|
||||
#endif
|
||||
break;
|
||||
case PAD_CAPS_ALL:
|
||||
default:
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
caps = gst_pad_query_caps(pad, NULL);
|
||||
#else
|
||||
caps = gst_pad_get_caps(pad);
|
||||
#endif
|
||||
}
|
||||
#if GST_VERSION_MAJOR >= 1
|
||||
caps = gst_pad_query_caps(pad, NULL);
|
||||
#else
|
||||
caps = gst_pad_get_caps(pad);
|
||||
#endif
|
||||
if(caps) {
|
||||
gchar* str = gst_caps_to_string(caps);
|
||||
if (afTruncated) {
|
||||
gchar* str_limited = get_str_caps_limited(str);
|
||||
g_free(str);
|
||||
padCaps = str_limited;
|
||||
g_free(str_limited);
|
||||
} else {
|
||||
padCaps = str;
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gst_object_unref(element);
|
||||
gst_object_unref (pad);
|
||||
return padCaps;
|
||||
}
|
||||
|
||||
bool GraphManager::AddPlugin(const char *plugin, const char *name)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class QString;
|
||||
|
||||
enum ePadCapsSubset {
|
||||
PAD_CAPS_ALLOWED = 0,
|
||||
PAD_CAPS_NEGOCIATED,
|
||||
PAD_CAPS_ALL
|
||||
};
|
||||
|
||||
struct PadInfo
|
||||
{
|
||||
public:
|
||||
|
@ -94,6 +102,8 @@ public:
|
|||
bool Pause();
|
||||
bool Stop();
|
||||
|
||||
QString getPadCaps(ElementInfo* elementInfo, PadInfo* padInfo, ePadCapsSubset subset, bool afTruncated = false);
|
||||
|
||||
GstElement *m_pGraph;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue