Commit 18334924 authored by DanmeiChen's avatar DanmeiChen
Browse files

didEnterBackground/Foreground for ios

parent ce16cd73
......@@ -12,6 +12,7 @@ This changelog file was started on October 2019. Previous changes were more or l
### Added
- RTP bundle mode feature according to https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-54 .
- EnterForeground and enterBackground automatically for ios and anroid.
### Changed
- Big internal refactoring of how streams are managed within offer/answer exchanges.
......
......@@ -30,9 +30,18 @@ set(LINK_LIBS
if(ENABLE_ADVANCED_IM)
list(APPEND LIBS ${LIBXSD_LIBRARIES})
endif()
#APPLE_LIBS is mandatory for apple compilation
if(APPLE)
list(APPEND APPLE_LIBS "-framework CFNetwork -framework Foundation -framework AVFoundation -framework SystemConfiguration -framework CoreLocation")
if(IOS)
list(APPEND APPLE_LIBS "-framework UIKit")
endif()
endif()
#interface_libs is used in export cmake config file
if(APPLE)
list(APPEND INTERFACE_LIBS "-framework CFNetwork -framework Foundation -framework AVFoundation -framework SystemConfiguration -framework CoreLocation")
list(APPEND INTERFACE_LIBS ${APPLE_LIBS})
endif()
set(INTERFACE_LIBS ${LINK_LIBS} xml2 xsd)
......@@ -458,6 +467,10 @@ if (APPLE)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-apple.h)
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/platform-helpers/ios-platform-helpers.mm)
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/shared-core-helpers/ios-shared-core-helpers.mm)
if (IOS)
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/app/ios-app-delegate.h)
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/app/ios-app-delegate.mm)
endif()
elseif (ANDROID)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-android.cpp core/platform-helpers/android-platform-helpers.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-android.h)
......@@ -528,7 +541,7 @@ if(ENABLE_STATIC)
target_link_libraries(linphone-static PRIVATE ${LINK_LIBS})
if(APPLE)
target_link_libraries(linphone-static PUBLIC "-framework Foundation" "-framework AVFoundation" "-framework SystemConfiguration -framework CFNetwork -framework CoreLocation")
target_link_libraries(linphone-static PUBLIC ${APPLE_LIBS})
endif()
install(TARGETS linphone-static EXPORT ${EXPORT_TARGETS_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
......@@ -598,7 +611,7 @@ if(ENABLE_SHARED)
target_link_libraries(linphone PRIVATE ${LINK_LIBS})
if(APPLE)
target_link_libraries(linphone PUBLIC "-framework Foundation" "-framework AVFoundation" "-framework SystemConfiguration -framework CFNetwork -framework CoreLocation")
target_link_libraries(linphone PUBLIC ${APPLE_LIBS})
endif()
if(WIN32)
# Export Xerces and Soci symbols.
......
/*
* Copyright (c) 2010-2019 Belledonne Communications SARL.
*
* This file is part of Liblinphone.
*
* 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 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <UIKit/UIKit.h>
#include "private.h"
@interface IosAppDelegate : NSObject {
std::shared_ptr<LinphonePrivate::Core> pcore;
}
- (void)setCore:(std::shared_ptr<LinphonePrivate::Core>)core;
@end
/*
* Copyright (c) 2010-2019 Belledonne Communications SARL.
*
* This file is part of Liblinphone.
*
* 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 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ios-app-delegate.h"
@implementation IosAppDelegate
- (id)init {
self = [super init];
if (self != nil) {
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(didEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(didEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}
return self;
}
- (void)dealloc {
[super dealloc];
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (void)setCore:(std::shared_ptr<LinphonePrivate::Core>)core {
pcore = core;
}
- (void)didEnterBackground:(NSNotification *)notif {
ms_message("[Ios App] didEnterBackground");
pcore->enterBackground();
}
- (void)didEnterForeground:(NSNotification *)notif {
ms_message("[Ios App] didEnterForeground");
pcore->enterForeground();
}
@end
......@@ -236,6 +236,14 @@ void CorePrivate::notifyEnteringBackground () {
if (isFriendListSubscriptionEnabled)
enableFriendListsSubscription(false);
#if TARGET_OS_IPHONE
L_Q();
LinphoneCore *lc = L_GET_C_BACK_PTR(q);
// Stop the video preview
linphone_core_enable_video_preview(lc, FALSE);
linphone_core_stop_dtmf_stream(lc);
#endif
}
void CorePrivate::notifyEnteringForeground () {
......@@ -257,7 +265,15 @@ void CorePrivate::notifyEnteringForeground () {
listener->onEnteringForeground();
if (isFriendListSubscriptionEnabled)
enableFriendListsSubscription(true);
enableFriendListsSubscription(true);
#if TARGET_OS_IPHONE
linphone_core_start_dtmf_stream(lc);
/*start the video preview in case we are in the main view*/
if (linphone_core_video_display_enabled(lc) && linphone_config_get_bool(lc->config, "app", "preview_preference", 0)) {
linphone_core_enable_video_preview(lc, TRUE);
}
#endif
}
belle_sip_main_loop_t *CorePrivate::getMainLoop(){
......
......@@ -39,6 +39,7 @@
// TODO: Remove me
#include "private.h"
#include "core/app/ios-app-delegate.h"
// =============================================================================
using namespace std;
......@@ -48,7 +49,9 @@ LINPHONE_BEGIN_NAMESPACE
class IosPlatformHelpers : public GenericPlatformHelpers {
public:
IosPlatformHelpers (std::shared_ptr<LinphonePrivate::Core> core, void *systemContext);
~IosPlatformHelpers () = default;
~IosPlatformHelpers (){
[mAppDelegate dealloc];
}
void acquireWifiLock () override {}
void releaseWifiLock () override {}
......@@ -106,6 +109,7 @@ private:
SCNetworkReachabilityFlags mCurrentFlags = 0;
bool mNetworkMonitoringEnabled = false;
static const string Framework;
IosAppDelegate *mAppDelegate;
};
static void sNetworkChangeCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo);
......@@ -120,6 +124,9 @@ IosPlatformHelpers::IosPlatformHelpers (std::shared_ptr<LinphonePrivate::Core> c
mNetworkReachable = 0; // wait until monitor to give a status;
mSharedCoreHelpers = createIosSharedCoreHelpers(core);
mAppDelegate = [[IosAppDelegate alloc] init];
[mAppDelegate setCore:core];
string cpimPath = getResourceDirPath(Framework, "cpim_grammar");
if (!cpimPath.empty())
belr::GrammarLoader::get().addPath(cpimPath);
......
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