diff --git a/ice.c b/ice.c index f4f80cd574..bc2e9e10a8 100644 --- a/ice.c +++ b/ice.c @@ -1378,6 +1378,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; } diff --git a/plugins/janus_sip.c b/plugins/janus_sip.c index a1a80f7154..08d47e76d3 100644 --- a/plugins/janus_sip.c +++ b/plugins/janus_sip.c @@ -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." @@ -2465,7 +2465,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) { @@ -4278,7 +4278,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); @@ -5133,8 +5133,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); diff --git a/plugins/plugin.h b/plugins/plugin.h index 56dd41198d..99a8f32074 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -393,7 +393,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