• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2004-6 Zaheer Abbas Merali <zaheerabbas at merali dot org>
3  * Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
4  *
5  *
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.
10  *
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.
15  *
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.
20  *
21  *
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
24  *
25  */
26 
27 #ifndef __GST_OSX_VIDEO_SINK_H__
28 #define __GST_OSX_VIDEO_SINK_H__
29 
30 #include <gst/video/video.h>
31 #include <gst/video/gstvideosink.h>
32 
33 #include <string.h>
34 #include <math.h>
35 #include <objc/runtime.h>
36 #include <Cocoa/Cocoa.h>
37 
38 #import "cocoawindow.h"
39 
40 GST_DEBUG_CATEGORY_EXTERN (gst_debug_osx_video_sink);
41 #define GST_CAT_DEFAULT gst_debug_osx_video_sink
42 
43 G_BEGIN_DECLS
44 
45 #define GST_TYPE_OSX_VIDEO_SINK \
46   (gst_osx_video_sink_get_type())
47 #define GST_OSX_VIDEO_SINK(obj) \
48   (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_OSX_VIDEO_SINK, GstOSXVideoSink))
49 #define GST_OSX_VIDEO_SINK_CLASS(klass) \
50   (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_OSX_VIDEO_SINK, GstOSXVideoSinkClass))
51 #define GST_IS_OSX_VIDEO_SINK(obj) \
52   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_OSX_VIDEO_SINK))
53 #define GST_IS_OSX_VIDEO_SINK_CLASS(klass) \
54   (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_OSX_VIDEO_SINK))
55 
56 typedef struct _GstOSXWindow GstOSXWindow;
57 
58 typedef struct _GstOSXVideoSink GstOSXVideoSink;
59 typedef struct _GstOSXVideoSinkClass GstOSXVideoSinkClass;
60 
61 #define GST_TYPE_OSXVIDEOBUFFER (gst_osxvideobuffer_get_type())
62 
63 typedef enum {
64   GST_OSX_VIDEO_SINK_RUN_LOOP_STATE_NOT_RUNNING = 0,
65   GST_OSX_VIDEO_SINK_RUN_LOOP_STATE_RUNNING = 1,
66   GST_OSX_VIDEO_SINK_RUN_LOOP_STATE_UNKNOWN = 2,
67 } GstOSXVideoSinkRunLoopState;
68 
69 /* OSXWindow stuff */
70 struct _GstOSXWindow {
71   gint width, height;
72   gboolean closed;
73   gboolean internal;
74   GstGLView* gstview;
75   GstOSXVideoSinkWindow* win;
76 };
77 
78 struct _GstOSXVideoSink {
79   /* Our element stuff */
80   GstVideoSink videosink;
81   GstOSXWindow *osxwindow;
82   void *osxvideosinkobject;
83   NSView *superview;
84   gboolean keep_par;
85   GstVideoInfo info;
86 };
87 
88 struct _GstOSXVideoSinkClass {
89   GstVideoSinkClass parent_class;
90 
91   GstOSXVideoSinkRunLoopState run_loop_state;
92   NSThread *ns_app_thread;
93 };
94 
95 GType gst_osx_video_sink_get_type(void);
96 
97 @interface NSApplication(AppleMenu)
98 - (void)setAppleMenu:(NSMenu *)menu;
99 @end
100 
101 @interface GstBufferObject : NSObject
102 {
103   @public
104   GstBuffer *buf;
105 }
106 
107 -(id) initWithBuffer: (GstBuffer *) buf;
108 @end
109 
110 
111 @interface GstWindowDelegate : NSObject <NSWindowDelegate>
112 {
113   @public
114   GstOSXVideoSink *osxvideosink;
115 }
116 -(id) initWithSink: (GstOSXVideoSink *) sink;
117 @end
118 
119 @interface GstOSXVideoSinkObject : NSObject
120 {
121   @public
122   GstOSXVideoSink *osxvideosink;
123 }
124 
125 -(id) initWithSink: (GstOSXVideoSink *) sink;
126 -(void) createInternalWindow;
127 -(void) resize;
128 -(void) destroy;
129 -(void) showFrame: (GstBufferObject*) buf;
130 -(void) setView: (NSView*) view;
131 + (BOOL) isMainThread;
132 #ifndef GSTREAMER_GLIB_COCOA_NSAPPLICATION
133 -(void) nsAppThread;
134 -(void) checkMainRunLoop;
135 #endif
136 @end
137 
138 G_END_DECLS
139 
140 #endif /* __GST_OSX_VIDEO_SINK_H__ */
141 
142