diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 2a813d0f5..52d29b56b 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -27,7 +27,7 @@ #include "CallHistoryTableViewController.h" #include "LinphoneManager.h" - +#include "linphonecore.h" @implementation linphoneAppDelegate @@ -37,11 +37,44 @@ @synthesize myPhoneViewController; +-(void)applicationWillResignActive:(UIApplication *)application { + LinphoneCore* lc = [LinphoneManager getLc]; + LinphoneCall* call = linphone_core_get_current_call(lc); + if (call == NULL) + return; + + /* save call context */ + LinphoneManager* instance = [LinphoneManager instance]; + instance->currentCallContextBeforeGoingBackground.call = call; + instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call); + + const LinphoneCallParams* params = linphone_call_get_current_params(call); + if (linphone_call_params_video_enabled(params)) { + linphone_call_enable_camera(call, false); + } + +} - (void)applicationDidEnterBackground:(UIApplication *)application { [[LinphoneManager instance] enterBackgroundMode]; } - (void)applicationDidBecomeActive:(UIApplication *)application { [[LinphoneManager instance] becomeActive]; + + LinphoneCore* lc = [LinphoneManager getLc]; + LinphoneCall* call = linphone_core_get_current_call(lc); + if (call == NULL) + return; + + LinphoneManager* instance = [LinphoneManager instance]; + if (call == instance->currentCallContextBeforeGoingBackground.call) { + const LinphoneCallParams* params = linphone_call_get_current_params(call); + if (linphone_call_params_video_enabled(params)) { + linphone_call_enable_camera( + call, + instance->currentCallContextBeforeGoingBackground.cameraIsEnabled); + } + instance->currentCallContextBeforeGoingBackground.call = 0; + } } - (void) loadDefaultSettings { diff --git a/Classes/LinphoneUI/LinphoneManager.h b/Classes/LinphoneUI/LinphoneManager.h index 6b8114db3..1c0915469 100644 --- a/Classes/LinphoneUI/LinphoneManager.h +++ b/Classes/LinphoneUI/LinphoneManager.h @@ -29,6 +29,13 @@ typedef enum _Connectivity { ,none } Connectivity; @class FastAddressBook; + +/* Application specific call context */ +typedef struct _CallContext { + LinphoneCall* call; + bool_t cameraIsEnabled; +} CallContext; + @interface LinphoneManager : NSObject { @private SCNetworkReachabilityContext proxyReachabilityContext; @@ -44,7 +51,9 @@ typedef enum _Connectivity { FastAddressBook* mFastAddressBook; const char* frontCamId; const char* backCamId; - + +@public + CallContext currentCallContextBeforeGoingBackground; } +(LinphoneManager*) instance; +(LinphoneCore*) getLc;