diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h index 9ac87aaee..398355620 100644 --- a/Classes/LinphoneUI/LinphoneManager.h +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -42,6 +42,8 @@ typedef enum _Connectivity { UIViewController* mCurrentViewController; Connectivity connectivity; FastAddressBook* mFastAddressBook; + const char* frontCamId; + const char* backCamId; } +(LinphoneManager*) instance; @@ -57,9 +59,13 @@ typedef enum _Connectivity { -(void) kickOffNetworkConnection; -(NSString*) getDisplayNameFromAddressBook:(NSString*) number andUpdateCallLog:(LinphoneCallLog*)log; + + @property (nonatomic, retain) id callDelegate; @property (nonatomic, retain) id registrationDelegate; @property Connectivity connectivity; +@property (readonly) const char* frontCamId; +@property (readonly) const char* backCamId; @end diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index d977177d4..c57488173 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -36,11 +36,15 @@ extern void libmsamr_init(); #ifdef HAVE_X264 extern void libmsx264_init(); #endif +#define FRONT_CAM_NAME "AV Capture: Front Camera" +#define BACK_CAM_NAME "AV Capture: Back Camera" @implementation LinphoneManager @synthesize callDelegate; @synthesize registrationDelegate; @synthesize connectivity; +@synthesize frontCamId; +@synthesize backCamId; -(id) init { if ((self= [super init])) { @@ -722,6 +726,21 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach otherButtonTitles:nil ,nil]; [error show]; } + /*DETECT cameras*/ + frontCamId= backCamId=nil; + char** camlist = (char**)linphone_core_get_video_devices(theLinphoneCore); + for (char* cam = *camlist;*camlist!=NULL;cam=*++camlist) { + if (strcmp(FRONT_CAM_NAME, cam)==0) { + frontCamId = cam; + //great set default cam to front + linphone_core_set_video_device(theLinphoneCore, cam); + } + if (strcmp(BACK_CAM_NAME, cam)==0) { + backCamId = cam; + } + + } + if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { //go directly to bg mode @@ -770,4 +789,5 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach mLogView = view; } + @end diff --git a/Classes/LinphoneUI/UICamSwitch.h b/Classes/LinphoneUI/UICamSwitch.h new file mode 100644 index 000000000..beaab07e6 --- /dev/null +++ b/Classes/LinphoneUI/UICamSwitch.h @@ -0,0 +1,31 @@ +/* UICamSwitch.h + * + * Copyright (C) 2011 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import + + +@interface UICamSwitch : UIButton { + +@private + char* currentCamId; + char* nextCamId; + UIView* preview; +} +@property (nonatomic, retain) IBOutlet UIView* preview; +@end diff --git a/Classes/LinphoneUI/UICamSwitch.m b/Classes/LinphoneUI/UICamSwitch.m new file mode 100644 index 000000000..aaa3032e3 --- /dev/null +++ b/Classes/LinphoneUI/UICamSwitch.m @@ -0,0 +1,80 @@ +/* UICamSwitch.m + * + * Copyright (C) 2011 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import "UICamSwitch.h" +#include "LinphoneManager.h" + + +@implementation UICamSwitch +@synthesize preview; +-(void) touchUp:(id) sender { + if (nextCamId!=currentCamId) { + ms_message("Swithcing from [%s] to [%s]",currentCamId,nextCamId); + linphone_core_set_video_device([LinphoneManager getLc], nextCamId); + nextCamId=currentCamId; + currentCamId = linphone_core_get_video_device([LinphoneManager getLc]); + linphone_core_update_call([LinphoneManager getLc] + , linphone_core_get_current_call([LinphoneManager getLc]) + ,NULL); + linphone_core_set_native_preview_window_id([LinphoneManager getLc],preview); + } +} + +- (id) init { + [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; +} +- (id)initWithFrame:(CGRect)frame { + + self = [super initWithFrame:frame]; + if (self) { + [self init]; + } + return self; +} +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (self) { + [self init]; + } + return self; +} + + +- (void)dealloc { + [super dealloc]; + [preview release]; +} + + + + + +@end diff --git a/Classes/LinphoneUI/UILinphone.h b/Classes/LinphoneUI/UILinphone.h index 6c9ed3840..9820da892 100644 --- a/Classes/LinphoneUI/UILinphone.h +++ b/Classes/LinphoneUI/UILinphone.h @@ -1,4 +1,4 @@ -/* UIHangUpButton.h +/* UILinphone.h * * Copyright (C) 2011 Belledonne Comunications, Grenoble, France * @@ -26,3 +26,4 @@ #import "UIDuration.h" #import "UIEraseButton.h" #import "LinphoneUIDelegates.h" +#import "UICamSwitch.h" diff --git a/Classes/VideoViewController.h b/Classes/VideoViewController.h index 4ab762d2c..569d45b44 100644 --- a/Classes/VideoViewController.h +++ b/Classes/VideoViewController.h @@ -24,6 +24,7 @@ UIView* mPreview; UIMuteButton* mMute; UIHangUpButton* mHangUp; + UICamSwitch* mCamSwitch; } @@ -31,4 +32,5 @@ @property (nonatomic, retain) IBOutlet UIView* mPreview; @property (nonatomic, retain) IBOutlet UIMuteButton* mMute; @property (nonatomic, retain) IBOutlet UIHangUpButton* mHangUp; +@property (nonatomic, retain) IBOutlet UICamSwitch* mCamSwitch; @end \ No newline at end of file diff --git a/Classes/VideoViewController.m b/Classes/VideoViewController.m index d84e9b731..2e4df1863 100644 --- a/Classes/VideoViewController.m +++ b/Classes/VideoViewController.m @@ -25,6 +25,7 @@ @synthesize mPreview; @synthesize mMute; @synthesize mHangUp; +@synthesize mCamSwitch; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { @@ -53,12 +54,14 @@ - (void)viewDidLoad { [super viewDidLoad]; - + [mMute initWithOnImage:[UIImage imageNamed:@"mic_muted.png"] offImage:[UIImage imageNamed:@"mic_active.png"] ]; + [mCamSwitch setPreview:mPreview]; } - (void)viewDidUnload { [super viewDidUnload]; + // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } diff --git a/Classes/VideoViewController.xib b/Classes/VideoViewController.xib index 759671486..b2a7f9f62 100644 --- a/Classes/VideoViewController.xib +++ b/Classes/VideoViewController.xib @@ -70,7 +70,6 @@ 15 16 - mute 3 MQA @@ -96,13 +95,16 @@ 0 0 - hangup 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + NSImage + stopcall-red.png + @@ -181,6 +183,22 @@ 11 + + + mCamSwitch + + + + 12 + + + + mMute + + + + 13 + @@ -257,6 +275,7 @@ 6.IBPluginDependency 7.CustomClassName 7.IBPluginDependency + 8.CustomClassName 8.IBPluginDependency 9.IBPluginDependency @@ -271,6 +290,7 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIHangUpButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UICamSwitch com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -287,11 +307,30 @@ - 11 + 13 YES + + UICamSwitch + UIButton + + preview + UIView + + + preview + + preview + UIView + + + + IBProjectSource + ./Classes/UICamSwitch.h + + UIHangUpButton UIButton @@ -323,6 +362,7 @@ YES YES + mCamSwitch mDisplay mHangUp mMute @@ -330,6 +370,7 @@ YES + UICamSwitch UIImageView UIHangUpButton UIMuteButton @@ -340,6 +381,7 @@ YES YES + mCamSwitch mDisplay mHangUp mMute @@ -347,6 +389,10 @@ YES + + mCamSwitch + UICamSwitch + mDisplay UIImageView @@ -380,6 +426,10 @@ YES 3 + + stopcall-red.png + {62, 54} + 300 diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index b88f1b2c5..05cd5250c 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -73,6 +73,7 @@ 22A10F3B11F8960300373793 /* libortp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 220FAD2C10765B400068D98F /* libortp.a */; }; 22AA8AFD13D7125600B30535 /* libx264.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22AA8AFB13D7125500B30535 /* libx264.a */; }; 22AA8AFE13D7125600B30535 /* libmsx264.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22AA8AFC13D7125500B30535 /* libmsx264.a */; }; + 22AA8B0113D83F6300B30535 /* UICamSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 22AA8B0013D83F6300B30535 /* UICamSwitch.m */; }; 22B5EFA310CE50BD00777D97 /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */; }; 22B5EFE510CE5E5800777D97 /* ContactPickerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B5EFE410CE5E5800777D97 /* ContactPickerDelegate.m */; }; 22B5F03510CE6B2F00777D97 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B5F03410CE6B2F00777D97 /* AddressBook.framework */; }; @@ -329,6 +330,8 @@ 22A10D9E11F88C1F00373793 /* liblinphone.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = liblinphone.xcodeproj; path = submodules/liblinphone.xcodeproj; sourceTree = ""; }; 22AA8AFB13D7125500B30535 /* libx264.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libx264.a; path = "liblinphone-sdk/apple-darwin/lib/libx264.a"; sourceTree = ""; }; 22AA8AFC13D7125500B30535 /* libmsx264.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmsx264.a; path = "liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins/libmsx264.a"; sourceTree = ""; }; + 22AA8AFF13D83F6300B30535 /* UICamSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICamSwitch.h; sourceTree = ""; }; + 22AA8B0013D83F6300B30535 /* UICamSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICamSwitch.m; sourceTree = ""; }; 22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; }; 22B5EFE310CE5E5800777D97 /* ContactPickerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactPickerDelegate.h; sourceTree = ""; }; 22B5EFE410CE5E5800777D97 /* ContactPickerDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactPickerDelegate.m; sourceTree = ""; }; @@ -739,6 +742,8 @@ 22BB1A68132FF16A005CD7AA /* UIEraseButton.m */, 223963151393CFAE001DE689 /* FastAddressBook.h */, 223963161393CFAF001DE689 /* FastAddressBook.m */, + 22AA8AFF13D83F6300B30535 /* UICamSwitch.h */, + 22AA8B0013D83F6300B30535 /* UICamSwitch.m */, ); path = LinphoneUI; sourceTree = ""; @@ -1073,6 +1078,7 @@ 22BB1A69132FF16A005CD7AA /* UIEraseButton.m in Sources */, 223963171393CFAF001DE689 /* FastAddressBook.m in Sources */, 22E028B713B4CCBD0068A713 /* VideoViewController.m in Sources */, + 22AA8B0113D83F6300B30535 /* UICamSwitch.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/submodules/linphone b/submodules/linphone index 714c9a529..b57946b55 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 714c9a52908ae8829f559775fccbbc407574c9ab +Subproject commit b57946b5518da0a50d62b24b6a06606b6006237c