Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add crop

  • Loading branch information...
commit eacf590b9bc3b81eb559d51a5e4b0517f14b512e 1 parent fafa4b5
Rob Clark authored
View
41 plugins/multimedia/gstreamer/qvideosurfacegstsink.cpp
@@ -384,7 +384,7 @@ void QVideoSurfaceGstSink::class_init(gpointer g_class, gpointer class_data)
base_sink_class->start = QVideoSurfaceGstSink::start;
base_sink_class->stop = QVideoSurfaceGstSink::stop;
// base_sink_class->unlock = QVideoSurfaceGstSink::unlock; // Not implemented.
- // base_sink_class->event = QVideoSurfaceGstSink::event; // Not implemented.
+ base_sink_class->event = QVideoSurfaceGstSink::event;
base_sink_class->preroll = QVideoSurfaceGstSink::preroll;
base_sink_class->render = QVideoSurfaceGstSink::render;
@@ -727,10 +727,43 @@ gboolean QVideoSurfaceGstSink::unlock(GstBaseSink *base)
gboolean QVideoSurfaceGstSink::event(GstBaseSink *base, GstEvent *event)
{
- Q_UNUSED(base);
- Q_UNUSED(event);
+ GstEventType type = GST_EVENT_TYPE (event);
+ VO_SINK(base);
- return TRUE;
+#define GST_CROP_EXTENSION
+#ifdef GST_CROP_EXTENSION
+ if (type == GST_EVENT_CROP) {
+ int bytesPerLine = sink->delegate->m_bytesPerLine;
+ QVideoSurfaceFormat format = sink->delegate->m_format;
+ gint top, left, width, height;
+
+ gst_event_parse_crop (event, &top, &left, &width, &height);
+
+ format.setViewport(QRect(left, top, width, height));
+
+ if (sink->delegate->isActive()) {
+ sink->delegate->stop();
+ }
+
+#ifdef DEBUG_VIDEO_SURFACE_SINK
+ qDebug() << "Cropping video surface, format:";
+ qDebug() << format;
+#endif
+
+ if (sink->delegate->start(format, bytesPerLine))
+ return TRUE;
+ else
+ qWarning() << "Failed to start video surface";
+
+ return TRUE;
+ }
+#endif
+
+ if (GST_BASE_SINK_CLASS(sink_parent_class)->event) {
+ return GST_BASE_SINK_CLASS(sink_parent_class)->event (base, event);
+ } else {
+ return TRUE;
+ }
}
GstFlowReturn QVideoSurfaceGstSink::preroll(GstBaseSink *base, GstBuffer *buffer)
View
5 plugins/multimedia/gstreamer/qvideosurfacegstsink.h
@@ -80,6 +80,9 @@ class QVideoSurfaceGstDelegate : public QObject
GstFlowReturn render(GstBuffer *buffer);
+ QVideoSurfaceFormat m_format;
+ int m_bytesPerLine;
+
private slots:
void queuedStart();
void queuedStop();
@@ -94,10 +97,8 @@ private slots:
QMutex m_mutex;
QWaitCondition m_setupCondition;
QWaitCondition m_renderCondition;
- QVideoSurfaceFormat m_format;
QVideoFrame m_frame;
GstFlowReturn m_renderReturn;
- int m_bytesPerLine;
bool m_started;
};
Please sign in to comment.
Something went wrong with that request. Please try again.