Skip to content

Commit

Permalink
Don't call close_pc in SIP plugin if there was no SDP (fixes #3332) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero committed Mar 25, 2024
1 parent 5c6b2bb commit 0f32c32
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/ice.c
Expand Up @@ -1411,6 +1411,7 @@ janus_ice_handle *janus_ice_handle_create(void *core_session, const char *opaque
handle->queued_candidates = g_async_queue_new();
handle->queued_packets = g_async_queue_new();
janus_mutex_init(&handle->mutex);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT);
janus_session_handles_insert(session, handle);
return handle;
}
Expand Down
19 changes: 13 additions & 6 deletions src/plugins/janus_sip.c
Expand Up @@ -696,8 +696,8 @@


/* Plugin information */
#define JANUS_SIP_VERSION 8
#define JANUS_SIP_VERSION_STRING "0.0.8"
#define JANUS_SIP_VERSION 9
#define JANUS_SIP_VERSION_STRING "0.0.9"
#define JANUS_SIP_DESCRIPTION "This is a simple SIP plugin for Janus, allowing WebRTC peers to register at a SIP server and call SIP user agents through a Janus instance."
#define JANUS_SIP_NAME "JANUS SIP plugin"
#define JANUS_SIP_AUTHOR "Meetecho s.r.l."
Expand Down Expand Up @@ -2466,7 +2466,7 @@ void janus_sip_setup_media(janus_plugin_session *handle) {
g_atomic_int_set(&session->establishing, 0);
g_atomic_int_set(&session->hangingup, 0);
janus_mutex_unlock(&sessions_mutex);
/* TODO Only relay RTP/RTCP when we get this event */
/* Only relay RTP/RTCP when we get this event */
}

void janus_sip_incoming_rtp(janus_plugin_session *handle, janus_plugin_rtp *packet) {
Expand Down Expand Up @@ -4286,7 +4286,7 @@ static void *janus_sip_handler(void *data) {
if(session->stack->s_nh_i == NULL) {
JANUS_LOG(LOG_WARN, "NUA Handle for 200 OK still null??\n");
}
int response_code = 486;
int response_code = 603;
json_t *code_json = json_object_get(root, "code");
if(code_json)
response_code = json_integer_value(code_json);
Expand Down Expand Up @@ -5141,8 +5141,15 @@ void janus_sip_sofia_callback(nua_event_t event, int status, char const *phrase,
session->hangup_reason_header = NULL;
session->hangup_reason_header_protocol = NULL;
session->hangup_reason_header_cause = NULL;
if(g_atomic_int_get(&session->establishing) || g_atomic_int_get(&session->established))
gateway->close_pc(session->handle);
if(g_atomic_int_get(&session->establishing) || g_atomic_int_get(&session->established)) {
if(session->media.has_audio || session->media.has_video) {
/* Get rid of the PeerConnection in the core */
gateway->close_pc(session->handle);
} else {
/* No SDP was exchanged, just clean up locally */
janus_sip_hangup_media_internal(session->handle);
}
}
} else if(session->stack->s_nh_i == nh && callstate == nua_callstate_calling && session->status == janus_sip_call_status_incall) {
/* Have just sent re-INVITE */
janus_sip_call_update_status(session, janus_sip_call_status_incall_reinviting);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/plugin.h
Expand Up @@ -401,7 +401,8 @@ struct janus_callbacks {

/*! \brief Callback to ask the core to close a WebRTC PeerConnection
* \note A call to this method will result in the core invoking the hangup_media
* callback on this plugin when done
* callback on this plugin when done, but only if a PeerConnection had been
* created or was in the process of being negotiated (SDP exchanged)
* @param[in] handle The plugin/gateway session that the PeerConnection is related to */
void (* const close_pc)(janus_plugin_session *handle);
/*! \brief Callback to ask the core to get rid of a plugin/gateway session
Expand Down

0 comments on commit 0f32c32

Please sign in to comment.