#include <gst/gstinfo.h>
GST_DEBUG_CATEGORY_EXTERN (gst_debug_ximagesink);
+GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
#define GST_CAT_DEFAULT gst_debug_ximagesink
typedef struct
ximagesink->xwindow = gst_ximagesink_xwindow_new (ximagesink,
GST_VIDEO_SINK_WIDTH (ximagesink), GST_VIDEO_SINK_HEIGHT (ximagesink));
}
+
+ ximagesink->info = info;
+
/* Remember to draw borders for next frame */
ximagesink->draw_border = TRUE;
to_put = buf;
res = GST_FLOW_OK;
} else {
- guint8 *data;
- gsize size;
+ GstVideoFrame src, dest;
/* Else we have to copy the data into our private image, */
/* if we have one... */
if (gst_buffer_get_size (to_put) < gst_buffer_get_size (buf))
goto wrong_size;
- data = gst_buffer_map (to_put, &size, NULL, GST_MAP_WRITE);
- gst_buffer_extract (buf, 0, data, size);
- gst_buffer_unmap (to_put, data, size);
+ GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, ximagesink,
+ "slow copy into bufferpool buffer %p", to_put);
+
+ if (!gst_video_frame_map (&src, &ximagesink->info, buf, GST_MAP_READ))
+ goto invalid_buffer;
+
+ if (!gst_video_frame_map (&dest, &ximagesink->info, to_put, GST_MAP_WRITE)) {
+ gst_video_frame_unmap (&src);
+ goto invalid_buffer;
+ }
+
+ gst_video_frame_copy (&dest, &src);
+
+ gst_video_frame_unmap (&dest);
+ gst_video_frame_unmap (&src);
}
if (!gst_ximagesink_ximage_put (ximagesink, to_put))
res = GST_FLOW_ERROR;
goto done;
}
+invalid_buffer:
+ {
+ /* No Window available to put our image into */
+ GST_WARNING_OBJECT (ximagesink, "could map image");
+ res = GST_FLOW_OK;
+ goto done;
+ }
no_window:
{
/* No Window available to put our image into */
#include <string.h>
#include <math.h>
+/* Helper functions */
+#include <gst/video/video.h>
+
G_BEGIN_DECLS
#define GST_TYPE_XIMAGESINK \
(gst_ximagesink_get_type())
GThread *event_thread;
gboolean running;
+ GstVideoInfo info;
+
/* Framerate numerator and denominator */
gint fps_n;
gint fps_d;
#include <gst/interfaces/colorbalance.h>
#include <gst/interfaces/propertyprobe.h>
/* Helper functions */
-#include <gst/video/video.h>
#include <gst/video/gstmetavideo.h>
/* Object header */
GST_VIDEO_SINK_HEIGHT (xvimagesink));
}
+ xvimagesink->info = info;
+
/* After a resize, we want to redraw the borders in case the new frame size
* doesn't cover the same area */
xvimagesink->redraw_border = TRUE;
to_put = buf;
res = GST_FLOW_OK;
} else {
- guint8 *data;
- gsize size;
+ GstVideoFrame src, dest;
/* Else we have to copy the data into our private image, */
/* if we have one... */
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, xvimagesink,
"slow copy into bufferpool buffer %p", to_put);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- gst_buffer_fill (to_put, 0, data, size);
- gst_buffer_unmap (buf, data, size);
+ if (!gst_video_frame_map (&src, &xvimagesink->info, buf, GST_MAP_READ))
+ goto invalid_buffer;
+
+ if (!gst_video_frame_map (&dest, &xvimagesink->info, to_put, GST_MAP_WRITE)) {
+ gst_video_frame_unmap (&src);
+ goto invalid_buffer;
+ }
+
+ gst_video_frame_copy (&dest, &src);
+
+ gst_video_frame_unmap (&dest);
+ gst_video_frame_unmap (&src);
}
if (!gst_xvimagesink_xvimage_put (xvimagesink, to_put))
res = GST_FLOW_ERROR;
goto done;
}
+invalid_buffer:
+ {
+ /* No Window available to put our image into */
+ GST_WARNING_OBJECT (xvimagesink, "could map image");
+ res = GST_FLOW_OK;
+ goto done;
+ }
no_window:
{
/* No Window available to put our image into */
#include <math.h>
#include <stdlib.h>
+/* Helper functions */
+#include <gst/video/video.h>
+
G_BEGIN_DECLS
#define GST_TYPE_XVIMAGESINK \
(gst_xvimagesink_get_type())
GThread *event_thread;
gboolean running;
+ GstVideoInfo info;
+
/* Framerate numerator and denominator */
gint fps_n;
gint fps_d;