34 #include <nsIRunnable.h>
35 #include <nsThreadUtils.h>
37 #import <AppKit/AppKit.h>
47 static PRLogModuleInfo* gGStreamerPlatformOSX =
48 PR_NewLogModule(
"sbGStreamerPlatformOSX");
51 if (gGStreamerPlatformOSX) \
52 PR_LOG(gGStreamerPlatformOSX, PR_LOG_WARNING, args)
55 if (gGStreamerPlatformOSX) \
56 PR_LOG(gGStreamerPlatformOSX, PR_LOG_DEBUG, args)
71 - (void)setFrameAsString:(NSString *)aString;
77 - (void)setFrameAsString:(NSString *)aString
79 NSRect newFrame = NSRectFromString(aString);
80 [
self setFrame:newFrame];
88 - (void)setDelegate:(
id)aDelegate;
102 - (void)startListeningToResizeEvents;
103 - (void)stopListeningToResizeEvents;
104 - (void)mouseMoved:(NSEvent *)theEvent;
105 - (void)windowResized:(NSNotification *)aNotice;
113 if ((
self = [super
init])) {
126 [[NSNotificationCenter defaultCenter] removeObserver:self];
137 [[NSNotificationCenter defaultCenter] addObserver:self
138 selector:@selector(windowResized:)
139 name:NSWindowDidResizeNotification
149 [[NSNotificationCenter defaultCenter] removeObserver:self];
152 - (void)mouseMoved:(NSEvent *)theEvent
161 - (void)windowResized:(NSNotification *)aNotice
179 mGstGLViewDelegate(NULL)
206 mVideoSink = gst_element_factory_make(
"osxvideosink",
"video-sink");
208 g_object_set (
mVideoSink,
"embed", TRUE, NULL);
214 mVideoSink = gst_element_factory_make(
"autovideosink",
"video-sink");
235 mAudioSink = gst_element_factory_make(
"osxaudiosink",
"audio-sink");
238 mAudioSink = gst_element_factory_make(
"autoaudiosink",
"audio-sink");
253 NS_ENSURE_SUCCESS(rv, rv);
256 mParentView = (
void *)(aWidget->GetNativeData(NS_NATIVE_WIDGET));
257 NS_ENSURE_TRUE(
mParentView != NULL, NS_ERROR_FAILURE);
275 nsCOMPtr<nsIThread> mainThread;
276 nsresult rv = NS_GetMainThread(getter_AddRefs(mainThread));
277 NS_ENSURE_SUCCESS(rv, );
279 nsCOMPtr<nsIRunnable> runnable =
284 rv = mainThread->Dispatch(runnable, NS_DISPATCH_SYNC);
285 NS_ENSURE_SUCCESS(rv, );
293 const GValue *
value = gst_structure_get_value (
294 aMessage->structure,
"nsview");
296 if (!value || !G_VALUE_HOLDS_POINTER(value))
299 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
315 [parentView performSelectorOnMainThread:@selector(addSubview:)
321 if ([view respondsToSelector:
@selector(setDelegate:)]) {
322 [view setDelegate:(id)mGstGLViewDelegate];
340 NS_ENSURE_TRUE(aCocoaEvent, );
345 nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
347 NS_ENSURE_SUCCESS(rv, );
349 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
353 NSEvent *
event = (NSEvent *)aCocoaEvent;
356 float menuBarHeight = 0.0;
357 NSArray *allScreens = [NSScreen screens];
358 if ([allScreens
count]) {
359 menuBarHeight = [[allScreens objectAtIndex:0] frame].size.height;
361 float windowHeight = [[[eventView window] contentView] frame].size.height;
364 NSPoint viewPoint = [event locationInWindow];
365 NSPoint screenPoint = [[eventView window] convertBaseToScreen:viewPoint];
367 viewPoint.y = windowHeight - viewPoint.y;
368 screenPoint.y = menuBarHeight - screenPoint.y;
370 rv = mouseEvent->InitMouseEvent(
371 NS_LITERAL_STRING(
"mousemove"),
376 (PRInt32)screenPoint.x,
377 (PRInt32)screenPoint.y,
378 (PRInt32)viewPoint.x,
379 (PRInt32)viewPoint.y,
380 (([
event modifierFlags] & NSControlKeyMask) != 0),
381 (([
event modifierFlags] & NSAlternateKeyMask) != 0),
382 (([
event modifierFlags] & NSShiftKeyMask) != 0),
383 (([
event modifierFlags] & NSCommandKeyMask) != 0),
387 NS_ENSURE_SUCCESS(rv, );
389 nsCOMPtr<nsIDOMEvent> domEvent(do_QueryInterface(mouseEvent));
391 NS_ENSURE_SUCCESS(rv, );
403 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
409 rect.origin.y = [[view superview] frame].size.height - y -
height;
412 rect.size.width =
width;
413 rect.size.height =
height;
417 NSString *frameStr = NSStringFromRect(rect);
418 [view performSelectorOnMainThread:@selector(setFrameAsString:)
429 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
433 [view performSelectorOnMainThread:@selector(removeFromSuperviewWithoutNeedingDisplay)
void stopListeningToResizeEvents()
OSXPlatformInterface * mOwner
void startListeningToResizeEvents()