]> sjero.net Git - linphone/commitdiff
Function to check if a call locks sound resources.
authorGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Thu, 27 Oct 2011 08:38:05 +0000 (10:38 +0200)
committerGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Thu, 27 Oct 2011 08:38:05 +0000 (10:38 +0200)
Use to prevent a situation where several calls
try to use the sound resources.
- outgoing states (ring)
- incoming states (ring)
- ..

coreapi/conference.c
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
java/common/org/linphone/core/LinphoneCore.java

index 767eaf07dae3fff157048a5e904c7ffa65d2df1f..94bf17bc178396be9d1797659c090f09667f6935 100644 (file)
@@ -189,6 +189,9 @@ int linphone_core_leave_conference(LinphoneCore *lc){
 
 
 int linphone_core_enter_conference(LinphoneCore *lc){
+       if (linphone_core_sound_resources_locked) {
+               return -1;
+       }
        LinphoneConference *conf=&lc->conf_ctx;
        if (conf->local_participant==NULL) add_local_endpoint(conf,lc);
        return 0;
index 7e3a1f262098b5546fc415d9164e41ff928c3f63..66334ea0f4e3022a7ac8062f6d6bb324dbcf2151 100644 (file)
@@ -4381,3 +4381,32 @@ const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const cha
        }
        return NULL;
 }
+
+
+/**
+ * Check if a call will need the sound resources.
+ *
+ * @ingroup call_control
+ * @param lc The LinphoneCore
+**/
+bool_t linphone_core_sound_resources_locked(LinphoneCore *lc){
+       MSList *calls=lc->calls;
+       while(calls) {
+               LinphoneCall *c=(LinphoneCall*)calls->data;
+               calls=calls->next;
+               switch (c->state) {
+                       case LinphoneCallOutgoingInit:
+                       case LinphoneCallOutgoingProgress:
+                       case LinphoneCallOutgoingRinging:
+                       case LinphoneCallOutgoingEarlyMedia:
+                       case LinphoneCallConnected:
+                       case LinphoneCallRefered:
+                       case LinphoneCallIncomingEarlyMedia:
+                       case LinphoneCallUpdated:
+                               return TRUE;
+                       default:
+                               break;
+               }
+       }
+       return FALSE;
+}
index a85855def0f0722f793f2c98e46086f5cca7e1b9..0f49a4593e561decd055992ab718fc1d9a404971 100644 (file)
@@ -1031,6 +1031,7 @@ int linphone_core_terminate_conference(LinphoneCore *lc);
 int linphone_core_get_conference_size(LinphoneCore *lc);
 
 int linphone_core_get_max_calls(LinphoneCore *lc);
+bool_t linphone_core_sound_resources_locked(LinphoneCore *lc);
 
 #ifdef __cplusplus
 }
index f12a95d90d0c262f00fa414d1fc633dadb228028..6da09ef6b9ae9f549d0deba7c2174b2a1c52d599 100644 (file)
@@ -1506,6 +1506,10 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_areStreamsEncrypted(
        return linphone_call_are_all_streams_encrypted((LinphoneCall *) ptr);
 }
 
+extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
+       return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
+}
+
 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
 // Implemented directly in msandroid.cpp (sound filters for Android).
 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
index 0d560f4e2648600c93f6e8b3bcd5bf050a41cb36..fcd041dc8a6c5745fef27c0abd5d7ce0aee72f0b 100644 (file)
@@ -625,4 +625,13 @@ public interface LinphoneCore {
        int getMaxCalls();
        boolean isMyself(String uri);
 
+       /**
+        * Use this method to check the calls state and forbid proposing actions
+        * which could result in an active call.
+        * Eg: don't start a new call if one is in outgoing ringing.
+        * Eg: don't merge to conference either as it could result
+        *     in two active calls (conference and accepted call). 
+        * @return
+        */
+       boolean soundResourcesLocked();
 }