gstreamer and qt interaction
pfarmer
flacone at gmx.de
Sat Mar 9 01:59:07 PST 2013
On 03/09/2013 03:01 AM, Mcnv [via GStreamer-devel] wrote:
> Hi,
> I have written a small application for playing a audio/video file in
> Gstreamer.
> now i want to display or redirect video/audio content to a specific
> window of Qt instead of launching a player window.
>
> request help on this.
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://gstreamer-devel.966125.n4.nabble.com/gstreamer-and-qt-interaction-tp4659016.html
>
> To start a new topic under GStreamer-devel, email
> ml-node+s966125n966125h77 at n4.nabble.com
> To unsubscribe from GStreamer-devel, click here
> <http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=966125&code=ZmxhY29uZUBnbXguZGV8OTY2MTI1fDY2NTk5NjY2OQ==>.
> NAML
> <http://gstreamer-devel.966125.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
You can use QtGStreamer
(http://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/).
For another way there is an example in the gstvideooverlay
documentation
(http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideooverlay.html)
Or you can use gst_app_sink. With gstreamer-1.0 and Linux:
If you have a Capture class with a pipeline with an appsink a callback
can be registered
GstElement* sink;
sink = gst_bin_get_by_name(GST_BIN(m_pipeline), "sink");
gst_app_sink_set_emit_signals(GST_APP_SINK(sink), TRUE);
g_signal_connect(sink, "new-sample", G_CALLBACK(newSample),
(gpointer)this);
gst_element_set_state(m_pipeline, GST_STATE_PLAYING);
This callback may look like this:
GstFlowReturn Capture::newSample(GstAppSink* sink, gpointer gSelf)
{
GstSample* sample = NULL;
GstBuffer* sampleBuffer = NULL;
GstMapInfo bufferInfo;
Capture* self = static_cast<Capture* >(gSelf);
sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
if(sample != NULL)
{
sampleBuffer = gst_sample_get_buffer(sample);
if(sampleBuffer != NULL)
{
gst_buffer_map(sampleBuffer, &bufferInfo, GST_MAP_READ);
self->m_mutex.lock();
self->m_image = QImage(bufferInfo.data, 320, 180,
QImage::Format_RGB888);
self->m_mutex.unlock();
gst_buffer_unmap(sampleBuffer, &bufferInfo);
}
gst_sample_unref(sample);
}
return GST_FLOW_OK;
}
The m_imgae can be returned with:
QImage Capture::getFrame()
{
QMutexLocker locker(&m_mutex);
return m_image;
}
With the private member variables of Capture
QImage m_image;
QMutex m_mutex;
The image can be displayed with e.g. a QLabel. With a subclassed QLabel
the image from the Capture can be continuously retrieved:
Display::Display(QWidget* parent) :
QLabel(parent),
m_capture(new Capture(this))
{
}
void Display::paintEvent(QPaintEvent* paintEvent)
{
setPixmap(QPixmap::fromImage(m_capture->getFrame()));
QLabel::paintEvent(paintEvent);
}
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/gstreamer-and-qt-interaction-tp4659016p4659017.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130309/d655c9cd/attachment.html>
More information about the gstreamer-devel
mailing list