Re: [pjsip] Check state of call

N
nab@ukr.net
Sat, Feb 13, 2021 11:13 PM

PJSIP_INV_STATE_INCOMING and PJSIP_INV_STATE_CALLING are set for a short time. Then the state switches to PJSIP_INV_STATE_EARLY. And you can determine the state by the role and state of the media. Well, or display your flags in onCallState or other callback.

I think this option will be even more reliable:
@property
def incoming (self):
return not self.call.hasMedia () and
(self.role == PJ.PJSIP_ROLE_UAS
or self.role == PJ.PJSIP_UAS_ROLE)
# incoming

@property
def calling (self):
    return not self.call.hasMedia () and \
            (self.role == PJ.PJSIP_ROLE_UAC \
            or self.role == PJ.PJSIP_UAC_ROLE)
# calling

@property
def talking (self):
    return self.call.hasMedia ()
#talking

Is it possible to add a check for:
self.state != PJ.PJSIP_INV_STATE_NULL

or self.call.isActive()

Hi.
?
It think it?s right. But I always check call state without hasMedia and roles.
I?ve faced with the issue that I couldn?t get PJ.PJSIP_INV_STATE_INCOMING for incoming calls. So I had to set flag for the?incoming call in the callback function onIncomingCall. It?s workaround I could come up with.
?

PJSIP_INV_STATE_INCOMING and PJSIP_INV_STATE_CALLING are set for a short time. Then the state switches to PJSIP_INV_STATE_EARLY. And you can determine the state by the role and state of the media. Well, or display your flags in onCallState or other callback. I think this option will be even more reliable: @property def incoming (self): return not self.call.hasMedia () and \ (self.role == PJ.PJSIP_ROLE_UAS \ or self.role == PJ.PJSIP_UAS_ROLE) # incoming @property def calling (self): return not self.call.hasMedia () and \ (self.role == PJ.PJSIP_ROLE_UAC \ or self.role == PJ.PJSIP_UAC_ROLE) # calling @property def talking (self): return self.call.hasMedia () #talking Is it possible to add a check for: self.state != PJ.PJSIP_INV_STATE_NULL or self.call.isActive() > > Hi. > ? > It think it?s right. But I always check call state without hasMedia and roles. > I?ve faced with the issue that I couldn?t get PJ.PJSIP_INV_STATE_INCOMING for incoming calls. So I had to set flag for the?incoming call in the callback function onIncomingCall. It?s workaround I could come up with. > ?