osxvideo: straightforward port to 0.11

This commit is contained in:
Thiago Santos 2012-06-01 01:19:35 -03:00
parent 78ec03e32f
commit 44d010277c
3 changed files with 16 additions and 34 deletions

View File

@ -312,7 +312,7 @@ dnl Non ported plugins (non-dependant, then dependant)
dnl Make sure you have a space before and after all plugins dnl Make sure you have a space before and after all plugins
GST_PLUGINS_NONPORTED="deinterlace \ GST_PLUGINS_NONPORTED="deinterlace \
cairo cairo_gobject gdk_pixbuf \ cairo cairo_gobject gdk_pixbuf \
osx_video osx_audio " osx_audio "
AC_SUBST(GST_PLUGINS_NONPORTED) AC_SUBST(GST_PLUGINS_NONPORTED)
dnl these are all the gst plug-ins, compilable without additional libs dnl these are all the gst plug-ins, compilable without additional libs

View File

@ -29,7 +29,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <QuickTime/QuickTime.h> #import <QuickTime/QuickTime.h>
#import <glib.h> #import <glib.h>
#import <gst/interfaces/navigation.h> #import <gst/video/navigation.h>
struct _GstOSXImage; struct _GstOSXImage;

View File

@ -37,8 +37,8 @@
*/ */
#include "config.h" #include "config.h"
#include <gst/interfaces/xoverlay.h> #include <gst/video/videooverlay.h>
#include <gst/interfaces/navigation.h> #include <gst/video/navigation.h>
#include "osxvideosink.h" #include "osxvideosink.h"
#include <unistd.h> #include <unistd.h>
@ -56,14 +56,14 @@ static GstStaticPadTemplate gst_osx_video_sink_sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, " GST_STATIC_CAPS ("video/x-raw, "
"framerate = (fraction) [ 0, MAX ], " "framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], " "width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ], "
#if G_BYTE_ORDER == G_BIG_ENDIAN #if G_BYTE_ORDER == G_BIG_ENDIAN
"format = (fourcc) YUY2") "format = (string) YUY2")
#else #else
"format = (fourcc) UYVY") "format = (string) UYVY")
#endif #endif
); );
@ -121,7 +121,7 @@ gst_osx_video_sink_run_cocoa_loop (GstOSXVideoSink * sink )
* events and process deferred calls to the main thread through * events and process deferred calls to the main thread through
* perfermSelectorOnMainThread. * perfermSelectorOnMainThread.
* Since the sink needs to create it's own Cocoa window when no * Since the sink needs to create it's own Cocoa window when no
* external NSView is passed to the sink through the GstXOverlay API, * external NSView is passed to the sink through the GstVideoOverlay API,
* we need to run the cocoa mainloop somehow. * we need to run the cocoa mainloop somehow.
*/ */
if ([[NSRunLoop mainRunLoop] currentMode] == nil) { if ([[NSRunLoop mainRunLoop] currentMode] == nil) {
@ -215,7 +215,7 @@ gst_osx_video_sink_osxwindow_create (GstOSXVideoSink * osxvideosink, gint width,
/* have-ns-view wasn't handled, post prepare-xwindow-id */ /* have-ns-view wasn't handled, post prepare-xwindow-id */
if (osxvideosink->superview == NULL) { if (osxvideosink->superview == NULL) {
GST_INFO_OBJECT (osxvideosink, "emitting prepare-xwindow-id"); GST_INFO_OBJECT (osxvideosink, "emitting prepare-xwindow-id");
gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (osxvideosink)); gst_video_overlay_prepare_window_handle (GST_VIDEO_OVERLAY (osxvideosink));
} }
if (osxvideosink->superview != NULL) { if (osxvideosink->superview != NULL) {
@ -540,19 +540,6 @@ gst_osx_video_sink_class_init (GstOSXVideoSinkClass * klass)
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
} }
static gboolean
gst_osx_video_sink_interface_supported (GstImplementsInterface * iface, GType type)
{
g_assert (type == GST_TYPE_X_OVERLAY || type == GST_TYPE_NAVIGATION);
return TRUE;
}
static void
gst_osx_video_sink_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_osx_video_sink_interface_supported;
}
static void static void
gst_osx_video_sink_navigation_send_event (GstNavigation * navigation, gst_osx_video_sink_navigation_send_event (GstNavigation * navigation,
GstStructure * structure) GstStructure * structure)
@ -621,7 +608,7 @@ gst_osx_video_sink_navigation_init (GstNavigationInterface * iface)
} }
static void static void
gst_osx_video_sink_set_window_handle (GstXOverlay * overlay, guintptr handle_id) gst_osx_video_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle_id)
{ {
GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay); GstOSXVideoSink *osxvideosink = GST_OSX_VIDEO_SINK (overlay);
gulong window_id = (gulong) handle_id; gulong window_id = (gulong) handle_id;
@ -647,7 +634,7 @@ gst_osx_video_sink_set_window_handle (GstXOverlay * overlay, guintptr handle_id)
} }
static void static void
gst_osx_video_sink_xoverlay_init (GstXOverlayClass * iface) gst_osx_video_sink_xoverlay_init (GstVideoOverlayInterface * iface)
{ {
iface->set_window_handle = gst_osx_video_sink_set_window_handle; iface->set_window_handle = gst_osx_video_sink_set_window_handle;
iface->expose = NULL; iface->expose = NULL;
@ -684,12 +671,6 @@ gst_osx_video_sink_get_type (void)
(GInstanceInitFunc) gst_osx_video_sink_init, (GInstanceInitFunc) gst_osx_video_sink_init,
}; };
static const GInterfaceInfo iface_info = {
(GInterfaceInitFunc) gst_osx_video_sink_interface_init,
NULL,
NULL,
};
static const GInterfaceInfo overlay_info = { static const GInterfaceInfo overlay_info = {
(GInterfaceInitFunc) gst_osx_video_sink_xoverlay_init, (GInterfaceInitFunc) gst_osx_video_sink_xoverlay_init,
NULL, NULL,
@ -704,9 +685,7 @@ gst_osx_video_sink_get_type (void)
osxvideosink_type = g_type_register_static (GST_TYPE_VIDEO_SINK, osxvideosink_type = g_type_register_static (GST_TYPE_VIDEO_SINK,
"GstOSXVideoSink", &osxvideosink_info, 0); "GstOSXVideoSink", &osxvideosink_info, 0);
g_type_add_interface_static (osxvideosink_type, g_type_add_interface_static (osxvideosink_type, GST_TYPE_VIDEO_OVERLAY,
GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
g_type_add_interface_static (osxvideosink_type, GST_TYPE_X_OVERLAY,
&overlay_info); &overlay_info);
g_type_add_interface_static (osxvideosink_type, GST_TYPE_NAVIGATION, g_type_add_interface_static (osxvideosink_type, GST_TYPE_NAVIGATION,
&navigation_info); &navigation_info);
@ -814,16 +793,19 @@ gst_osx_video_sink_get_type (void)
- (void) showFrame: (GstBufferObject *) object - (void) showFrame: (GstBufferObject *) object
{ {
GstMapInfo info;
guint8 *viewdata; guint8 *viewdata;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GstBuffer *buf = object->buf; GstBuffer *buf = object->buf;
if (!destroyed) if (!destroyed)
{ {
gst_buffer_map (buf, &info, GST_MAP_READ);
viewdata = (guint8 *) [osxvideosink->osxwindow->gstview getTextureBuffer]; viewdata = (guint8 *) [osxvideosink->osxwindow->gstview getTextureBuffer];
memcpy (viewdata, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); memcpy (viewdata, info.data, info.size);
[osxvideosink->osxwindow->gstview displayTexture]; [osxvideosink->osxwindow->gstview displayTexture];
gst_buffer_unmap (buf, &info);
} }
[object release]; [object release];