mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
start adding bluetooth support
This commit is contained in:
parent
9f7d881625
commit
00b9ef2c7f
3 changed files with 112 additions and 0 deletions
27
Classes/LinphoneUI/UIBluetoothButton.h
Normal file
27
Classes/LinphoneUI/UIBluetoothButton.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* UISpeakerButton.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>
|
||||
#import "UIToggleButton.h"
|
||||
|
||||
@interface UIBluetoothButton : UIToggleButton<UIToggleButtonDelegate> {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
79
Classes/LinphoneUI/UIBluetoothButton.m
Normal file
79
Classes/LinphoneUI/UIBluetoothButton.m
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* UISpeakerButton.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 "UIBluetoothButton.h"
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
#include "linphonecore.h"
|
||||
|
||||
@implementation UIBluetoothButton
|
||||
#define check_auresult(au,method) \
|
||||
if (au!=0) ms_error("UIBluetoothButton error for %s: ret=%i",method,au)
|
||||
|
||||
-(void) onOn {
|
||||
//redirect audio to bluetooth
|
||||
|
||||
UInt32 size = sizeof(CFStringRef);
|
||||
CFStringRef route="HeadsetBT";
|
||||
OSStatus result = AudioSessionSetProperty(kAudioSessionProperty_AudioRoute, &size, &route);
|
||||
check_auresult(result,"set kAudioSessionProperty_AudioRoute HeadsetBT");
|
||||
|
||||
int allowBluetoothInput = 1;
|
||||
result = AudioSessionSetProperty (
|
||||
kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,
|
||||
sizeof (allowBluetoothInput),
|
||||
&allowBluetoothInput
|
||||
);
|
||||
check_auresult(result,"set kAudioSessionProperty_OverrideCategoryEnableBluetoothInput 1");
|
||||
|
||||
}
|
||||
-(void) onOff {
|
||||
//redirect audio to bluetooth
|
||||
int allowBluetoothInput = 0;
|
||||
OSStatus result = AudioSessionSetProperty (
|
||||
kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,
|
||||
sizeof (allowBluetoothInput),
|
||||
&allowBluetoothInput
|
||||
);
|
||||
check_auresult(result,"set kAudioSessionProperty_OverrideCategoryEnableBluetoothInput 0");
|
||||
UInt32 size = sizeof(CFStringRef);
|
||||
CFStringRef route="ReceiverAndMicrophone";
|
||||
result = AudioSessionSetProperty(kAudioSessionProperty_AudioRoute, &size, &route);
|
||||
check_auresult(result,"set kAudioSessionProperty_AudioRoute ReceiverAndMicrophone");
|
||||
|
||||
|
||||
}
|
||||
-(bool) isInitialStateOn {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code.
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)dealloc {
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
@ -64,6 +64,7 @@
|
|||
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 */; };
|
||||
22C755601317E59C007BC101 /* UIBluetoothButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 22C7555F1317E59C007BC101 /* UIBluetoothButton.m */; };
|
||||
22D1B68112A3E0BE001AE361 /* libresolv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 22D1B68012A3E0BE001AE361 /* libresolv.dylib */; };
|
||||
22E0A785111C1BA800B04932 /* Speaker-32-on.png in Resources */ = {isa = PBXBuildFile; fileRef = 22E0A783111C1BA800B04932 /* Speaker-32-on.png */; };
|
||||
22E0A786111C1BA800B04932 /* Speaker-32-off.png in Resources */ = {isa = PBXBuildFile; fileRef = 22E0A784111C1BA800B04932 /* Speaker-32-off.png */; };
|
||||
|
|
@ -285,6 +286,8 @@
|
|||
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>"; };
|
||||
22B5F03410CE6B2F00777D97 /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
|
||||
22C7555E1317E59C007BC101 /* UIBluetoothButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIBluetoothButton.h; sourceTree = "<group>"; };
|
||||
22C7555F1317E59C007BC101 /* UIBluetoothButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIBluetoothButton.m; sourceTree = "<group>"; };
|
||||
22D1B68012A3E0BE001AE361 /* libresolv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libresolv.dylib; path = usr/lib/libresolv.dylib; sourceTree = SDKROOT; };
|
||||
22E0A783111C1BA800B04932 /* Speaker-32-on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Speaker-32-on.png"; path = "Resources/Speaker-32-on.png"; sourceTree = "<group>"; };
|
||||
22E0A784111C1BA800B04932 /* Speaker-32-off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Speaker-32-off.png"; path = "Resources/Speaker-32-off.png"; sourceTree = "<group>"; };
|
||||
|
|
@ -586,6 +589,8 @@
|
|||
22968A8712F87C2000588287 /* UIDuration.m */,
|
||||
2218A5C412F9597B0088A667 /* LinphoneUIDelegates.h */,
|
||||
2218A5CE12F973450088A667 /* LogView.h */,
|
||||
22C7555E1317E59C007BC101 /* UIBluetoothButton.h */,
|
||||
22C7555F1317E59C007BC101 /* UIBluetoothButton.m */,
|
||||
);
|
||||
path = LinphoneUI;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -807,6 +812,7 @@
|
|||
22968A5F12F875C600588287 /* UISpeakerButton.m in Sources */,
|
||||
22968A8812F87C2000588287 /* UIDuration.m in Sources */,
|
||||
2218A92512FBE1340088A667 /* FirstLoginViewController.m in Sources */,
|
||||
22C755601317E59C007BC101 /* UIBluetoothButton.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue