video: various iOS fix

parent 4004034d
......@@ -214,7 +214,7 @@ didOutputSampleBuffer:(CMSampleBufferRef) sampleBuffer
dispatch_release(queue);
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
captureVideoPreviewLayer.orientation = AVCaptureVideoOrientationPortrait; //AVCaptureVideoOrientationLandscapeRight;
captureVideoPreviewLayer.orientation = AVCaptureVideoOrientationPortrait;
start_time=0;
frame_count=-1;
fps=0;
......@@ -449,8 +449,6 @@ static int v4ios_set_device_orientation (MSFilter *f, void *arg) {
if ( webcam->mDeviceOrientation != *(int*)(arg)) {
webcam->mDeviceOrientation = *(int*)(arg);
[webcam setSize:webcam->mOutputVideoSize]; //to update size from orientation
//if ([webcam->captureVideoPreviewLayer isOrientationSupported])
// webcam->captureVideoPreviewLayer.orientation = devideOrientation2AVCaptureVideoOrientation(webcam->mDeviceOrientation);
ms_mutex_lock(&webcam->mutex);
if (webcam->msframe) {
// delete frame if any
......@@ -462,6 +460,16 @@ static int v4ios_set_device_orientation (MSFilter *f, void *arg) {
return 0;
}
/* this method is used to display the preview with correct orientation */
static int v4ios_set_device_orientation_display (MSFilter *f, void *arg) {
IOSMsWebCam *webcam=(IOSMsWebCam*)f->data;
if ([webcam->captureVideoPreviewLayer isOrientationSupported])
webcam->captureVideoPreviewLayer.orientation = devideOrientation2AVCaptureVideoOrientation(webcam->mDeviceOrientation);
return 0;
}
static MSFilterMethod methods[]={
{ MS_FILTER_SET_FPS , v4ios_set_fps },
{ MS_FILTER_GET_FPS , v4ios_get_fps },
......@@ -471,6 +479,7 @@ static MSFilterMethod methods[]={
{ MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID , v4ios_set_native_window },//preview is managed by capture filter
{ MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID , v4ios_get_native_window },
{ MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION, v4ios_set_device_orientation },
{ MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION, v4ios_set_device_orientation_display },
{ 0 , NULL }
};
......
......@@ -101,26 +101,28 @@
return;
@synchronized(self) {
if (![EAGLContext setCurrentContext:context])
{
ms_error("Failed to bind GL context");
return;
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultFrameBuffer);
if (![EAGLContext setCurrentContext:context]) {
ms_error("Failed to bind GL context");
return;
}
[self updateRenderStorageIfNeeded];
glBindFramebuffer(GL_FRAMEBUFFER, defaultFrameBuffer);
if (!glInitDone) {
glClear(GL_COLOR_BUFFER_BIT);
} else {
ogl_display_render(helper, deviceRotation);
}
if (!glInitDone) {
glClear(GL_COLOR_BUFFER_BIT);
} else {
ogl_display_render(helper, deviceRotation);
}
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
[context presentRenderbuffer:GL_RENDERBUFFER];
[context presentRenderbuffer:GL_RENDERBUFFER];
}
}
- (void) layoutSubviews
- (void) updateRenderStorageIfNeeded
{
@synchronized(self) {
if (!(allocatedW == self.superview.frame.size.width && allocatedH == self.superview.frame.size.height)) {
......@@ -147,8 +149,6 @@
glClear(GL_COLOR_BUFFER_BIT);
}
} else {
ogl_display_init(helper, self.superview.frame.size.width, self.superview.frame.size.height);
}
}
glInitDone = TRUE;
......@@ -164,8 +164,7 @@
// add to new parent
[self.imageView addSubview:self];
}
// handle GL/view interaction
[self layoutSubviews];
// schedule rendering
displayLink = [self.window.screen displayLinkWithTarget:self selector:@selector(drawView:)];
[displayLink setFrameInterval:4];
......@@ -181,8 +180,6 @@
[displayLink release];
displayLink = nil;
animating = FALSE;
[self removeFromSuperview];
}
}
......@@ -192,10 +189,7 @@
}
static void iosdisplay_init(MSFilter *f){
//IOSDisplay* thiz = [[IOSDisplay alloc] init];
//[thiz initGlRendering];
//f->data = thiz;
//f->data = nil;
}
-(void) dealloc {
[EAGLContext setCurrentContext:context];
......
......@@ -641,14 +641,15 @@ void video_stream_use_preview_video_window(VideoStream *stream, bool_t yesno){
void video_stream_set_device_rotation(VideoStream *stream, int orientation){
MSFilter* target_filter;
if (stream == 0)
return;
stream->device_orientation = orientation;
target_filter=stream->source;
if (target_filter){
ms_filter_call_method(target_filter,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&orientation);
// The below code may look weird so I'll add a bit of documentation
if (!stream->display_filter_auto_rotate_enabled)
ms_filter_call_method(target_filter,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&orientation);
}
if (stream->output && stream->display_filter_auto_rotate_enabled) {
ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&orientation);
......
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