osxvideosink: use the video frame API instead of the video meta API

https://bugzilla.gnome.org/show_bug.cgi?id=726738
This commit is contained in:
Matthieu Bouron 2014-03-19 19:18:11 +00:00 committed by Edward Hervey
parent c6dcd3689d
commit 7ac0204625
2 changed files with 16 additions and 6 deletions

View file

@ -27,6 +27,7 @@
#ifndef __GST_OSX_VIDEO_SINK_H__ #ifndef __GST_OSX_VIDEO_SINK_H__
#define __GST_OSX_VIDEO_SINK_H__ #define __GST_OSX_VIDEO_SINK_H__
#include <gst/video/video.h>
#include <gst/video/gstvideosink.h> #include <gst/video/gstvideosink.h>
#include <string.h> #include <string.h>
@ -83,6 +84,7 @@ struct _GstOSXVideoSink {
NSView *superview; NSView *superview;
gboolean keep_par; gboolean keep_par;
gboolean embed; gboolean embed;
GstVideoInfo info;
}; };
struct _GstOSXVideoSinkClass { struct _GstOSXVideoSinkClass {

View file

@ -375,6 +375,9 @@ gst_osx_video_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
gst_osx_video_sink_osxwindow_resize (osxvideosink, osxvideosink->osxwindow, gst_osx_video_sink_osxwindow_resize (osxvideosink, osxvideosink->osxwindow,
video_width, video_height); video_width, video_height);
gst_video_info_from_caps (&osxvideosink->info, caps);
result = TRUE; result = TRUE;
beach: beach:
@ -875,8 +878,7 @@ gst_osx_video_sink_get_type (void)
- (void) showFrame: (GstBufferObject *) object - (void) showFrame: (GstBufferObject *) object
{ {
GstMapInfo info; GstVideoFrame frame;
GstVideoMeta *vmeta;
guint8 *data, *readp, *writep; guint8 *data, *readp, *writep;
gint i, active_width, stride; gint i, active_width, stride;
guint8 *texture_buffer; guint8 *texture_buffer;
@ -891,9 +893,11 @@ gst_osx_video_sink_get_type (void)
if (G_UNLIKELY (texture_buffer == NULL)) if (G_UNLIKELY (texture_buffer == NULL))
goto no_texture_buffer; goto no_texture_buffer;
vmeta = (GstVideoMeta *) gst_buffer_get_meta (buf, GST_VIDEO_META_API_TYPE); if (!gst_video_frame_map (&frame, &osxvideosink->info, buf, GST_MAP_READ))
gst_video_meta_map (vmeta, 0, &info, (gpointer *) &data, &stride, GST_MAP_READ); goto no_map;
readp = data;
data = readp = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0);
writep = texture_buffer; writep = texture_buffer;
active_width = GST_VIDEO_SINK_WIDTH (osxvideosink) * sizeof (short); active_width = GST_VIDEO_SINK_WIDTH (osxvideosink) * sizeof (short);
for (i = 0; i < GST_VIDEO_SINK_HEIGHT (osxvideosink); i++) { for (i = 0; i < GST_VIDEO_SINK_HEIGHT (osxvideosink); i++) {
@ -903,7 +907,7 @@ gst_osx_video_sink_get_type (void)
} }
[osxvideosink->osxwindow->gstview displayTexture]; [osxvideosink->osxwindow->gstview displayTexture];
gst_video_meta_unmap (vmeta, 0, &info); gst_video_frame_unmap (&frame);
out: out:
GST_OBJECT_UNLOCK (osxvideosink); GST_OBJECT_UNLOCK (osxvideosink);
@ -912,6 +916,10 @@ out:
[pool release]; [pool release];
return; return;
no_map:
GST_WARNING_OBJECT (osxvideosink, "couldn't map frame");
goto out;
no_window: no_window:
GST_WARNING_OBJECT (osxvideosink, "not showing frame since we have no window (!?)"); GST_WARNING_OBJECT (osxvideosink, "not showing frame since we have no window (!?)");
goto out; goto out;