2009/7/5 Paulo Rog?rio Panhoto <paulo at voicetechnology.com.br>: > Hello, > > I was wonder how can I know whether a disconnection is local or remote. On > PJSIP 1.3, always a "PJSIP_EVENT_TSX_STATE" event arrives at all kinds of > disconnection. There is a union called src that contains rdata and tdata. > How can this union be tested to give the information on which member must be > used. Hello Paulo, maybe someone else can give you a better answer. But here's my shot: I don't know at which level of the PJSIP API you are working with but to get disconnection events, I set the on_state_changed in the pjsip_inv_callback struct. When the cb is called, I check inv->state and if it is PJSIP_INV_STATE_DISCONNECTED, I discern between local and remote from my state-machine: if I have sent pjsip_inv_end_session, then I am waiting a state change that I have initiated. Well, maybe you are working on a lower level independent of what other layers of app are doing. In this case, I think you could inspect the values of the pjsip_transaction, like pjsip_role_e (UAC or UAS) and the sip_method: if you are the UAS in a BYE/CANCEL transaction, then it was a remote disconnection (but I never tested this). And I believe rdata/tdata will not have valid data in case of PJSIP_EVENT_TSX_STATE. I believe they will be filled only in case of PJSIP_EVENT_RX_MSG or PJSIP_EVENT_TX_MSG.