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

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

 



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
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>



[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