Skip to content

Commit

Permalink
Decreased verbosity for some lines (info to verb), and added call to …
Browse files Browse the repository at this point in the history
…nice_agent_remove_stream when enforcing bundle/rtcp-mux (see #154)
  • Loading branch information
lminiero committed Oct 6, 2015
1 parent 614f398 commit 202d13d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 41 deletions.
4 changes: 2 additions & 2 deletions dtls.c
Expand Up @@ -562,7 +562,7 @@ void janus_dtls_callback(const SSL *ssl, int where, int ret) {
JANUS_LOG(LOG_WARN, "[%"SCNu64"] DTLS alert triggered on stream %"SCNu16", but it's the data channel so we don't care...\n", handle->handle_id, stream->stream_id);
return;
}
JANUS_LOG(LOG_INFO, "[%"SCNu64"] DTLS alert triggered on stream %"SCNu16" (component %"SCNu16"), closing...\n", handle->handle_id, stream->stream_id, component->component_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] DTLS alert triggered on stream %"SCNu16" (component %"SCNu16"), closing...\n", handle->handle_id, stream->stream_id, component->component_id);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING);
if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT)) {
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT);
Expand Down Expand Up @@ -727,7 +727,7 @@ void *janus_dtls_sctp_setup_thread(void *data) {
}
janus_sctp_association *sctp = (janus_sctp_association *)dtls->sctp;
/* Do the accept/connect stuff now */
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Started thread: setup of the SCTP association\n", sctp->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Started thread: setup of the SCTP association\n", sctp->handle_id);
janus_sctp_association_setup(sctp);
g_thread_unref(g_thread_self());
return NULL;
Expand Down
26 changes: 13 additions & 13 deletions ice.c
Expand Up @@ -444,7 +444,7 @@ gint janus_ice_trickle_parse(janus_ice_handle *handle, json_t *candidate, const
}
/* Parse trickle candidate */
if(!json_is_object(candidate) || json_object_get(candidate, "completed") != NULL) {
JANUS_LOG(LOG_INFO, "No more remote candidates for handle %"SCNu64"!\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "No more remote candidates for handle %"SCNu64"!\n", handle->handle_id);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALL_TRICKLES);
} else {
/* Handle remote candidate */
Expand Down Expand Up @@ -967,7 +967,7 @@ gint janus_ice_handle_destroy(void *gateway_session, guint64 handle_id) {
}
janus_mutex_unlock(&session->mutex);
/* We only actually destroy the handle later */
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Handle detached (error=%d), scheduling destruction\n", handle_id, error);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Handle detached (error=%d), scheduling destruction\n", handle_id, error);
janus_mutex_lock(&old_handles_mutex);
g_hash_table_insert(old_handles, GUINT_TO_POINTER(handle_id), handle);
janus_mutex_unlock(&old_handles_mutex);
Expand Down Expand Up @@ -1766,7 +1766,7 @@ void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint component_i
}
if(component_id == 3 || (janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RTCPMUX)
&& janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_DATA_CHANNELS))) {
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Not RTP and not RTCP... may these be data channels?\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Not RTP and not RTCP... may these be data channels?\n", handle->handle_id);
janus_dtls_srtp_incoming_msg(component->dtls, buf, len);
/* Update stats (TODO Do the same for the last second window as well) */
if(len > 0) {
Expand Down Expand Up @@ -2443,10 +2443,10 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
nice_agent_set_port_range(handle->agent, handle->audio_id, 2, rtp_range_min, rtp_range_max);
#endif
}
nice_agent_gather_candidates (handle->agent, handle->audio_id);
nice_agent_attach_recv (handle->agent, handle->audio_id, 1, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, audio_rtp);
nice_agent_gather_candidates(handle->agent, handle->audio_id);
nice_agent_attach_recv(handle->agent, handle->audio_id, 1, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, audio_rtp);
if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RTCPMUX) && audio_rtcp != NULL)
nice_agent_attach_recv (handle->agent, handle->audio_id, 2, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, audio_rtcp);
nice_agent_attach_recv(handle->agent, handle->audio_id, 2, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, audio_rtcp);
}
if(video && (!audio || !janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_BUNDLE))) {
/* Add a video stream */
Expand Down Expand Up @@ -2595,10 +2595,10 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
nice_agent_set_port_range(handle->agent, handle->video_id, 2, rtp_range_min, rtp_range_max);
#endif
}
nice_agent_gather_candidates (handle->agent, handle->video_id);
nice_agent_attach_recv (handle->agent, handle->video_id, 1, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, video_rtp);
nice_agent_gather_candidates(handle->agent, handle->video_id);
nice_agent_attach_recv(handle->agent, handle->video_id, 1, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, video_rtp);
if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RTCPMUX) && video_rtcp != NULL)
nice_agent_attach_recv (handle->agent, handle->video_id, 2, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, video_rtcp);
nice_agent_attach_recv(handle->agent, handle->video_id, 2, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, video_rtcp);
}
#ifndef HAVE_SCTP
handle->data_id = 0;
Expand Down Expand Up @@ -2682,8 +2682,8 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
/* FIXME: libnice supports this since 0.1.0, but the 0.1.3 on Fedora fails with an undefined reference! */
nice_agent_set_port_range(handle->agent, handle->data_id, 1, rtp_range_min, rtp_range_max);
#endif
nice_agent_gather_candidates (handle->agent, handle->data_id);
nice_agent_attach_recv (handle->agent, handle->data_id, 1, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, data_component);
nice_agent_gather_candidates(handle->agent, handle->data_id);
nice_agent_attach_recv(handle->agent, handle->data_id, 1, g_main_loop_get_context (handle->iceloop), janus_ice_cb_nice_recv, data_component);
}
#endif
#ifdef HAVE_LIBCURL
Expand All @@ -2697,7 +2697,7 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi

