2 * Copyright (C) 2004-6 Zaheer Abbas Merali <zaheerabbas at merali dot org>
3 * Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 * The development of this code was made possible due to the involvement of Pioneers
23 * of the Inevitable, the creators of the Songbird Music player
27 #ifndef __GST_OSX_VIDEO_SINK_H__
28 #define __GST_OSX_VIDEO_SINK_H__
30 #include <gst/video/gstvideosink.h>
34 #include <objc/runtime.h>
35 #include <Cocoa/Cocoa.h>
37 #include <QuickTime/QuickTime.h>
38 #import "cocoawindow.h"
40 GST_DEBUG_CATEGORY_EXTERN (gst_debug_osx_video_sink);
41 #define GST_CAT_DEFAULT gst_debug_osx_video_sink
43 /* The hack doesn't work on leopard, the _CFMainPThread symbol
44 * is doesn't exist in the CoreFoundation library */
45 #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
46 #ifdef RUN_NS_APP_THREAD
47 #undef RUN_NS_APP_THREAD
53 #define GST_TYPE_OSX_VIDEO_SINK \
54 (gst_osx_video_sink_get_type())
55 #define GST_OSX_VIDEO_SINK(obj) \
56 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_OSX_VIDEO_SINK, GstOSXVideoSink))
57 #define GST_OSX_VIDEO_SINK_CLASS(klass) \
58 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_OSX_VIDEO_SINK, GstOSXVideoSinkClass))
59 #define GST_IS_OSX_VIDEO_SINK(obj) \
60 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_OSX_VIDEO_SINK))
61 #define GST_IS_OSX_VIDEO_SINK_CLASS(klass) \
62 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_OSX_VIDEO_SINK))
64 typedef struct _GstOSXWindow GstOSXWindow;
66 typedef struct _GstOSXVideoSink GstOSXVideoSink;
67 typedef struct _GstOSXVideoSinkClass GstOSXVideoSinkClass;
69 #define GST_TYPE_OSXVIDEOBUFFER (gst_osxvideobuffer_get_type())
72 struct _GstOSXWindow {
77 GstOSXVideoSinkWindow* win;
80 struct _GstOSXVideoSink {
81 /* Our element stuff */
82 GstVideoSink videosink;
83 GstOSXWindow *osxwindow;
84 void *osxvideosinkobject;
86 NSThread *ns_app_thread;
87 #ifdef RUN_NS_APP_THREAD
88 GMutex loop_thread_lock;
89 GCond loop_thread_cond;
93 GMutex mrl_check_lock;
95 gboolean mrl_check_done;
96 gboolean main_run_loop_running;
102 struct _GstOSXVideoSinkClass {
103 GstVideoSinkClass parent_class;
106 GType gst_osx_video_sink_get_type(void);
108 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
109 @interface NSApplication(AppleMenu)
110 - (void)setAppleMenu:(NSMenu *)menu;
114 @interface GstBufferObject : NSObject
120 -(id) initWithBuffer: (GstBuffer *) buf;
124 #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
125 @interface GstWindowDelegate : NSObject
127 @interface GstWindowDelegate : NSObject <NSWindowDelegate>
131 GstOSXVideoSink *osxvideosink;
133 -(id) initWithSink: (GstOSXVideoSink *) sink;
136 @interface GstOSXVideoSinkObject : NSObject
139 GstOSXVideoSink *osxvideosink;
142 -(id) initWithSink: (GstOSXVideoSink *) sink;
143 -(void) createInternalWindow;
146 -(void) showFrame: (GstBufferObject*) buf;
147 #ifdef RUN_NS_APP_THREAD
148 + (BOOL) isMainThread;
150 -(void) checkMainRunLoop;
156 #endif /* __GST_OSX_VIDEO_SINK_H__ */