From 874eb9e62a4a597a1bdbbcac5b15a6ac052cd691 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 24 Jun 2014 17:54:36 +0200 Subject: [PATCH] fix UICamSwitch button broken --- Classes/LinphoneManager.m | 1 + Classes/LinphoneUI/UICamSwitch.h | 3 +-- Classes/LinphoneUI/UICamSwitch.m | 34 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index e114f2615..f1b9a54a8 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1,3 +1,4 @@ + /* LinphoneManager.h * * Copyright (C) 2011 Belledonne Comunications, Grenoble, France diff --git a/Classes/LinphoneUI/UICamSwitch.h b/Classes/LinphoneUI/UICamSwitch.h index 3110b0e71..bcde2513c 100644 --- a/Classes/LinphoneUI/UICamSwitch.h +++ b/Classes/LinphoneUI/UICamSwitch.h @@ -22,8 +22,7 @@ @interface UICamSwitch : UIButton { @private - const char* currentCamId; - const char* nextCamId; + } @property (nonatomic, retain) IBOutlet UIView* preview; @end diff --git a/Classes/LinphoneUI/UICamSwitch.m b/Classes/LinphoneUI/UICamSwitch.m index 8dba965ed..371cac44e 100644 --- a/Classes/LinphoneUI/UICamSwitch.m +++ b/Classes/LinphoneUI/UICamSwitch.m @@ -28,17 +28,6 @@ - (id)initUICamSwitch { [self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside]; - currentCamId = (char*)linphone_core_get_video_device([LinphoneManager getLc]); - if ([LinphoneManager instance].frontCamId !=nil ) { - //ok, we have 2 cameras - if (strcmp(currentCamId,[LinphoneManager instance].frontCamId)==0) { - nextCamId = [LinphoneManager instance].backCamId; - } else { - nextCamId = [LinphoneManager instance].frontCamId; - } - } else { - nextCamId=currentCamId; - } return self; } @@ -81,15 +70,26 @@ [LinphoneLogger logc:LinphoneLoggerWarning format:"Cannot tigger camswitch button: Linphone core not ready"]; return; } - if (nextCamId != currentCamId) { - [LinphoneLogger logc:LinphoneLoggerLog format:"Switching from [%s] to [%s]", currentCamId, nextCamId]; - linphone_core_set_video_device([LinphoneManager getLc], nextCamId); - nextCamId = currentCamId; - currentCamId = linphone_core_get_video_device([LinphoneManager getLc]); - LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]); + const char *currentCamId = (char*)linphone_core_get_video_device([LinphoneManager getLc]); + const char **cameras=linphone_core_get_video_devices([LinphoneManager getLc]); + const char *newCamId=NULL; + int i; + + for (i=0;cameras[i]!=NULL;++i){ + if (strcmp(cameras[i],"StaticImage: Static picture")==0) continue; + if (strcmp(cameras[i],currentCamId)!=0){ + newCamId=cameras[i]; + break; + } + } + if (newCamId){ + [LinphoneLogger logc:LinphoneLoggerLog format:"Switching from [%s] to [%s]", currentCamId, newCamId]; + linphone_core_set_video_device([LinphoneManager getLc], newCamId); + LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]); if(call != NULL) { linphone_core_update_call([LinphoneManager getLc], call, NULL); } + } }