void *janus_ice_send_thread(void *data) {
janus_ice_handle *handle = (janus_ice_handle *)data;
JANUS_LOG(LOG_INFO, "[%"SCNu64"] ICE send thread started...\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] ICE send thread started...\n", handle->handle_id);
janus_ice_queued_packet *pkt = NULL;
gint64 now = janus_get_monotonic_time(), before = now;
while(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALERT)) {
Expand Down Expand Up @@ -3014,7 +3014,7 @@ void *janus_ice_send_thread(void *data) {
continue;
}
}
JANUS_LOG(LOG_INFO, "[%"SCNu64"] ICE send thread leaving...\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] ICE send thread leaving...\n", handle->handle_id);
g_thread_unref(g_thread_self());
return NULL;
}
Expand Down
46 changes: 26 additions & 20 deletions janus.c
Expand Up @@ -1318,7 +1318,7 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
goto jsondone;
}
janus_plugin *plugin_t = (janus_plugin *)handle->app;
JANUS_LOG(LOG_INFO, "[%"SCNu64"] There's a message for %s\n", handle->handle_id, plugin_t->get_name());
JANUS_LOG(LOG_VERB, "[%"SCNu64"] There's a message for %s\n", handle->handle_id, plugin_t->get_name());
json_t *body = json_object_get(root, "body");
if(body == NULL) {
ret = janus_process_error(source, session_id, transaction_text, JANUS_ERROR_MISSING_MANDATORY_ELEMENT, "Missing mandatory element (body)");
Expand Down Expand Up @@ -1350,7 +1350,7 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
type = NULL;
/* Are we still cleaning up from a previous media session? */
if(janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING)) {
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Still cleaning up from a previous media session, let's wait a bit...\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Still cleaning up from a previous media session, let's wait a bit...\n", handle->handle_id);
gint64 waited = 0;
while(janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING)) {
g_usleep(100000);
Expand Down Expand Up @@ -1484,43 +1484,46 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
handle->audio_stream->video_ssrc = handle->video_stream->video_ssrc;
handle->audio_stream->video_ssrc_peer = handle->video_stream->video_ssrc_peer;
handle->audio_stream->video_ssrc_peer_rtx = handle->video_stream->video_ssrc_peer_rtx;
nice_agent_remove_stream(handle->agent, handle->video_stream->stream_id);
janus_ice_stream_free(handle->streams, handle->video_stream);
}
handle->video_stream = NULL;
if(handle->video_id > 0) {
nice_agent_attach_recv (handle->agent, handle->video_id, 1, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv (handle->agent, handle->video_id, 2, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv(handle->agent, handle->video_id, 1, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv(handle->agent, handle->video_id, 2, g_main_loop_get_context (handle->iceloop), NULL, NULL);
}
handle->video_id = 0;
if(handle->streams && handle->data_stream) {
nice_agent_remove_stream(handle->agent, handle->data_stream->stream_id);
janus_ice_stream_free(handle->streams, handle->data_stream);
}
handle->data_stream = NULL;
if(handle->data_id > 0) {
nice_agent_attach_recv (handle->agent, handle->data_id, 1, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv(handle->agent, handle->data_id, 1, g_main_loop_get_context (handle->iceloop), NULL, NULL);
}
handle->data_id = 0;
} else if(video) {
/* Get rid of data, if present */
if(handle->streams && handle->data_stream) {
nice_agent_remove_stream(handle->agent, handle->data_stream->stream_id);
janus_ice_stream_free(handle->streams, handle->data_stream);
}
handle->data_stream = NULL;
if(handle->data_id > 0) {
nice_agent_attach_recv (handle->agent, handle->data_id, 1, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv(handle->agent, handle->data_id, 1, g_main_loop_get_context (handle->iceloop), NULL, NULL);
}
handle->data_id = 0;
}
}
if(janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RTCPMUX)) {
JANUS_LOG(LOG_HUGE, "[%"SCNu64"] -- rtcp-mux is supported by the browser, getting rid of RTCP components, if any...\n", handle->handle_id);
if(handle->audio_stream && handle->audio_stream->components != NULL) {
nice_agent_attach_recv (handle->agent, handle->audio_id, 2, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv(handle->agent, handle->audio_id, 2, g_main_loop_get_context (handle->iceloop), NULL, NULL);
janus_ice_component_free(handle->audio_stream->components, handle->audio_stream->rtcp_component);
handle->audio_stream->rtcp_component = NULL;
}
if(handle->video_stream && handle->video_stream->components != NULL) {
nice_agent_attach_recv (handle->agent, handle->video_id, 2, g_main_loop_get_context (handle->iceloop), NULL, NULL);
nice_agent_attach_recv(handle->agent, handle->video_id, 2, g_main_loop_get_context (handle->iceloop), NULL, NULL);
janus_ice_component_free(handle->video_stream->components, handle->video_stream->rtcp_component);
handle->video_stream->rtcp_component = NULL;
}
Expand Down Expand Up @@ -1602,7 +1605,7 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
}
} else if(json_is_array(candidate)) {
/* We got multiple candidates in an array */
JANUS_LOG(LOG_INFO, "Got multiple candidates (%zu)\n", json_array_size(candidate));
JANUS_LOG(LOG_VERB, "Got multiple candidates (%zu)\n", json_array_size(candidate));
if(json_array_size(candidate) > 0) {
/* Handle remote candidates */
size_t i = 0;
Expand All @@ -1621,10 +1624,10 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
if(!offer) {
if(janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_TRICKLE) &&
!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_ALL_TRICKLES)) {
JANUS_LOG(LOG_INFO, "[%"SCNu64"] -- ICE Trickling is supported by the browser, waiting for remote candidates...\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] -- ICE Trickling is supported by the browser, waiting for remote candidates...\n", handle->handle_id);
janus_flags_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_START);
} else {
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Done! Sending connectivity checks...\n", handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Done! Sending connectivity checks...\n", handle->handle_id);
if(handle->audio_id > 0) {
janus_ice_setup_remote_candidates(handle, handle->audio_id, 1);
if(!janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RTCPMUX)) /* http://tools.ietf.org/html/rfc5761#section-5.1.3 */
Expand Down Expand Up @@ -1798,7 +1801,7 @@ int janus_process_incoming_request(janus_request_source *source, json_t *root) {
janus_mutex_unlock(&handle->mutex);
goto jsondone;
}
JANUS_LOG(LOG_INFO, "Got multiple candidates (%zu)\n", json_array_size(candidates));
JANUS_LOG(LOG_VERB, "Got multiple candidates (%zu)\n", json_array_size(candidates));
if(json_array_size(candidates) > 0) {
/* Handle remote candidates */
size_t i = 0;
Expand Down Expand Up @@ -4068,7 +4071,7 @@ json_t *janus_handle_sdp(janus_plugin_session *plugin_session, janus_plugin *plu
#endif
/* Are we still cleaning up from a previous media session? */
if(janus_flags_is_set(&ice_handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING)) {
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Still cleaning up from a previous media session, let's wait a bit...\n", ice_handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Still cleaning up from a previous media session, let's wait a bit...\n", ice_handle->handle_id);
gint64 waited = 0;
while(janus_flags_is_set(&ice_handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_CLEANING)) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Still cleaning up from a previous media session, let's wait a bit...\n", ice_handle->handle_id);
Expand Down Expand Up @@ -4171,7 +4174,7 @@ json_t *janus_handle_sdp(janus_plugin_session *plugin_session, janus_plugin *plu
/* We set the flag to wait for an answer before handling trickle candidates */
janus_flags_set(&ice_handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_PROCESSING_OFFER);
} else {
JANUS_LOG(LOG_INFO, "[%"SCNu64"] Done! Ready to setup remote candidates and send connectivity checks...\n", ice_handle->handle_id);
JANUS_LOG(LOG_VERB, "[%"SCNu64"] Done! Ready to setup remote candidates and send connectivity checks...\n", ice_handle->handle_id);
if(janus_flags_is_set(&ice_handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_BUNDLE) && audio && video) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] -- bundle is supported by the browser, getting rid of one of the RTP/RTCP components, if any...\n", ice_handle->handle_id);
if(audio) {
Expand All @@ -4180,43 +4183,46 @@ json_t *janus_handle_sdp(janus_plugin_session *plugin_session, janus_plugin *plu
ice_handle->audio_stream->video_ssrc = ice_handle->video_stream->video_ssrc;
ice_handle->audio_stream->video_ssrc_peer = ice_handle->video_stream->video_ssrc_peer;
ice_handle->audio_stream->video_ssrc_peer_rtx = ice_handle->video_stream->video_ssrc_peer_rtx;
nice_agent_remove_stream(ice_handle->agent, ice_handle->video_stream->stream_id);
janus_ice_stream_free(ice_handle->streams, ice_handle->video_stream);
}
ice_handle->video_stream = NULL;
if(ice_handle->video_id > 0) {
nice_agent_attach_recv (ice_handle->agent, ice_handle->video_id, 1, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv (ice_handle->agent, ice_handle->video_id, 2, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv(ice_handle->agent, ice_handle->video_id, 1, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv(ice_handle->agent, ice_handle->video_id, 2, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
}
ice_handle->video_id = 0;
if(ice_handle->streams && ice_handle->data_stream) {
nice_agent_remove_stream(ice_handle->agent, ice_handle->data_stream->stream_id);
janus_ice_stream_free(ice_handle->streams, ice_handle->data_stream);
}
ice_handle->data_stream = NULL;
if(ice_handle->data_id > 0) {
nice_agent_attach_recv (ice_handle->agent, ice_handle->data_id, 1, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv(ice_handle->agent, ice_handle->data_id, 1, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
}
ice_handle->data_id = 0;
} else if(video) {
/* Get rid of data, if present */
if(ice_handle->streams && ice_handle->data_stream) {
nice_agent_remove_stream(ice_handle->agent, ice_handle->data_stream->stream_id);
janus_ice_stream_free(ice_handle->streams, ice_handle->data_stream);
}
ice_handle->data_stream = NULL;
if(ice_handle->data_id > 0) {
nice_agent_attach_recv (ice_handle->agent, ice_handle->data_id, 1, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv(ice_handle->agent, ice_handle->data_id, 1, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
}
ice_handle->data_id = 0;
}
}
if(janus_flags_is_set(&ice_handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_RTCPMUX)) {
JANUS_LOG(LOG_VERB, "[%"SCNu64"] -- rtcp-mux is supported by the browser, getting rid of RTCP components, if any...\n", ice_handle->handle_id);
if(ice_handle->audio_stream && ice_handle->audio_stream->rtcp_component && ice_handle->audio_stream->components != NULL) {
nice_agent_attach_recv (ice_handle->agent, ice_handle->audio_id, 2, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv(ice_handle->agent, ice_handle->audio_id, 2, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
janus_ice_component_free(ice_handle->audio_stream->components, ice_handle->audio_stream->rtcp_component);
ice_handle->audio_stream->rtcp_component = NULL;
}
if(ice_handle->video_stream && ice_handle->video_stream->rtcp_component && ice_handle->video_stream->components != NULL) {
nice_agent_attach_recv (ice_handle->agent, ice_handle->video_id, 2, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
nice_agent_attach_recv(ice_handle->agent, ice_handle->video_id, 2, g_main_loop_get_context (ice_handle->iceloop), NULL, NULL);
janus_ice_component_free(ice_handle->video_stream->components, ice_handle->video_stream->rtcp_component);
ice_handle->video_stream->rtcp_component = NULL;
}
Expand Down

0 comments on commit 202d13d

Please sign in to comment.