Revision 1d31e31f ice.c

View differences:

ice.c
450 450
	JANUS_LOG(LOG_VERB, "[%"SCNu64"] Sending event to transport...\n", handle->handle_id);
451 451
	janus_session_notify_event(session->session_id, event);
452 452
	/* Notify event handlers as well */
453
	json_t *info = json_object();
454
	json_object_set_new(info, "media", json_string(video ? "video" : "audio"));
455
	json_object_set_new(info, "receiving", json_string(up ? "true" : "false"));
456
	janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, session->session_id, handle->handle_id, info);
453
	if(janus_events_is_enabled()) {
454
		json_t *info = json_object();
455
		json_object_set_new(info, "media", json_string(video ? "video" : "audio"));
456
		json_object_set_new(info, "receiving", json_string(up ? "true" : "false"));
457
		janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, session->session_id, handle->handle_id, info);
458
	}
457 459
}
458 460

  
459 461
void janus_ice_notify_hangup(janus_ice_handle *handle, const char *reason) {
......
474 476
	JANUS_LOG(LOG_VERB, "[%"SCNu64"] Sending event to transport...\n", handle->handle_id);
475 477
	janus_session_notify_event(session->session_id, event);
476 478
	/* Notify event handlers as well */
477
	json_t *info = json_object();
478
	json_object_set_new(info, "connection", json_string("hangup"));
479
	janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
479
	if(janus_events_is_enabled()) {
480
		json_t *info = json_object();
481
		json_object_set_new(info, "connection", json_string("hangup"));
482
		janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
483
	}
480 484
}
481 485

  
482 486

  
......
965 969
	janus_mutex_unlock(&old_plugin_sessions_mutex);
966 970
	janus_mutex_unlock(&session->mutex);
967 971
	/* Notify event handlers */
968
	janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE, session->session_id, handle_id, "attached");
972
	if(janus_events_is_enabled())
973
		janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE, session->session_id, handle_id, "attached");
969 974
	return 0;
970 975
}
971 976

  
......
1019 1024
	g_hash_table_insert(old_handles, GUINT_TO_POINTER(handle_id), handle);
1020 1025
	janus_mutex_unlock(&old_handles_mutex);
1021 1026
	/* Notify event handlers as well */
1022
	janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE, session->session_id, handle_id, "detached");
1027
	if(janus_events_is_enabled())
1028
		janus_events_notify_handlers(JANUS_EVENT_TYPE_HANDLE, session->session_id, handle_id, "detached");
1023 1029
	return error;
1024 1030
}
1025 1031

  
......
1338 1344
	}
1339 1345
	component->state = state;
1340 1346
	/* Notify event handlers */
1341
	janus_session *session = (janus_session *)handle->session;
1342
	json_t *info = json_object();
1343
	json_object_set_new(info, "ice", json_string(janus_get_ice_state_name(state)));
1344
	json_object_set_new(info, "stream_id", json_integer(stream_id));
1345
	json_object_set_new(info, "component_id", json_integer(component_id));
1346
	janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
1347
	if(janus_events_is_enabled()) {
1348
		janus_session *session = (janus_session *)handle->session;
1349
		json_t *info = json_object();
1350
		json_object_set_new(info, "ice", json_string(janus_get_ice_state_name(state)));
1351
		json_object_set_new(info, "stream_id", json_integer(stream_id));
1352
		json_object_set_new(info, "component_id", json_integer(component_id));
1353
		janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
1354
	}
1347 1355
	/* Handle new state */
1348 1356
	if((state == NICE_COMPONENT_STATE_CONNECTED || state == NICE_COMPONENT_STATE_READY)
1349 1357
			&& handle->send_thread == NULL) {
......
1469 1477
#endif
1470 1478
	component->selected_pair = g_strdup(sp);
1471 1479
	/* Notify event handlers */
1472
	janus_session *session = (janus_session *)handle->session;
1473
	json_t *info = json_object();
1474
	json_object_set_new(info, "selected-pair", json_string(sp));
1475
	json_object_set_new(info, "stream_id", json_integer(stream_id));
1476
	json_object_set_new(info, "component_id", json_integer(component_id));
1477
	janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
1480
	if(janus_events_is_enabled()) {
1481
		janus_session *session = (janus_session *)handle->session;
1482
		json_t *info = json_object();
1483
		json_object_set_new(info, "selected-pair", json_string(sp));
1484
		json_object_set_new(info, "stream_id", json_integer(stream_id));
1485
		json_object_set_new(info, "component_id", json_integer(component_id));
1486
		janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
1487
	}
1478 1488
	/* Now we can start the DTLS handshake (FIXME This was on the 'connected' state notification, before) */
1479 1489
	JANUS_LOG(LOG_VERB, "[%"SCNu64"]   Component is ready enough, starting DTLS handshake...\n", handle->handle_id);
1480 1490
	/* Have we been here before? (might happen, when trickling) */
......
3606 3616
	JANUS_LOG(LOG_VERB, "[%"SCNu64"] Sending event to transport...\n", handle->handle_id);
3607 3617
	janus_session_notify_event(session->session_id, event);
3608 3618
	/* Notify event handlers as well */
3609
	json_t *info = json_object();
3610
	json_object_set_new(info, "connection", json_string("webrtcup"));
3611
	janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
3619
	if(janus_events_is_enabled()) {
3620
		json_t *info = json_object();
3621
		json_object_set_new(info, "connection", json_string("webrtcup"));
3622
		janus_events_notify_handlers(JANUS_EVENT_TYPE_WEBRTC, session->session_id, handle->handle_id, info);
3623
	}
3612 3624
}

Also available in: Unified diff