What is the best way to get the number of incoming calls?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just tried. It always returns 0 after step 3 while
incoming_calls_count() sometimes returns 0 and sometimes 1. But after
step 5 the return code of pjsua_call_get_info() is 25354 (sometimes
25274).

Example1:
02:16:45.325 AKTelephoneCal  Call 0 state changed to CALLING
02:16:45.364 AKTelephoneCal  Call 1 state changed to INCOMING
02:16:46.334 AKTelephoneCal  Call 2 state changed to CALLING
02:16:46.376 AKTelephoneCal  Call 3 state changed to INCOMING
02:16:47.447 AKTelephoneCal  Call 3 is DISCONNECTED [reason = 603 (Decline)]
02:16:47.472 AKTelephoneCal  Call 2 is DISCONNECTED [reason = 603 (Declined)]
2008-11-27 02:16:47.648 Telephone[1813:10b] Incoming calls count: 0; status: 0
02:16:49.067 AKTelephoneCal  Call 0 is DISCONNECTED [reason = 487
(Request Terminated)]
02:16:49.069 AKTelephoneCal  Call 1 is DISCONNECTED [reason = 487
(Request Terminated)]
2008-11-27 02:16:49.109 Telephone[1813:10b] Incoming calls count: 0;
status: 25354

Example 2:
03:22:27.789 AKTelephoneCal  Call 0 state changed to CALLING
03:22:27.863 AKTelephoneCal  Call 1 state changed to INCOMING
03:22:29.326 AKTelephoneCal  Call 2 state changed to CALLING
03:22:29.384 AKTelephoneCal  Call 3 state changed to INCOMING
03:22:29.384 AKTelephoneCal  Incoming call for account 0!
03:22:30.932 AKTelephoneCal  Call 0 is DISCONNECTED [reason = 487
(Request Terminated)]
03:22:30.934 AKTelephoneCal  Call 1 is DISCONNECTED [reason = 487
(Request Terminated)]
2008-11-27 03:22:30.937 Telephone[2466:10b] Incoming calls count: 1; status: 0
2008-11-27 03:22:30.938 Telephone[2466:10b] Error string: Success
03:22:31.548 AKTelephoneCal  Call 2 is DISCONNECTED [reason = 487
(Request Terminated)]
03:22:31.549 AKTelephoneCal  Call 3 is DISCONNECTED [reason = 487
(Request Terminated)]
2008-11-27 03:22:31.550 Telephone[2466:10b] Incoming calls count: 0;
status: 25274
2008-11-27 03:22:31.550 Telephone[2466:10b] Error string: Unknown error 25274

status is the return code of pjsua_call_get_info() inside
incoming_calls_count().

Alexei

On Wed, Nov 26, 2008 at 10:02 PM, Nanang Izzuddin <nanang at pjsip.org> wrote:
> Hi,
>
> Sounds strange. Have you tried to examine the return code of
> pjsua_call_get_info()?
>
> Regards,
> nanang
>
>
> On Wed, Nov 26, 2008 at 3:34 AM, Alexei Kuznetsov <eofster at gmail.com> wrote:
>> Hi,
>>
>> I need to get the number of current calls in PJSIP_INV_STATE_INCOMING
>> state. Here is how I'm trying to achieve that:
>>
>> unsigned incoming_calls_count()
>> {
>>        pjsua_call_id call_ids[PJSUA_MAX_CALLS];
>>
>>        unsigned all_count;
>>        pjsua_enum_calls(call_ids, &all_count);
>>
>>        unsigned incoming_count = 0;
>>        for (unsigned i = 0; i < all_count; ++i) {
>>                pjsua_call_info call_info;
>>                pjsua_call_get_info(call_ids[i], &call_info);
>>
>>                if (call_info.state == PJSIP_INV_STATE_INCOMING)
>>                        ++incoming_count;
>>        }
>>
>>        return incoming_count;
>> }
>>
>> I call this function on the main thread when any call enters
>> disconnected state. But sometimes it doesn't return the actual number
>> of incoming calls.
>>
>> For example:
>> 1. first incoiming call received (not answered)
>> 2. second incoming call received (not answered)
>> 3. the user hangs up the second call or the call is disconnected by
>> another party
>> 4. incoming_calls_count() on the main thread sometimes returns 1 and sometimes 0
>> 5. first call is disconnected, incoming_calls_count() always returns 0
>>
>> But if inside incoming_calls_count() I add a function call to log
>> something to the console, incoming_calls_count() always returns
>> correct value!
>>
>> What am I missing? Any threading issues? Is there a better way to do
>> that? I'm using pjproject-1.0.
>>
>> Best regards,
>> Alexei Kuznetsov



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux