Commit 21e7c96f authored by Yann Diorcet's avatar Yann Diorcet
Browse files

Normalize ioscapture/iosdisplay/macosxdisplay

parent b184aec8
......@@ -448,11 +448,12 @@ static void ioscapture_uninit(MSFilter *f) {
IOSCapture *thiz = (IOSCapture*)f->data;
if(thiz != nil) {
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
[thiz performSelectorInBackground:@selector(stop) withObject:nil];
[thiz performSelectorOnMainThread:@selector(setParentView:) withObject:nil waitUntilDone:NO];
[thiz release];
f->data = NULL;
[myPool drain];
}
}
......@@ -475,7 +476,9 @@ static void ioscapture_process(MSFilter * obj) {
static void ioscapture_preprocess(MSFilter *f) {
IOSCapture *thiz = (IOSCapture*)f->data;
if (thiz != NULL) {
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
[thiz performSelectorInBackground:@selector(start) withObject:nil];
[myPool drain];
}
}
......@@ -522,21 +525,22 @@ static int ioscapture_get_vsize(MSFilter *f, void *arg) {
/*filter specific method*/
static int ioscapture_set_native_window(MSFilter *f, void *arg) {
UIView* parentView = *(UIView**)arg;
IOSCapture *thiz = (IOSCapture*)f->data;
if (thiz != nil) {
UIView* parentView = *(UIView**)arg;
// set curent parent view
if (parentView) {
[thiz performSelectorOnMainThread:@selector(setParentView:) withObject:parentView waitUntilDone:NO];
}
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
[thiz performSelectorOnMainThread:@selector(setParentView:) withObject:parentView waitUntilDone:NO];
[myPool drain];
}
return 0;
return 0;
}
static int ioscapture_get_native_window(MSFilter *f, void *arg) {
IOSCapture *thiz = (IOSCapture*)f->data;
if (thiz != NULL) {
arg = &thiz->parentView;
unsigned long *winId = (unsigned long*)arg;
*winId = (unsigned long)thiz->parentView;
}
return 0;
}
......
......@@ -255,9 +255,13 @@ static void iosdisplay_process(MSFilter *f) {
static void iosdisplay_uninit(MSFilter *f) {
IOSDisplay* thiz = (IOSDisplay*)f->data;
// Remove from parent view in order to release all reference to IOSDisplay
[thiz performSelectorOnMainThread:@selector(setParentView:) withObject:nil waitUntilDone:NO];
[thiz release];
if (thiz != nil) {
NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
// Remove from parent view in order to release all reference to IOSDisplay
[thiz performSelectorOnMainThread:@selector(setParentView:) withObject:nil waitUntilDone:NO];
[thiz release];
[loopPool drain];
}
}
static int iosdisplay_set_native_window(MSFilter *f, void *arg) {
......@@ -273,13 +277,16 @@ static int iosdisplay_set_native_window(MSFilter *f, void *arg) {
}
static int iosdisplay_get_native_window(MSFilter *f, void *arg) {
IOSDisplay* thiz=(IOSDisplay*)f->data;
*(UIView**)arg = thiz.parentView;
IOSDisplay* thiz = (IOSDisplay*)f->data;
if (!thiz)
return 0;
unsigned long *winId = (unsigned long*)arg;
*winId = (unsigned long)thiz->parentView;
return 0;
}
static int iosdisplay_set_device_orientation(MSFilter* f, void* arg) {
IOSDisplay* thiz=(IOSDisplay*)f->data;
IOSDisplay* thiz = (IOSDisplay*)f->data;
if (!thiz)
return 0;
thiz.deviceRotation = *((int*)arg);
......@@ -287,7 +294,7 @@ static int iosdisplay_set_device_orientation(MSFilter* f, void* arg) {
}
static int iosdisplay_set_device_orientation_display(MSFilter* f, void* arg) {
IOSDisplay* thiz=(IOSDisplay*)f->data;
IOSDisplay* thiz = (IOSDisplay*)f->data;
if (!thiz)
return 0;
thiz.displayRotation = *((int*)arg);
......@@ -295,8 +302,11 @@ static int iosdisplay_set_device_orientation_display(MSFilter* f, void* arg) {
}
static int iosdisplay_set_zoom(MSFilter* f, void* arg) {
IOSDisplay* thiz=(IOSDisplay*)f->data;
IOSDisplay* thiz = (IOSDisplay*)f->data;
if (!thiz)
return 0;
ogl_display_zoom(thiz->display_helper, arg);
return 0;
}
static MSFilterMethod iosdisplay_methods[] = {
......
......@@ -290,11 +290,12 @@ static void osx_gl_init(MSFilter* f) {
}
static void osx_gl_preprocess(MSFilter* f) {
OSXDisplay* thiz = (OSXDisplay*) f->data;
NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
[thiz performSelectorOnMainThread:@selector(createWindowIfNeeded) withObject:nil waitUntilDone:FALSE];
[loopPool drain];
OSXDisplay* thiz = (OSXDisplay*) f->data;
if (thiz != nil) {
NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
[thiz performSelectorOnMainThread:@selector(createWindowIfNeeded) withObject:nil waitUntilDone:FALSE];
[loopPool drain];
}
}
static void osx_gl_process(MSFilter* f) {
......@@ -306,19 +307,21 @@ static void osx_gl_process(MSFilter* f) {
if ((m=ms_queue_peek_last(f->inputs[0])) != NULL) {
if (ms_yuv_buf_init_from_mblk (&pic,m) == 0) {
// Source size change?
if (pic.w != thiz.glLayer.sourceSize.width || pic.h != thiz.glLayer.sourceSize.height) {
thiz.glLayer.sourceSize = CGSizeMake(pic.w, pic.h);
if (thiz != nil) {
// Source size change?
if (pic.w != thiz.glLayer.sourceSize.width || pic.h != thiz.glLayer.sourceSize.height) {
thiz.glLayer.sourceSize = CGSizeMake(pic.w, pic.h);
// Force window resize
if(thiz.window != nil) {
[thiz.glLayer performSelectorOnMainThread:@selector(resizeToWindow:) withObject:thiz.window waitUntilDone:FALSE];
// Force window resize
if(thiz.window != nil) {
[thiz.glLayer performSelectorOnMainThread:@selector(resizeToWindow:) withObject:thiz.window waitUntilDone:FALSE];
}
}
}
ogl_display_set_yuv_to_display(thiz.glLayer->display_helper, m);
ogl_display_set_yuv_to_display(thiz.glLayer->display_helper, m);
// Force redraw
[thiz.glLayer performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:FALSE];
// Force redraw
[thiz.glLayer performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:FALSE];
}
}
}
ms_queue_flush(f->inputs[0]);
......@@ -326,10 +329,12 @@ static void osx_gl_process(MSFilter* f) {
if (f->inputs[1] != NULL) {
if ((m=ms_queue_peek_last(f->inputs[1])) != NULL) {
if (ms_yuv_buf_init_from_mblk (&pic,m) == 0) {
ogl_display_set_preview_yuv_to_display(thiz.glLayer->display_helper, m);
if (thiz != nil) {
ogl_display_set_preview_yuv_to_display(thiz.glLayer->display_helper, m);
// Force redraw
[thiz.glLayer performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:FALSE];
// Force redraw
[thiz.glLayer performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:FALSE];
}
}
}
ms_queue_flush(f->inputs[1]);
......@@ -340,8 +345,11 @@ static void osx_gl_process(MSFilter* f) {
static void osx_gl_uninit(MSFilter* f) {
OSXDisplay* thiz = (OSXDisplay*) f->data;
[thiz release];
if (thiz != nil) {
NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
[thiz release];
[loopPool drain];
}
}
static int osx_gl_set_vsize(MSFilter* f, void* arg) {
......@@ -351,14 +359,16 @@ static int osx_gl_set_vsize(MSFilter* f, void* arg) {
static int osx_gl_get_native_window_id(MSFilter* f, void* arg) {
OSXDisplay* thiz = (OSXDisplay*) f->data;
unsigned long *winId=(unsigned long*)arg;
if(thiz.window != nil) {
return *winId = (unsigned long)thiz.window;
}
if(thiz.view != nil) {
return *winId = (unsigned long)thiz.view;
}
if(thiz.layer != nil) {
return *winId = (unsigned long)thiz.layer;
if(thiz != nil) {
if(thiz->window != nil) {
*winId = (unsigned long)thiz->window;
}
if(thiz->view != nil) {
*winId = (unsigned long)thiz->view;
}
if(thiz->layer != nil) {
*winId = (unsigned long)thiz->layer;
}
}
return 0;
}
......@@ -367,22 +377,25 @@ static int osx_gl_set_native_window_id(MSFilter* f, void* arg) {
OSXDisplay* thiz = (OSXDisplay*) f->data;
NSObject *obj = *((NSObject **)arg);
NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
if(obj != nil) {
if([obj isKindOfClass:[NSWindow class]]) {
[thiz performSelectorOnMainThread:@selector(setWindow:) withObject:(NSWindow*)obj waitUntilDone:NO];
return 0;
} else if([obj isKindOfClass:[NSView class]]) {
[thiz performSelectorOnMainThread:@selector(setView:) withObject:(NSView*)obj waitUntilDone:NO];
return 0;
} else if([obj isKindOfClass:[CALayer class]]) {
[thiz performSelectorOnMainThread:@selector(setLayer:) withObject:(CALayer*)obj waitUntilDone:NO];
return 0;
if(thiz != nil) {
NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init];
if(obj != nil) {
if([obj isKindOfClass:[NSWindow class]]) {
[thiz performSelectorOnMainThread:@selector(setWindow:) withObject:(NSWindow*)obj waitUntilDone:NO];
return 0;
} else if([obj isKindOfClass:[NSView class]]) {
[thiz performSelectorOnMainThread:@selector(setView:) withObject:(NSView*)obj waitUntilDone:NO];
return 0;
} else if([obj isKindOfClass:[CALayer class]]) {
[thiz performSelectorOnMainThread:@selector(setLayer:) withObject:(CALayer*)obj waitUntilDone:NO];
return 0;
}
} else {
[thiz performSelectorOnMainThread:@selector(resetContainers) withObject:nil waitUntilDone:NO];
}
} else {
[thiz performSelectorOnMainThread:@selector(resetContainers) withObject:nil waitUntilDone:NO];
[loopPool drain];
}
[loopPool drain];
return -1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment