enable front cam

This commit is contained in:
Jehan Monnier 2011-07-21 16:40:54 +02:00
parent 9fd2ca3c75
commit d73efa6d9c
10 changed files with 205 additions and 6 deletions

View file

@ -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<LinphoneUICallDelegate> callDelegate;
@property (nonatomic, retain) id<LinphoneUIRegistrationDelegate> registrationDelegate;
@property Connectivity connectivity;
@property (readonly) const char* frontCamId;
@property (readonly) const char* backCamId;
@end

View file

@ -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

View file

@ -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 <UIKit/UIKit.h>
@interface UICamSwitch : UIButton {
@private
char* currentCamId;
char* nextCamId;
UIView* preview;
}
@property (nonatomic, retain) IBOutlet UIView* preview;
@end

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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;
}

View file

@ -70,7 +70,6 @@
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
</object>
<string key="IBUINormalTitle">mute</string>
<object class="NSColor" key="IBUIHighlightedTitleColor" id="770254705">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
@ -96,13 +95,16 @@
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<reference key="IBUIFont" ref="996800421"/>
<string key="IBUINormalTitle">hangup</string>
<reference key="IBUIHighlightedTitleColor" ref="770254705"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="19777660"/>
<object class="NSCustomResource" key="IBUINormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">stopcall-red.png</string>
</object>
</object>
<object class="IBUIButton" id="383499753">
<reference key="NSNextResponder" ref="191373211"/>
@ -181,6 +183,22 @@
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">mCamSwitch</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="383499753"/>
</object>
<int key="connectionID">12</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">mMute</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="477702441"/>
</object>
<int key="connectionID">13</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -257,6 +275,7 @@
<string>6.IBPluginDependency</string>
<string>7.CustomClassName</string>
<string>7.IBPluginDependency</string>
<string>8.CustomClassName</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
@ -271,6 +290,7 @@
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIHangUpButton</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UICamSwitch</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
@ -287,11 +307,30 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">11</int>
<int key="maxID">13</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">UICamSwitch</string>
<string key="superclassName">UIButton</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">preview</string>
<string key="NS.object.0">UIView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">preview</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">preview</string>
<string key="candidateClassName">UIView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/UICamSwitch.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIHangUpButton</string>
<string key="superclassName">UIButton</string>
@ -323,6 +362,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>mCamSwitch</string>
<string>mDisplay</string>
<string>mHangUp</string>
<string>mMute</string>
@ -330,6 +370,7 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UICamSwitch</string>
<string>UIImageView</string>
<string>UIHangUpButton</string>
<string>UIMuteButton</string>
@ -340,6 +381,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>mCamSwitch</string>
<string>mDisplay</string>
<string>mHangUp</string>
<string>mMute</string>
@ -347,6 +389,10 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">mCamSwitch</string>
<string key="candidateClassName">UICamSwitch</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">mDisplay</string>
<string key="candidateClassName">UIImageView</string>
@ -380,6 +426,10 @@
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">stopcall-red.png</string>
<string key="NS.object.0">{62, 54}</string>
</object>
<string key="IBCocoaTouchPluginVersion">300</string>
</data>
</archive>

View file

@ -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 = "<group>"; };
22AA8AFB13D7125500B30535 /* libx264.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libx264.a; path = "liblinphone-sdk/apple-darwin/lib/libx264.a"; sourceTree = "<group>"; };
22AA8AFC13D7125500B30535 /* libmsx264.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmsx264.a; path = "liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins/libmsx264.a"; sourceTree = "<group>"; };
22AA8AFF13D83F6300B30535 /* UICamSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICamSwitch.h; sourceTree = "<group>"; };
22AA8B0013D83F6300B30535 /* UICamSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICamSwitch.m; sourceTree = "<group>"; };
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 = "<group>"; };
22B5EFE410CE5E5800777D97 /* ContactPickerDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactPickerDelegate.m; sourceTree = "<group>"; };
@ -739,6 +742,8 @@
22BB1A68132FF16A005CD7AA /* UIEraseButton.m */,
223963151393CFAE001DE689 /* FastAddressBook.h */,
223963161393CFAF001DE689 /* FastAddressBook.m */,
22AA8AFF13D83F6300B30535 /* UICamSwitch.h */,
22AA8B0013D83F6300B30535 /* UICamSwitch.m */,
);
path = LinphoneUI;
sourceTree = "<group>";
@ -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;
};

@ -1 +1 @@
Subproject commit 714c9a52908ae8829f559775fccbbc407574c9ab
Subproject commit b57946b5518da0a50d62b24b6a06606b6006237c