-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add on_rejected_incoming_call() callback #3683
Conversation
Does this handle INVITE crossover, i.e. SIP 491? Having the SIP message, that has been rejected, would/could be useful. Maybe by using sip_event. Isn't it implemented intentionally in PJSUA2? |
- save incoming rdata to be passed as callback parameter
This approach seems to be more complicated than expected. Some alternative ideas: Personally, I like option b. |
A couple of spec questions to consider:
|
|
The transmitted message is very useful for tracing, when onCallTsxState(...) is not called. |
pjsip/include/pjsua-lib/pjsua.h
Outdated
@@ -1967,6 +2016,20 @@ typedef struct pjsua_callback | |||
*/ | |||
void (*on_media_event)(pjmedia_event *event); | |||
|
|||
/** | |||
* This callback is called when an incoming call is rejected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The callback is now called only when it's internally rejected by the library, right? Will using pjsua_call_answer()
also trigger the callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor:
make it clear in the doc that the callback is only called for calls that are internally rejected by the library. And the callback won't be called if user rejects the call using pjsua_call_answer/answer2()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the callback will not trigger when pjsua_call_answer()
is used to reject the call
By "tracing", you mean for info only, correct? |
Yes. |
pjsip/src/pjsua-lib/pjsua_call.c
Outdated
@@ -1475,6 +1516,8 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) | |||
pjmedia_sdp_session *offer=NULL; | |||
pj_bool_t should_dec_dlg = PJ_FALSE; | |||
pjsip_tpselector tp_sel; | |||
pj_str_t st_reason = pj_str(""); | |||
int st_code = 200; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not initialize st_code
with zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's following the original code on
pjproject/pjsip/src/pjsua-lib/pjsua_call.c
Line 1561 in 05d03ad
int st_code = 200; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's following the original code on
pjproject/pjsip/src/pjsua-lib/pjsua_call.c
Line 1561 in 05d03ad
int st_code = 200;
Oh, "the original code" is actually the default answer code for replaced dialog (may be overriden by app from the replaced dlg callback). IMO better not share the same var with the replaced dialog, it serves different purpose, it may cause confusion in the future.
pjsip/src/pjsua-lib/pjsua_call.c
Outdated
@@ -1965,6 +2023,7 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) | |||
pjsua_perror(THIS_FILE, "Error initializing media channel", status); | |||
|
|||
pjsip_dlg_inc_lock(dlg); | |||
st_code = sip_err_code; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When pjsua_media_channel_init()
is done async-ly or returning EPENDING
, e.g: due to waiting for TURN allocations, the library may reject the call if the media init fails, should we invoke the callback too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting scenario indeed. And note that on_incoming_call()
has been called for such case, whereas for other cases, it hasn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the on_incoming_call()
has been called, the new callback (on_rejected_incoming_call()
) should not be called again. Another case would be if the called is answered with 200OK, however there's an issue (e.g: media init) and the call is rejected. The callback would not be called, however app still be informed from on_call_state()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure the behavior is consistent on pjsua2 as well, since on pjsua2 onIncomingCall() is called earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is async, I guess there can be race between on_incoming_call()
and on_incoming_call_med_tp_complete()
, in other word, we cannot be sure whether on_incoming_call()
has been called?
Moreover, the purpose of the callback is to notify app about the call rejection by lib (e.g: so app can stop the incoming call UI), I guess it is better to still call the callback even when on_incoming_call()
has been called. Btw, if rx_data
is the problem (add complexity for example), IMHO we can set it to NULL for now for this scenario (notifying app is the priority).
…ode to using defined/enum error for uniformity
Sorry for rather late comment. But maybe we should consider adding |
looks okay. |
Just a few additional notes: But I think the PR can be merged first for now. If there's any feedback @anikitin-intermedia, please feel free to inform us. |
Consider the scenario: (on iOS)
This PR will add a new callback
on_rejected_incoming_call()
to notifiy the application in case incoming call is rejected.