Smarter handling of video preview start/stop on ipad

This commit is contained in:
Pierre-Eric Pelloux-Prayer 2012-04-25 17:22:53 +02:00
parent 556724a32d
commit c696f7fae1
2 changed files with 24 additions and 11 deletions

View file

@ -106,10 +106,23 @@
[session startRunning];
}
-(void) stopPreview:(id) a {
@synchronized (self) {
if (!session.running)
return;
[self.view removeFromSuperview];
[session stopRunning];
}
}
-(void) startPreview:(id) a {
[window addSubview:self.view];
[window sendSubviewToBack:self.view];
[session startRunning];
@synchronized (self) {
if (session.running)
return;
[window addSubview:self.view];
[window sendSubviewToBack:self.view];
[session startRunning];
}
}
@ -129,13 +142,10 @@
if (show && !session.running) {
[self performSelectorInBackground:@selector(startPreview:) withObject:nil];
} else if (!show && session.running) {
[self.view removeFromSuperview];
[session stopRunning];
[self performSelectorInBackground:@selector(stopPreview:) withObject:nil];
}
} else {
if (session != nil)
[session stopRunning];
[self.view removeFromSuperview];
[self stopPreview:nil];
}
}

View file

@ -135,8 +135,8 @@
[self updateCallAndBackButtons];
}
-(void) viewWillDisappear:(BOOL)animated {
[mMainScreenWithVideoPreview showPreview:NO];
-(void) viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
@ -244,7 +244,7 @@
-(void) displayIncomingCall:(LinphoneCall*) call NotificationFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[mMainScreenWithVideoPreview showPreview:NO];
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
// Create a new notification
@ -304,6 +304,7 @@
}
-(void) displayCall: (LinphoneCall*) call InProgressFromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[mMainScreenWithVideoPreview showPreview:NO];
if (self.presentedViewController != (UIViewController*)mIncallViewController) {
[self presentModalViewController:(UIViewController*)mIncallViewController animated:true];
}
@ -316,6 +317,7 @@
}
-(void) displayInCall: (LinphoneCall*) call FromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[mMainScreenWithVideoPreview showPreview:NO];
if (self.presentedViewController != (UIViewController*)mIncallViewController && (call == 0x0 ||
linphone_call_get_dir(call)==LinphoneCallIncoming)){
[self presentModalViewController:(UIViewController*)mIncallViewController animated:true];
@ -336,6 +338,7 @@
-(void) displayVideoCall:(LinphoneCall*) call FromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName {
[mMainScreenWithVideoPreview showPreview:NO];
[mIncallViewController displayVideoCall:call FromUI:viewCtrl
forUser:username
withDisplayName:displayName];