2007-01-30 17:19:33 +00:00
|
|
|
/* GStreamer
|
2008-01-15 16:04:44 +00:00
|
|
|
* Copyright (C) 2004-6 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
|
|
|
* Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
|
|
|
|
*
|
2007-01-30 17:19:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2008-01-15 16:04:44 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* The development of this code was made possible due to the involvement of Pioneers
|
|
|
|
* of the Inevitable, the creators of the Songbird Music player
|
|
|
|
*
|
2007-01-30 17:19:33 +00:00
|
|
|
*/
|
|
|
|
|
2008-01-15 16:04:44 +00:00
|
|
|
#ifndef __GST_OSX_VIDEO_SINK_H__
|
|
|
|
#define __GST_OSX_VIDEO_SINK_H__
|
2007-01-30 17:19:33 +00:00
|
|
|
|
|
|
|
#include <gst/video/gstvideosink.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2012-05-22 14:45:28 +00:00
|
|
|
#include <objc/runtime.h>
|
2008-01-15 16:04:44 +00:00
|
|
|
#include <Cocoa/Cocoa.h>
|
2007-01-30 17:19:33 +00:00
|
|
|
|
|
|
|
#include <QuickTime/QuickTime.h>
|
|
|
|
#import "cocoawindow.h"
|
2008-01-15 16:04:44 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN (gst_debug_osx_video_sink);
|
|
|
|
#define GST_CAT_DEFAULT gst_debug_osx_video_sink
|
2007-01-30 17:19:33 +00:00
|
|
|
|
2012-05-31 08:26:27 +00:00
|
|
|
/* The hack doesn't work on leopard, the _CFMainPThread symbol
|
|
|
|
* is doesn't exist in the CoreFoundation library */
|
|
|
|
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
|
|
|
|
#ifdef RUN_NS_APP_THREAD
|
|
|
|
#undef RUN_NS_APP_THREAD
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2007-01-30 17:19:33 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2008-01-15 16:04:44 +00:00
|
|
|
#define GST_TYPE_OSX_VIDEO_SINK \
|
|
|
|
(gst_osx_video_sink_get_type())
|
|
|
|
#define GST_OSX_VIDEO_SINK(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_OSX_VIDEO_SINK, GstOSXVideoSink))
|
|
|
|
#define GST_OSX_VIDEO_SINK_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_OSX_VIDEO_SINK, GstOSXVideoSinkClass))
|
|
|
|
#define GST_IS_OSX_VIDEO_SINK(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_OSX_VIDEO_SINK))
|
|
|
|
#define GST_IS_OSX_VIDEO_SINK_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_OSX_VIDEO_SINK))
|
2007-01-30 17:19:33 +00:00
|
|
|
|
|
|
|
typedef struct _GstOSXWindow GstOSXWindow;
|
|
|
|
|
|
|
|
typedef struct _GstOSXVideoSink GstOSXVideoSink;
|
|
|
|
typedef struct _GstOSXVideoSinkClass GstOSXVideoSinkClass;
|
|
|
|
|
2008-01-15 16:04:44 +00:00
|
|
|
#define GST_TYPE_OSXVIDEOBUFFER (gst_osxvideobuffer_get_type())
|
|
|
|
|
2007-01-30 17:19:33 +00:00
|
|
|
/* OSXWindow stuff */
|
|
|
|
struct _GstOSXWindow {
|
|
|
|
gint width, height;
|
2012-05-14 16:01:02 +00:00
|
|
|
gboolean closed;
|
2007-01-30 17:19:33 +00:00
|
|
|
gboolean internal;
|
|
|
|
GstGLView* gstview;
|
2012-05-14 16:01:02 +00:00
|
|
|
GstOSXVideoSinkWindow* win;
|
2007-01-30 17:19:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstOSXVideoSink {
|
|
|
|
/* Our element stuff */
|
|
|
|
GstVideoSink videosink;
|
|
|
|
GstOSXWindow *osxwindow;
|
2012-05-11 16:24:08 +00:00
|
|
|
void *osxvideosinkobject;
|
2010-05-11 08:52:58 +00:00
|
|
|
NSView *superview;
|
2012-05-24 18:43:16 +00:00
|
|
|
NSThread *ns_app_thread;
|
2012-05-31 08:26:27 +00:00
|
|
|
#ifdef RUN_NS_APP_THREAD
|
2012-05-26 10:21:18 +00:00
|
|
|
GMutex *loop_thread_lock;
|
|
|
|
GCond *loop_thread_cond;
|
2012-05-22 14:45:28 +00:00
|
|
|
#else
|
2012-05-14 16:01:02 +00:00
|
|
|
guint cocoa_timeout;
|
2012-05-22 14:45:28 +00:00
|
|
|
#endif
|
2012-05-26 10:21:18 +00:00
|
|
|
gboolean app_started;
|
2012-05-16 16:52:45 +00:00
|
|
|
gboolean keep_par;
|
2012-05-16 19:52:45 +00:00
|
|
|
gboolean embed;
|
2007-01-30 17:19:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstOSXVideoSinkClass {
|
|
|
|
GstVideoSinkClass parent_class;
|
2008-01-15 15:22:41 +00:00
|
|
|
};
|
2007-03-14 16:30:19 +00:00
|
|
|
|
2008-01-15 16:04:44 +00:00
|
|
|
GType gst_osx_video_sink_get_type(void);
|
|
|
|
|
2012-05-14 16:01:02 +00:00
|
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
|
|
|
@interface NSApplication(AppleMenu)
|
|
|
|
- (void)setAppleMenu:(NSMenu *)menu;
|
|
|
|
@end
|
|
|
|
#endif
|
|
|
|
|
2012-05-11 16:24:08 +00:00
|
|
|
@interface GstBufferObject : NSObject
|
|
|
|
{
|
|
|
|
@public
|
|
|
|
GstBuffer *buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(id) initWithBuffer: (GstBuffer *) buf;
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
2012-05-30 14:03:55 +00:00
|
|
|
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
|
2012-05-30 10:40:57 +00:00
|
|
|
@interface GstWindowDelegate : NSObject
|
2012-05-30 14:03:55 +00:00
|
|
|
#else
|
|
|
|
@interface GstWindowDelegate : NSObject <NSWindowDelegate>
|
2012-05-30 10:40:57 +00:00
|
|
|
#endif
|
2012-05-14 16:01:02 +00:00
|
|
|
{
|
|
|
|
@public
|
|
|
|
GstOSXVideoSink *osxvideosink;
|
|
|
|
}
|
|
|
|
-(id) initWithSink: (GstOSXVideoSink *) sink;
|
|
|
|
@end
|
|
|
|
|
2012-05-11 16:24:08 +00:00
|
|
|
@interface GstOSXVideoSinkObject : NSObject
|
|
|
|
{
|
2012-05-14 16:01:02 +00:00
|
|
|
BOOL destroyed;
|
|
|
|
|
2012-05-11 16:24:08 +00:00
|
|
|
@public
|
|
|
|
GstOSXVideoSink *osxvideosink;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(id) initWithSink: (GstOSXVideoSink *) sink;
|
2012-05-14 16:01:02 +00:00
|
|
|
-(void) createInternalWindow;
|
2012-05-11 16:24:08 +00:00
|
|
|
-(void) resize;
|
|
|
|
-(void) destroy;
|
|
|
|
-(void) showFrame: (GstBufferObject*) buf;
|
2012-05-24 18:43:16 +00:00
|
|
|
#ifdef RUN_NS_APP_THREAD
|
2012-05-31 08:26:27 +00:00
|
|
|
+ (BOOL) isMainThread;
|
2012-05-24 18:43:16 +00:00
|
|
|
-(void) nsAppThread;
|
|
|
|
#endif
|
2012-05-11 16:24:08 +00:00
|
|
|
@end
|
|
|
|
|
2007-01-30 17:19:33 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
2008-01-15 16:04:44 +00:00
|
|
|
#endif /* __GST_OSX_VIDEO_SINK_H__ */
|
|
|
|
|