Commit a8122d57 authored by DanmeiChen's avatar DanmeiChen

support callkit

parent 1eb39010
......@@ -1527,6 +1527,9 @@ static void sip_config_read(LinphoneCore *lc) {
tmp=lp_config_get_int(lc->config,"app","sender_name_hidden_in_forward_message",0);
linphone_core_enable_sender_name_hidden_in_forward_message(lc, !!tmp);
tmp=lp_config_get_int(lc->config, "app", "use_callkit", 0);
linphone_core_callkit_enabled(lc, !!tmp);
/*In case of remote provisionning, function sip_config_read is initialy called in core_init, then in state ConfiguringSuccessfull*/
/*Accordingly, to avoid proxy_config to be added twice, it is mandatory to reset proxy config list from LinphoneCore*/
/*We assume, lc->config contains an accurate list of proxy_config, so no need to keep it from LinphoneCore */
......@@ -6726,6 +6729,14 @@ void linphone_core_soundcard_hint_check(LinphoneCore* lc) {
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->soundcardHintCheck();
}
void linphone_core_audio_session_activated (LinphoneCore* lc, bool_t actived) {
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->soundcardAudioSessionActivated(actived);
}
void linphone_core_callkit_enabled (LinphoneCore* lc, bool_t enabled) {
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->soundcardCallkitEnabled(enabled);
}
void linphone_core_set_remote_ringback_tone(LinphoneCore *lc, const char *file){
if (lc->sound_conf.ringback_tone){
ms_free(lc->sound_conf.ringback_tone);
......
......@@ -67,7 +67,13 @@ int linphone_ringtoneplayer_ios_start_with_cb(LinphoneRingtonePlayer* rp, const
ms_warning("%s: a player is already instantiated, stopping it first.", __FUNCTION__);
linphone_ringtoneplayer_ios_stop(rp);
}
rp->player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
NSError * error = NULL;
rp->player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if(rp->player == NULL && error != NULL) {
ms_error("Failed in creating AVAudioPlayer: %s", error.localizedDescription.UTF8String);
return 1;
}
[rp->player prepareToPlay];
rp->player.numberOfLoops = (loop_pause_ms >= 0) ? -1 : 0;
rp->player.delegate = rp->playerDelegate;
......
......@@ -122,6 +122,17 @@ LINPHONE_PUBLIC void linphone_core_start_dtmf_stream(LinphoneCore* lc);
*/
LINPHONE_PUBLIC void linphone_core_stop_dtmf_stream(LinphoneCore* lc);
/**
* @ingroup IOS
* Special function to indicate if the audio session is activated. Must be called when ProviderDelegate of the callkit notifies that the audio session is activated or deactivated.
*/
LINPHONE_PUBLIC void linphone_core_audio_session_activated(LinphoneCore* lc, bool_t actived);
/**
* @ingroup IOS
* Special function to indicate if the callkit is enabled, False by default.
*/
void linphone_core_callkit_enabled (LinphoneCore* lc, bool_t enabled);
typedef bool_t (*LinphoneCoreIterateHook)(void *data);
......
......@@ -213,6 +213,20 @@ void Core::soundcardHintCheck () {
}
}
void Core::soundcardAudioSessionActivated (bool actived) {
MSSndCard *card = getCCore()->sound_conf.capt_sndcard;
if (card) {
ms_snd_card_notify_audio_session_activated(card, actived);
}
}
void Core::soundcardCallkitEnabled (bool enabled) {
MSSndCard *card = getCCore()->sound_conf.capt_sndcard;
if (card) {
ms_snd_card_app_notifies_activation(card, enabled);
}
}
LinphoneStatus Core::terminateAllCalls () {
L_D();
while (!d->calls.empty()) {
......
......@@ -103,6 +103,8 @@ public:
std::shared_ptr<Call> getCurrentCall () const;
LinphoneStatus pauseAllCalls ();
void soundcardHintCheck ();
void soundcardAudioSessionActivated (bool active);
void soundcardCallkitEnabled (bool enabled);
LinphoneStatus terminateAllCalls ();
// ---------------------------------------------------------------------------
......
......@@ -195,7 +195,7 @@ class SwiftTranslator(object):
if normalType == "Bool":
listenerDict['delegate']['params'] += argName + ": " + argName + " != 0"
elif type(arg.type) is AbsApi.ClassType:
listenerDict['delegate']['params'] += argName + ": " + normalType + ".getSobject(cObject: " + argName + "!)"
listenerDict['delegate']['params'] += argName + ": " + normalType + ".getSwiftObject(cObject: " + argName + "!)"
elif type(arg.type) is AbsApi.EnumType:
ends = "" if arg.type.desc.isFlag else "!"
listenerDict['delegate']['params'] += argName + ": " + referenceType + "(rawValue: Int(" + argName + ".rawValue))" + ends
......
......@@ -140,14 +140,14 @@ open class {{interfaceName}} : LinphoneObjectDelegate
{{c_name_setter}}(cPtr, { ({{{params_private}}}) -> {{return}} in
if ({{first_param}} != nil) {
let sObject = {{interfaceClassName}}.getSobject(cObject: {{first_param}}!)
let sObject = {{interfaceClassName}}.getSwiftObject(cObject: {{first_param}}!)
let delegate = sObject.currentCallbacks
{{#classLists}}
var {{argName}}sList = [{{classType}}]()
var {{argName}}cList = {{argName}}
while ({{argName}}cList != nil) {
let data = unsafeBitCast({{argName}}cList!.pointee.data, to: OpaquePointer.self)
{{argName}}sList.append({{classType}}.getSobject(cObject: data))
{{argName}}sList.append({{classType}}.getSwiftObject(cObject: data))
{{argName}}cList = UnsafePointer<bctbx_list_t>({{argName}}cList!.pointee.next)
}
{{/classLists}}
......@@ -199,7 +199,7 @@ open class {{interfaceName}} : LinphoneObjectDelegate
{{/detailedDoc}}
public class {{className}} : LinphoneObject
{
static func getSobject(cObject:OpaquePointer) -> {{className}} {
static public func getSwiftObject(cObject:OpaquePointer) -> {{className}} {
let result = belle_sip_object_data_get(UnsafeMutablePointer(cObject), "swiftRef")
if (result != nil) {
return Unmanaged<{{className}}>.fromOpaque(result!).takeUnretainedValue()
......@@ -211,6 +211,10 @@ public class {{className}} : LinphoneObject
return sObject
}
public var getCobject: OpaquePointer? {
return cPtr
}
{{#isLinphoneCore}}
/// Get the native window handle of the video window.
public var NativeVideoWindowIdString: String
......@@ -322,7 +326,7 @@ public class {{className}} : LinphoneObject
if (cPointer == nil) {
return nil
}
return {{{return}}}.getSobject(cObject:cPointer!){{/Instance}}{{#Instance}}return {{{return}}}.getSobject(cObject:{{getter_c_name}}({{cPtr}})){{/Instance}}
return {{{return}}}.getSwiftObject(cObject:cPointer!){{/Instance}}{{#Instance}}return {{{return}}}.getSwiftObject(cObject:{{getter_c_name}}({{cPtr}})){{/Instance}}
{{/is_class}}
{{#is_enum}}
return {{{return}}}(rawValue: Int({{getter_c_name}}({{cPtr}}).rawValue)){{^isFlag}}!{{/isFlag}}
......@@ -347,7 +351,7 @@ public class {{className}} : LinphoneObject
var cList = {{getter_c_name}}({{cPtr}})
while (cList != nil) {
let data = unsafeBitCast(cList?.pointee.data, to: OpaquePointer.self)
swiftList.append({{{list_type}}}.getSobject(cObject: data))
swiftList.append({{{list_type}}}.getSwiftObject(cObject: data))
cList = Unsafe{{#isNotConst}}Mutable{{/isNotConst}}Pointer<bctbx_list_t>(cList?.pointee.next)
}
return swiftList
......@@ -493,7 +497,7 @@ public class {{className}} : LinphoneObject
{{#return}}if (cPointer == nil) {
{{#create_method}}throw LinphoneError.exception(result: "create null {{type}} value"){{/create_method}}{{^create_method}}return nil{{/create_method}}
}{{/return}}
{{return}}{{{type}}}.getSobject(cObject: cPointer!)
{{return}}{{{type}}}.getSwiftObject(cObject: cPointer!)
{{/is_class}}
{{#is_enum}}
{{#exception}}let exception_result = {{/exception}}{{#return}}{{return}}{{{type}}}(rawValue: Int({{/return}}{{c_name}}({{cPtr}}{{{c_args}}}){{#return}}.rawValue))!{{/return}}
......@@ -533,7 +537,7 @@ public class {{className}} : LinphoneObject
var cList = {{c_name}}({{cPtr}}{{{c_args}}})
while (cList != nil) {
let data = unsafeBitCast(cList?.pointee.data, to: OpaquePointer.self)
swiftList.append({{{list_type}}}.getSobject(cObject: data))
swiftList.append({{{list_type}}}.getSwiftObject(cObject: data))
cList = Unsafe{{#isNotConst}}Mutable{{/isNotConst}}Pointer<bctbx_list_t>(cList?.pointee.next)
}
return swiftList
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment