Revision 71a04f89

View differences:

conf/janus.plugin.audiobridge.cfg.sample
10 10
[general]
11 11
;admin_key = supersecret		; If set, rooms can be created via API only
12 12
								; if this key is provided in the request
13
;events = no					; Whether events should be sent to event
14
								; handlers (default is yes)
13 15

  
14 16
[1234]
15 17
description = Demo Room
conf/janus.plugin.echotest.cfg.sample
1
; The Echo Test plugin doesn't need any configuration
1
; events = yes|no, whether events should be sent to event handlers
2

  
3
[general]
4
;events = no
conf/janus.plugin.recordplay.cfg.sample.in
1 1
; path = where to place recordings in the file system
2
; events = yes|no, whether events should be sent to event handlers
2 3

  
3 4
[general]
4 5
path = @recordingsdir@
6
;events = no
conf/janus.plugin.sip.cfg.sample
1 1
[general]
2 2
; Specify which local IP address to use. If not set it will be automatically
3 3
; guessed from the system
4
; local_ip = 1.2.3.4
4
;local_ip = 1.2.3.4
5 5

  
6 6
; Enable local keep-alives to keep the registration open. Keep-alives are
7 7
; sent in the form of OPTIONS requests, at the given interval inseconds.
......
17 17
; user_agent = Cool WebRTC Gateway
18 18
; Expiration time for registrations
19 19
register_ttl = 3600
20

  
21
; Whether events should be sent to event handlers (default is yes)
22
;events = no
conf/janus.plugin.streaming.cfg.sample.in
40 40
[general]
41 41
;admin_key = supersecret		; If set, mountpoints can be created via API
42 42
								; only if this key is provided in the request
43
;events = no					; Whether events should be sent to event
44
								; handlers (default is yes)
43 45

  
44 46
[gstreamer-sample]
45 47
type = rtp
conf/janus.plugin.textroom.cfg.sample
8 8
[general]
9 9
;admin_key = supersecret		; If set, rooms can be created via API only
10 10
								; if this key is provided in the request
11
;events = no					; Whether events should be sent to event
12
								; handlers (default is yes)
11 13

  
12 14
[1234]
13 15
description = Demo Room
conf/janus.plugin.videocall.cfg.sample
1
; The Video Call plugin doesn't need any configuration
1
; events = yes|no, whether events should be sent to event handlers
2

  
3
[general]
4
;events = no
conf/janus.plugin.videoroom.cfg.sample
15 15
[general]
16 16
;admin_key = supersecret		; If set, rooms can be created via API only
17 17
								; if this key is provided in the request
18
;events = no					; Whether events should be sent to event
19
								; handlers (default is yes)
18 20

  
19 21
[1234]
20 22
description = Demo Room
conf/janus.plugin.voicemail.cfg.sample
2 2
;	properly configured web server, if you want the demo to work)
3 3
; base = base path to use when returning the recording URI (use this
4 4
;	to make sure the file in the path you chose is reachable via HTTP)
5
; events = yes|no, whether events should be sent to event handlers
5 6

  
6 7
[general]
7 8
path = /tmp/voicemail/
8 9
base = /voicemail/
10
events = yes
plugins/janus_audiobridge.c
500 500

  
501 501
/* Useful stuff */
502 502
static volatile gint initialized = 0, stopping = 0;
503
static gboolean notify_events = TRUE;
503 504
static janus_callbacks *gateway = NULL;
504 505
static GThread *handler_thread;
505 506
static GThread *watchdog;
......
795 796
		janus_config_item *key = janus_config_get_item_drilldown(config, "general", "admin_key");
796 797
		if(key != NULL && key->value != NULL)
797 798
			admin_key = g_strdup(key->value);
799
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
800
		if(events != NULL && events->value != NULL)
801
			notify_events = janus_is_true(events->value);
802
		if(!notify_events && callback->events_is_enabled()) {
803
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_AUDIOBRIDGE_NAME);
804
		}
798 805
		/* Iterate on all rooms */
799 806
		GList *cl = janus_config_get_categories(config);
800 807
		while(cl != NULL) {
......
1307 1314
		json_object_set_new(response, "audiobridge", json_string("created"));
1308 1315
		json_object_set_new(response, "room", json_integer(audiobridge->room_id));
1309 1316
		/* Also notify event handlers */
1310
		if(gateway->events_is_enabled()) {
1317
		if(notify_events && gateway->events_is_enabled()) {
1311 1318
			json_t *info = json_object();
1312 1319
			json_object_set_new(info, "event", json_string("created"));
1313 1320
			json_object_set_new(info, "room", json_integer(audiobridge->room_id));
......
1402 1409
		}
1403 1410
		g_free(response_text);
1404 1411
		/* Also notify event handlers */
1405
		if(gateway->events_is_enabled()) {
1412
		if(notify_events && gateway->events_is_enabled()) {
1406 1413
			json_t *info = json_object();
1407 1414
			json_object_set_new(info, "event", json_string("destroyed"));
1408 1415
			json_object_set_new(info, "room", json_integer(room_id));
......
1755 1762
		}
1756 1763
		g_free(leaving_text);
1757 1764
		/* Also notify event handlers */
1758
		if(gateway->events_is_enabled()) {
1765
		if(notify_events && gateway->events_is_enabled()) {
1759 1766
			json_t *info = json_object();
1760 1767
			json_object_set_new(info, "event", json_string("left"));
1761 1768
			json_object_set_new(info, "room", json_integer(audiobridge->room_id));
......
2100 2107
			json_object_set_new(event, "id", json_integer(user_id));
2101 2108
			json_object_set_new(event, "participants", list);
2102 2109
			/* Also notify event handlers */
2103
			if(gateway->events_is_enabled()) {
2110
			if(notify_events && gateway->events_is_enabled()) {
2104 2111
				json_t *info = json_object();
2105 2112
				json_object_set_new(info, "event", json_string("joined"));
2106 2113
				json_object_set_new(info, "room", json_integer(room_id));
......
2245 2252
			json_object_set_new(event, "audiobridge", json_string("event"));
2246 2253
			json_object_set_new(event, "result", json_string("ok"));
2247 2254
			/* Also notify event handlers */
2248
			if(gateway->events_is_enabled()) {
2255
			if(notify_events && gateway->events_is_enabled()) {
2249 2256
				janus_audiobridge_room *audiobridge = participant->room;
2250 2257
				json_t *info = json_object();
2251 2258
				json_object_set_new(info, "event", json_string("configured"));
......
2426 2433
			}
2427 2434
			g_free(leaving_text);
2428 2435
			/* Also notify event handlers */
2429
			if(gateway->events_is_enabled()) {
2436
			if(notify_events && gateway->events_is_enabled()) {
2430 2437
				json_t *info = json_object();
2431 2438
				json_object_set_new(info, "event", json_string("left"));
2432 2439
				json_object_set_new(info, "room", json_integer(old_audiobridge->room_id));
......
2503 2510
			json_object_set_new(event, "id", json_integer(user_id));
2504 2511
			json_object_set_new(event, "participants", list);
2505 2512
			/* Also notify event handlers */
2506
			if(gateway->events_is_enabled()) {
2513
			if(notify_events && gateway->events_is_enabled()) {
2507 2514
				json_t *info = json_object();
2508 2515
				json_object_set_new(info, "event", json_string("joined"));
2509 2516
				json_object_set_new(info, "room", json_integer(audiobridge->room_id));
......
2578 2585
			participant->arc = NULL;
2579 2586
			janus_mutex_unlock(&participant->rec_mutex);
2580 2587
			/* Also notify event handlers */
2581
			if(gateway->events_is_enabled()) {
2588
			if(notify_events && gateway->events_is_enabled()) {
2582 2589
				json_t *info = json_object();
2583 2590
				json_object_set_new(info, "event", json_string("left"));
2584 2591
				json_object_set_new(info, "room", json_integer(audiobridge->room_id));
plugins/janus_echotest.c
161 161

  
162 162
/* Useful stuff */
163 163
static volatile gint initialized = 0, stopping = 0;
164
static gboolean notify_events = TRUE;
164 165
static janus_callbacks *gateway = NULL;
165 166
static GThread *handler_thread;
166 167
static GThread *watchdog;
......
277 278
	g_snprintf(filename, 255, "%s/%s.cfg", config_path, JANUS_ECHOTEST_PACKAGE);
278 279
	JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename);
279 280
	janus_config *config = janus_config_parse(filename);
280
	if(config != NULL)
281
	if(config != NULL) {
281 282
		janus_config_print(config);
282
	/* This plugin actually has nothing to configure... */
283
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
284
		if(events != NULL && events->value != NULL)
285
			notify_events = janus_is_true(events->value);
286
		if(!notify_events && callback->events_is_enabled()) {
287
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_ECHOTEST_NAME);
288
		}
289
	}
283 290
	janus_config_destroy(config);
284 291
	config = NULL;
285 292
	
......
956 963
		g_free(event_text);
957 964
		janus_echotest_message_free(msg);
958 965

  
959
		if(gateway->events_is_enabled()) {
966
		if(notify_events && gateway->events_is_enabled()) {
960 967
			/* Just to showcase how you can notify handlers, let's update them on our configuration */
961 968
			json_t *info = json_object();
962 969
			json_object_set_new(info, "audio_active", session->audio_active ? json_true() : json_false());
plugins/janus_recordplay.c
341 341

  
342 342
/* Useful stuff */
343 343
static volatile gint initialized = 0, stopping = 0;
344
static gboolean notify_events = TRUE;
344 345
static janus_callbacks *gateway = NULL;
345 346
static GThread *handler_thread;
346 347
static GThread *watchdog;
......
538 539
		janus_config_item *path = janus_config_get_item_drilldown(config, "general", "path");
539 540
		if(path && path->value)
540 541
			recordings_path = g_strdup(path->value);
542
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
543
		if(events != NULL && events->value != NULL)
544
			notify_events = janus_is_true(events->value);
545
		if(!notify_events && callback->events_is_enabled()) {
546
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_RECORDPLAY_NAME);
547
		}
541 548
		/* Done */
542 549
		janus_config_destroy(config);
543 550
		config = NULL;
......
1226 1233
			json_object_set_new(result, "status", json_string("recording"));
1227 1234
			json_object_set_new(result, "id", json_integer(id));
1228 1235
			/* Also notify event handlers */
1229
			if(gateway->events_is_enabled()) {
1236
			if(notify_events && gateway->events_is_enabled()) {
1230 1237
				json_t *info = json_object();
1231 1238
				json_object_set_new(info, "event", json_string("recording"));
1232 1239
				json_object_set_new(info, "id", json_integer(id));
......
1316 1323
			json_object_set_new(result, "status", json_string("preparing"));
1317 1324
			json_object_set_new(result, "id", json_integer(id_value));
1318 1325
			/* Also notify event handlers */
1319
			if(gateway->events_is_enabled()) {
1326
			if(notify_events && gateway->events_is_enabled()) {
1320 1327
				json_t *info = json_object();
1321 1328
				json_object_set_new(info, "event", json_string("playout"));
1322 1329
				json_object_set_new(info, "id", json_integer(id_value));
......
1342 1349
			result = json_object();
1343 1350
			json_object_set_new(result, "status", json_string("playing"));
1344 1351
			/* Also notify event handlers */
1345
			if(gateway->events_is_enabled()) {
1352
			if(notify_events && gateway->events_is_enabled()) {
1346 1353
				json_t *info = json_object();
1347 1354
				json_object_set_new(info, "event", json_string("playing"));
1348 1355
				json_object_set_new(info, "id", json_integer(session->recording->id));
......
1411 1418
			if(session->recording)
1412 1419
				json_object_set_new(result, "id", json_integer(session->recording->id));
1413 1420
			/* Also notify event handlers */
1414
			if(gateway->events_is_enabled()) {
1421
			if(notify_events && gateway->events_is_enabled()) {
1415 1422
				json_t *info = json_object();
1416 1423
				json_object_set_new(info, "event", json_string("stopped"));
1417 1424
				if(session->recording)
plugins/janus_sip.c
174 174

  
175 175
/* Useful stuff */
176 176
static volatile gint initialized = 0, stopping = 0;
177
static gboolean notify_events = TRUE;
177 178
static janus_callbacks *gateway = NULL;
178 179

  
179 180
static char local_ip[INET6_ADDRSTRLEN];
......
812 813
	g_snprintf(filename, 255, "%s/%s.cfg", config_path, JANUS_SIP_PACKAGE);
813 814
	JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename);
814 815
	janus_config *config = janus_config_parse(filename);
815
	if(config != NULL)
816
	if(config != NULL) {
816 817
		janus_config_print(config);
817 818

  
818
	gboolean local_ip_set = FALSE;
819
	janus_config_item *item = janus_config_get_item_drilldown(config, "general", "local_ip");
820
	if(item && item->value) {
821
		int family;
822
		if (!janus_is_ip_valid(item->value, &family)) {
823
			JANUS_LOG(LOG_WARN, "Invalid local IP specified: %s, guessing the default...\n", item->value);
824
		} else {
825
			/* Verify that we can actually bind to that address */
826
			int fd = socket(family, SOCK_DGRAM, 0);
827
			if (fd == -1) {
828
				JANUS_LOG(LOG_WARN, "Error creating test socket, falling back to detecting IP address...\n");
819
		gboolean local_ip_set = FALSE;
820
		janus_config_item *item = janus_config_get_item_drilldown(config, "general", "local_ip");
821
		if(item && item->value) {
822
			int family;
823
			if (!janus_is_ip_valid(item->value, &family)) {
824
				JANUS_LOG(LOG_WARN, "Invalid local IP specified: %s, guessing the default...\n", item->value);
829 825
			} else {
830
				int r;
831
				struct sockaddr_storage ss;
832
				socklen_t addrlen;
833
				memset(&ss, 0, sizeof(ss));
834
				if (family == AF_INET) {
835
					struct sockaddr_in *addr4 = (struct sockaddr_in*)&ss;
836
					addr4->sin_family = AF_INET;
837
					addr4->sin_port = 0;
838
					inet_pton(AF_INET, item->value, &(addr4->sin_addr.s_addr));
839
					addrlen = sizeof(struct sockaddr_in);
840
				} else {
841
					struct sockaddr_in6 *addr6 = (struct sockaddr_in6*)&ss;
842
					addr6->sin6_family = AF_INET6;
843
					addr6->sin6_port = 0;
844
					inet_pton(AF_INET6, item->value, &(addr6->sin6_addr.s6_addr));
845
					addrlen = sizeof(struct sockaddr_in6);
846
				}
847
				r = bind(fd, (const struct sockaddr*)&ss, addrlen);
848
				close(fd);
849
				if (r < 0) {
850
					JANUS_LOG(LOG_WARN, "Error setting local IP address to %s, falling back to detecting IP address...\n", item->value);
826
				/* Verify that we can actually bind to that address */
827
				int fd = socket(family, SOCK_DGRAM, 0);
828
				if (fd == -1) {
829
					JANUS_LOG(LOG_WARN, "Error creating test socket, falling back to detecting IP address...\n");
851 830
				} else {
852
					g_strlcpy(local_ip, item->value, sizeof(local_ip));
853
					local_ip_set = TRUE;
831
					int r;
832
					struct sockaddr_storage ss;
833
					socklen_t addrlen;
834
					memset(&ss, 0, sizeof(ss));
835
					if (family == AF_INET) {
836
						struct sockaddr_in *addr4 = (struct sockaddr_in*)&ss;
837
						addr4->sin_family = AF_INET;
838
						addr4->sin_port = 0;
839
						inet_pton(AF_INET, item->value, &(addr4->sin_addr.s_addr));
840
						addrlen = sizeof(struct sockaddr_in);
841
					} else {
842
						struct sockaddr_in6 *addr6 = (struct sockaddr_in6*)&ss;
843
						addr6->sin6_family = AF_INET6;
844
						addr6->sin6_port = 0;
845
						inet_pton(AF_INET6, item->value, &(addr6->sin6_addr.s6_addr));
846
						addrlen = sizeof(struct sockaddr_in6);
847
					}
848
					r = bind(fd, (const struct sockaddr*)&ss, addrlen);
849
					close(fd);
850
					if (r < 0) {
851
						JANUS_LOG(LOG_WARN, "Error setting local IP address to %s, falling back to detecting IP address...\n", item->value);
852
					} else {
853
						g_strlcpy(local_ip, item->value, sizeof(local_ip));
854
						local_ip_set = TRUE;
855
					}
854 856
				}
855 857
			}
856 858
		}
859
		if (!local_ip_set)
860
			janus_sip_detect_local_ip(local_ip, sizeof(local_ip));
861
		JANUS_LOG(LOG_VERB, "Local IP set to %s\n", local_ip);
862

  
863
		item = janus_config_get_item_drilldown(config, "general", "keepalive_interval");
864
		if(item && item->value)
865
			keepalive_interval = atoi(item->value);
866
		JANUS_LOG(LOG_VERB, "SIP keep-alive interval set to %d seconds\n", keepalive_interval);
867

  
868
		item = janus_config_get_item_drilldown(config, "general", "register_ttl");
869
		if(item && item->value)
870
			register_ttl = atoi(item->value);
871
		JANUS_LOG(LOG_VERB, "SIP registration TTL set to %d seconds\n", register_ttl);
872

  
873
		item = janus_config_get_item_drilldown(config, "general", "behind_nat");
874
		if(item && item->value)
875
			behind_nat = janus_is_true(item->value);
876

  
877
		item = janus_config_get_item_drilldown(config, "general", "user_agent");
878
		if(item && item->value)
879
			user_agent = g_strdup(item->value);
880
		else
881
			user_agent = g_strdup("Janus WebRTC Gateway SIP Plugin "JANUS_SIP_VERSION_STRING);
882
		JANUS_LOG(LOG_VERB, "SIP User-Agent set to %s\n", user_agent);
883

  
884
		item = janus_config_get_item_drilldown(config, "general", "events");
885
		if(item != NULL && item->value != NULL)
886
			notify_events = janus_is_true(item->value);
887
		if(!notify_events && callback->events_is_enabled()) {
888
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_SIP_NAME);
889
		}
890

  
891
		janus_config_destroy(config);
857 892
	}
858
	if (!local_ip_set)
859
		janus_sip_detect_local_ip(local_ip, sizeof(local_ip));
860
	JANUS_LOG(LOG_VERB, "Local IP set to %s\n", local_ip);
861

  
862
	item = janus_config_get_item_drilldown(config, "general", "keepalive_interval");
863
	if(item && item->value)
864
		keepalive_interval = atoi(item->value);
865
	JANUS_LOG(LOG_VERB, "SIP keep-alive interval set to %d seconds\n", keepalive_interval);
866

  
867
	item = janus_config_get_item_drilldown(config, "general", "register_ttl");
868
	if(item && item->value)
869
		register_ttl = atoi(item->value);
870
	JANUS_LOG(LOG_VERB, "SIP registration TTL set to %d seconds\n", register_ttl);
871

  
872
	item = janus_config_get_item_drilldown(config, "general", "behind_nat");
873
	if(item && item->value)
874
		behind_nat = janus_is_true(item->value);
875

  
876
	item = janus_config_get_item_drilldown(config, "general", "user_agent");
877
	if(item && item->value)
878
		user_agent = g_strdup(item->value);
879
	else
880
		user_agent = g_strdup("Janus WebRTC Gateway SIP Plugin "JANUS_SIP_VERSION_STRING);
881
	JANUS_LOG(LOG_VERB, "SIP User-Agent set to %s\n", user_agent);
882

  
883
	/* This plugin actually has nothing to configure... */
884
	janus_config_destroy(config);
885 893
	config = NULL;
886 894

  
887 895
	/* Setup sofia */
......
1671 1679
				json_object_set_new(result, "username", json_string(session->account.username));
1672 1680
				json_object_set_new(result, "register_sent", json_string("false"));
1673 1681
				/* Also notify event handlers */
1674
				if(gateway->events_is_enabled()) {
1682
				if(notify_events && gateway->events_is_enabled()) {
1675 1683
					json_t *info = json_object();
1676 1684
					json_object_set_new(info, "event", json_string("registered"));
1677 1685
					json_object_set_new(info, "identity", json_string(session->account.identity));
......
1832 1840
			char callid[24];
1833 1841
			janus_sip_random_string(24, (char *)&callid);
1834 1842
			/* Also notify event handlers */
1835
			if(gateway->events_is_enabled()) {
1843
			if(notify_events && gateway->events_is_enabled()) {
1836 1844
				json_t *info = json_object();
1837 1845
				json_object_set_new(info, "event", json_string("calling"));
1838 1846
				json_object_set_new(info, "callee", json_string(uri_text));
......
1964 1972
			}
1965 1973
			JANUS_LOG(LOG_VERB, "Prepared SDP for 200 OK:\n%s", sdp);
1966 1974
			/* Also notify event handlers */
1967
			if(gateway->events_is_enabled()) {
1975
			if(notify_events && gateway->events_is_enabled()) {
1968 1976
				json_t *info = json_object();
1969 1977
				json_object_set_new(info, "event", json_string("accepted"));
1970 1978
				if(session->callid)
......
2025 2033
			}
2026 2034
			nua_respond(session->stack->s_nh_i, response_code, sip_status_phrase(response_code), TAG_END());
2027 2035
			/* Also notify event handlers */
2028
			if(gateway->events_is_enabled()) {
2036
			if(notify_events && gateway->events_is_enabled()) {
2029 2037
				json_t *info = json_object();
2030 2038
				json_object_set_new(info, "event", json_string("declined"));
2031 2039
				json_object_set_new(info, "callee", json_string(session->callee));
......
2420 2428
				JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2421 2429
				g_free(call_text);
2422 2430
				/* Also notify event handlers */
2423
				if(gateway->events_is_enabled()) {
2431
				if(notify_events && gateway->events_is_enabled()) {
2424 2432
					json_t *info = json_object();
2425 2433
					json_object_set_new(info, "event", json_string("proceeding"));
2426 2434
					if(session->callid)
......
2446 2454
				JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2447 2455
				g_free(call_text);
2448 2456
				/* Also notify event handlers */
2449
				if(gateway->events_is_enabled()) {
2457
				if(notify_events && gateway->events_is_enabled()) {
2450 2458
					json_t *info = json_object();
2451 2459
					json_object_set_new(info, "event", json_string("hangup"));
2452 2460
					if(session->callid)
......
2525 2533
					JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2526 2534
					g_free(missed_text);
2527 2535
					/* Also notify event handlers */
2528
					if(gateway->events_is_enabled()) {
2536
					if(notify_events && gateway->events_is_enabled()) {
2529 2537
						json_t *info = json_object();
2530 2538
						json_object_set_new(info, "event", json_string("missed_call"));
2531 2539
						json_object_set_new(info, "caller", json_string(caller_text));
......
2569 2577
			JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2570 2578
			g_free(call_text);
2571 2579
			/* Also notify event handlers */
2572
			if(gateway->events_is_enabled()) {
2580
			if(notify_events && gateway->events_is_enabled()) {
2573 2581
				json_t *info = json_object();
2574 2582
				json_object_set_new(info, "event", json_string("incomingcall"));
2575 2583
				if(session->callid)
......
2729 2737
			JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2730 2738
			g_free(call_text);
2731 2739
			/* Also notify event handlers */
2732
			if(gateway->events_is_enabled()) {
2740
			if(notify_events && gateway->events_is_enabled()) {
2733 2741
				json_t *info = json_object();
2734 2742
				json_object_set_new(info, "event", json_string("accepted"));
2735 2743
				if(session->callid)
......
2762 2770
				JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2763 2771
				g_free(call_text);
2764 2772
				/* Also notify event handlers */
2765
				if(gateway->events_is_enabled()) {
2773
				if(notify_events && gateway->events_is_enabled()) {
2766 2774
					json_t *info = json_object();
2767 2775
					json_object_set_new(info, "event", json_string("registered"));
2768 2776
					json_object_set_new(info, "identity", json_string(session->account.identity));
......
2807 2815
				JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
2808 2816
				g_free(event_text);
2809 2817
				/* Also notify event handlers */
2810
				if(gateway->events_is_enabled()) {
2818
				if(notify_events && gateway->events_is_enabled()) {
2811 2819
					json_t *info = json_object();
2812 2820
					json_object_set_new(info, "event", json_string("registration_failed"));
2813 2821
					json_object_set_new(info, "code", json_integer(status));
plugins/janus_streaming.c
288 288

  
289 289
/* Useful stuff */
290 290
static volatile gint initialized = 0, stopping = 0;
291
static gboolean notify_events = TRUE;
291 292
static janus_callbacks *gateway = NULL;
292 293
static GThread *handler_thread;
293 294
static GThread *watchdog;
......
568 569
		janus_config_item *key = janus_config_get_item_drilldown(config, "general", "admin_key");
569 570
		if(key != NULL && key->value != NULL)
570 571
			admin_key = g_strdup(key->value);
572
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
573
		if(events != NULL && events->value != NULL)
574
			notify_events = janus_is_true(events->value);
575
		if(!notify_events && callback->events_is_enabled()) {
576
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_STREAMING_NAME);
577
		}
571 578
		/* Iterate on all rooms */
572 579
		GList *cl = janus_config_get_categories(config);
573 580
		while(cl != NULL) {
......
1564 1571
		json_object_set_new(ml, "is_private", json_string(mp->is_private ? "true" : "false"));
1565 1572
		json_object_set_new(response, "stream", ml);
1566 1573
		/* Also notify event handlers */
1567
		if(gateway->events_is_enabled()) {
1574
		if(notify_events && gateway->events_is_enabled()) {
1568 1575
			json_t *info = json_object();
1569 1576
			json_object_set_new(info, "event", json_string("created"));
1570 1577
			json_object_set_new(info, "id", json_integer(mp->id));
......
1652 1659
			old_mountpoints = g_list_append(old_mountpoints, mp);
1653 1660
		}
1654 1661
		/* Also notify event handlers */
1655
		if(gateway->events_is_enabled()) {
1662
		if(notify_events && gateway->events_is_enabled()) {
1656 1663
			json_t *info = json_object();
1657 1664
			json_object_set_new(info, "event", json_string("destroyed"));
1658 1665
			json_object_set_new(info, "id", json_integer(id_value));
......
2216 2223
			/* We wait for the setup_media event to start: on the other hand, it may have already arrived */
2217 2224
			json_object_set_new(result, "status", json_string(session->started ? "started" : "starting"));
2218 2225
			/* Also notify event handlers */
2219
			if(gateway->events_is_enabled()) {
2226
			if(notify_events && gateway->events_is_enabled()) {
2220 2227
				json_t *info = json_object();
2221 2228
				json_object_set_new(info, "status", json_string("starting"));
2222 2229
				json_object_set_new(info, "id", json_integer(session->mountpoint->id));
......
2234 2241
			result = json_object();
2235 2242
			json_object_set_new(result, "status", json_string("pausing"));
2236 2243
			/* Also notify event handlers */
2237
			if(gateway->events_is_enabled()) {
2244
			if(notify_events && gateway->events_is_enabled()) {
2238 2245
				json_t *info = json_object();
2239 2246
				json_object_set_new(info, "status", json_string("pausing"));
2240 2247
				json_object_set_new(info, "id", json_integer(session->mountpoint->id));
......
2302 2309
			json_object_set_new(result, "switched", json_string("ok"));
2303 2310
			json_object_set_new(result, "id", json_integer(id_value));
2304 2311
			/* Also notify event handlers */
2305
			if(gateway->events_is_enabled()) {
2312
			if(notify_events && gateway->events_is_enabled()) {
2306 2313
				json_t *info = json_object();
2307 2314
				json_object_set_new(info, "status", json_string("switching"));
2308 2315
				json_object_set_new(info, "id", json_integer(id_value));
......
2330 2337
				janus_mutex_unlock(&session->mountpoint->mutex);
2331 2338
			}
2332 2339
			/* Also notify event handlers */
2333
			if(gateway->events_is_enabled()) {
2340
			if(notify_events && gateway->events_is_enabled()) {
2334 2341
				json_t *info = json_object();
2335 2342
				json_object_set_new(info, "status", json_string("stopping"));
2336 2343
				json_object_set_new(info, "id", json_integer(session->mountpoint->id));
plugins/janus_textroom.c
165 165

  
166 166
/* Useful stuff */
167 167
static volatile gint initialized = 0, stopping = 0;
168
static gboolean notify_events = TRUE;
168 169
static janus_callbacks *gateway = NULL;
169 170
static GThread *handler_thread;
170 171
static GThread *watchdog;
......
377 378
		janus_config_item *key = janus_config_get_item_drilldown(config, "general", "admin_key");
378 379
		if(key != NULL && key->value != NULL)
379 380
			admin_key = g_strdup(key->value);
381
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
382
		if(events != NULL && events->value != NULL)
383
			notify_events = janus_is_true(events->value);
384
		if(!notify_events && callback->events_is_enabled()) {
385
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_TEXTROOM_NAME);
386
		}
380 387
		/* Iterate on all rooms */
381 388
		GList *cl = janus_config_get_categories(config);
382 389
		while(cl != NULL) {
......
912 919
			g_free(reply_text);
913 920
		}
914 921
		/* Also notify event handlers */
915
		if(gateway->events_is_enabled()) {
922
		if(notify_events && gateway->events_is_enabled()) {
916 923
			json_t *info = json_object();
917 924
			json_object_set_new(info, "event", json_string("join"));
918 925
			json_object_set_new(info, "room", json_integer(room_id));
......
979 986
			g_free(event_text);
980 987
		}
981 988
		/* Also notify event handlers */
982
		if(gateway->events_is_enabled()) {
989
		if(notify_events && gateway->events_is_enabled()) {
983 990
			json_t *info = json_object();
984 991
			json_object_set_new(info, "event", json_string("leave"));
985 992
			json_object_set_new(info, "room", json_integer(room_id));
......
1177 1184
			g_free(reply_text);
1178 1185
		}
1179 1186
		/* Also notify event handlers */
1180
		if(gateway->events_is_enabled()) {
1187
		if(notify_events && gateway->events_is_enabled()) {
1181 1188
			json_t *info = json_object();
1182 1189
			json_object_set_new(info, "event", json_string("created"));
1183 1190
			json_object_set_new(info, "room", json_integer(room_id));
......
1297 1304
		/* We'll let the watchdog worry about freeing resources */
1298 1305
		old_rooms = g_list_append(old_rooms, textroom);
1299 1306
		/* Also notify event handlers */
1300
		if(gateway->events_is_enabled()) {
1307
		if(notify_events && gateway->events_is_enabled()) {
1301 1308
			json_t *info = json_object();
1302 1309
			json_object_set_new(info, "event", json_string("destroyed"));
1303 1310
			json_object_set_new(info, "room", json_integer(room_id));
plugins/janus_videocall.c
319 319

  
320 320
/* Useful stuff */
321 321
static volatile gint initialized = 0, stopping = 0;
322
static gboolean notify_events = TRUE;
322 323
static janus_callbacks *gateway = NULL;
323 324
static GThread *handler_thread;
324 325
static GThread *watchdog;
......
446 447
	g_snprintf(filename, 255, "%s/%s.cfg", config_path, JANUS_VIDEOCALL_PACKAGE);
447 448
	JANUS_LOG(LOG_VERB, "Configuration file: %s\n", filename);
448 449
	janus_config *config = janus_config_parse(filename);
449
	if(config != NULL)
450
	if(config != NULL) {
450 451
		janus_config_print(config);
451
	/* This plugin actually has nothing to configure... */
452
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
453
		if(events != NULL && events->value != NULL)
454
			notify_events = janus_is_true(events->value);
455
		if(!notify_events && callback->events_is_enabled()) {
456
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_VIDEOCALL_NAME);
457
		}
458
	}
452 459
	janus_config_destroy(config);
453 460
	config = NULL;
454 461
	
......
831 838
		JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
832 839
		g_free(call_text);
833 840
		/* Also notify event handlers */
834
		if(gateway->events_is_enabled()) {
841
		if(notify_events && gateway->events_is_enabled()) {
835 842
			json_t *info = json_object();
836 843
			json_object_set_new(info, "event", json_string("hangup"));
837 844
			json_object_set_new(info, "reason", json_string("Remote WebRTC hangup"));
......
961 968
			json_object_set_new(result, "event", json_string("registered"));
962 969
			json_object_set_new(result, "username", json_string(username_text));
963 970
			/* Also notify event handlers */
964
			if(gateway->events_is_enabled()) {
971
			if(notify_events && gateway->events_is_enabled()) {
965 972
				json_t *info = json_object();
966 973
				json_object_set_new(info, "event", json_string("registered"));
967 974
				json_object_set_new(info, "username", json_string(username_text));
......
1011 1018
				json_object_set_new(result, "username", json_string(session->username));
1012 1019
				json_object_set_new(result, "reason", json_string("User busy"));
1013 1020
				/* Also notify event handlers */
1014
				if(gateway->events_is_enabled()) {
1021
				if(notify_events && gateway->events_is_enabled()) {
1015 1022
					json_t *info = json_object();
1016 1023
					json_object_set_new(info, "event", json_string("hangup"));
1017 1024
					json_object_set_new(info, "reason", json_string("User busy"));
......
1071 1078
				result = json_object();
1072 1079
				json_object_set_new(result, "event", json_string("calling"));
1073 1080
				/* Also notify event handlers */
1074
				if(gateway->events_is_enabled()) {
1081
				if(notify_events && gateway->events_is_enabled()) {
1075 1082
					json_t *info = json_object();
1076 1083
					json_object_set_new(info, "event", json_string("calling"));
1077 1084
					gateway->notify_event(session->handle, info);
......
1114 1121
			result = json_object();
1115 1122
			json_object_set_new(result, "event", json_string("accepted"));
1116 1123
			/* Also notify event handlers */
1117
			if(gateway->events_is_enabled()) {
1124
			if(notify_events && gateway->events_is_enabled()) {
1118 1125
				json_t *info = json_object();
1119 1126
				json_object_set_new(info, "event", json_string("accepted"));
1120 1127
				gateway->notify_event(session->handle, info);
......
1245 1252
				janus_mutex_unlock(&session->rec_mutex);
1246 1253
			}
1247 1254
			/* Also notify event handlers */
1248
			if(gateway->events_is_enabled()) {
1255
			if(notify_events && gateway->events_is_enabled()) {
1249 1256
				json_t *info = json_object();
1250 1257
				json_object_set_new(info, "event", json_string("configured"));
1251 1258
				json_object_set_new(info, "audio_active", session->audio_active ? json_true() : json_false());
......
1282 1289
			json_object_set_new(result, "username", json_string(session->username));
1283 1290
			json_object_set_new(result, "reason", json_string("Explicit hangup"));
1284 1291
			/* Also notify event handlers */
1285
			if(gateway->events_is_enabled()) {
1292
			if(notify_events && gateway->events_is_enabled()) {
1286 1293
				json_t *info = json_object();
1287 1294
				json_object_set_new(info, "event", json_string("hangup"));
1288 1295
				json_object_set_new(info, "reason", json_string("Explicit hangup"));
......
1304 1311
				JANUS_LOG(LOG_VERB, "  >> %d (%s)\n", ret, janus_get_api_error(ret));
1305 1312
				g_free(call_text);
1306 1313
				/* Also notify event handlers */
1307
				if(gateway->events_is_enabled()) {
1314
				if(notify_events && gateway->events_is_enabled()) {
1308 1315
					json_t *info = json_object();
1309 1316
					json_object_set_new(info, "event", json_string("hangup"));
1310 1317
					json_object_set_new(info, "reason", json_string("Remote hangup"));
plugins/janus_videoroom.c
283 283

  
284 284
/* Useful stuff */
285 285
static volatile gint initialized = 0, stopping = 0;
286
static gboolean notify_events = TRUE;
286 287
static janus_callbacks *gateway = NULL;
287 288
static GThread *handler_thread;
288 289
static GThread *watchdog;
......
756 757
		janus_config_item *key = janus_config_get_item_drilldown(config, "general", "admin_key");
757 758
		if(key != NULL && key->value != NULL)
758 759
			admin_key = g_strdup(key->value);
760
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
761
		if(events != NULL && events->value != NULL)
762
			notify_events = janus_is_true(events->value);
763
		if(!notify_events && callback->events_is_enabled()) {
764
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_VIDEOROOM_NAME);
765
		}
759 766
		/* Iterate on all rooms */
760 767
		GList *cl = janus_config_get_categories(config);
761 768
		while(cl != NULL) {
......
1481 1488
		json_object_set_new(response, "videoroom", json_string("created"));
1482 1489
		json_object_set_new(response, "room", json_integer(videoroom->room_id));
1483 1490
		/* Also notify event handlers */
1484
		if(gateway->events_is_enabled()) {
1491
		if(notify_events && gateway->events_is_enabled()) {
1485 1492
			json_t *info = json_object();
1486 1493
			json_object_set_new(info, "event", json_string("created"));
1487 1494
			json_object_set_new(info, "room", json_integer(videoroom->room_id));
......
1539 1546
		g_free(destroyed_text);
1540 1547
		janus_mutex_unlock(&videoroom->participants_mutex);
1541 1548
		/* Also notify event handlers */
1542
		if(gateway->events_is_enabled()) {
1549
		if(notify_events && gateway->events_is_enabled()) {
1543 1550
			json_t *info = json_object();
1544 1551
			json_object_set_new(info, "event", json_string("destroyed"));
1545 1552
			json_object_set_new(info, "room", json_integer(room_id));
......
1986 1993
			g_free(pub_text);
1987 1994
			janus_mutex_unlock(&videoroom->participants_mutex);
1988 1995
			/* Also notify event handlers */
1989
			if(gateway->events_is_enabled()) {
1996
			if(notify_events && gateway->events_is_enabled()) {
1990 1997
				json_t *info = json_object();
1991 1998
				json_object_set_new(info, "event", json_string("published"));
1992 1999
				json_object_set_new(info, "room", json_integer(participant->room->room_id));
......
2010 2017
					JANUS_LOG(LOG_VERB, "New listener available, sending PLI to %"SCNu64" (%s)\n", p->user_id, p->display ? p->display : "??");
2011 2018
					gateway->relay_rtcp(p->session->handle, 1, buf, 12);
2012 2019
					/* Also notify event handlers */
2013
					if(gateway->events_is_enabled()) {
2020
					if(notify_events && gateway->events_is_enabled()) {
2014 2021
						json_t *info = json_object();
2015 2022
						json_object_set_new(info, "event", json_string("subscribed"));
2016 2023
						json_object_set_new(info, "room", json_integer(p->room->room_id));
......
2379 2386
				janus_mutex_unlock(&publisher->listeners_mutex);
2380 2387
				listener->feed = NULL;
2381 2388
				/* Also notify event handlers */
2382
				if(gateway->events_is_enabled()) {
2389
				if(notify_events && gateway->events_is_enabled()) {
2383 2390
					json_t *info = json_object();
2384 2391
					json_object_set_new(info, "event", json_string("unsubscribed"));
2385 2392
					json_object_set_new(info, "room", json_integer(publisher->room->room_id));
......
2737 2744
				json_object_set_new(event, "id", json_integer(user_id));
2738 2745
				json_object_set_new(event, "publishers", list);
2739 2746
				/* Also notify event handlers */
2740
				if(gateway->events_is_enabled()) {
2747
				if(notify_events && gateway->events_is_enabled()) {
2741 2748
					json_t *info = json_object();
2742 2749
					json_object_set_new(info, "event", json_string("joined"));
2743 2750
					json_object_set_new(info, "room", json_integer(videoroom->room_id));
......
2831 2838
						root = NULL;
2832 2839
						janus_videoroom_message_free(msg);
2833 2840
						/* Also notify event handlers */
2834
						if(gateway->events_is_enabled()) {
2841
						if(notify_events && gateway->events_is_enabled()) {
2835 2842
							json_t *info = json_object();
2836 2843
							json_object_set_new(info, "event", json_string("subscribing"));
2837 2844
							json_object_set_new(info, "room", json_integer(videoroom->room_id));
......
3029 3036
				json_object_set_new(event, "room", json_integer(participant->room->room_id));
3030 3037
				json_object_set_new(event, "configured", json_string("ok"));
3031 3038
				/* Also notify event handlers */
3032
				if(gateway->events_is_enabled()) {
3039
				if(notify_events && gateway->events_is_enabled()) {
3033 3040
					json_t *info = json_object();
3034 3041
					json_object_set_new(info, "event", json_string("configured"));
3035 3042
					json_object_set_new(info, "room", json_integer(participant->room->room_id));
......
3219 3226
				if(publisher->display)
3220 3227
					json_object_set_new(event, "display", json_string(publisher->display));
3221 3228
				/* Also notify event handlers */
3222
				if(gateway->events_is_enabled()) {
3229
				if(notify_events && gateway->events_is_enabled()) {
3223 3230
					json_t *info = json_object();
3224 3231
					json_object_set_new(info, "event", json_string("switched"));
3225 3232
					json_object_set_new(info, "room", json_integer(publisher->room->room_id));
plugins/janus_voicemail.c
176 176

  
177 177
/* Useful stuff */
178 178
static volatile gint initialized = 0, stopping = 0;
179
static gboolean notify_events = TRUE;
179 180
static janus_callbacks *gateway = NULL;
180 181
static GThread *handler_thread;
181 182
static GThread *watchdog;
......
338 339
		janus_config_item *base = janus_config_get_item_drilldown(config, "general", "base");
339 340
		if(base && base->value)
340 341
			recordings_base = g_strdup(base->value);
342
		janus_config_item *events = janus_config_get_item_drilldown(config, "general", "events");
343
		if(events != NULL && events->value != NULL)
344
			notify_events = janus_is_true(events->value);
345
		if(!notify_events && callback->events_is_enabled()) {
346
			JANUS_LOG(LOG_WARN, "Notification of events to handlers disabled for %s\n", JANUS_VOICEMAIL_NAME);
347
		}
341 348
		/* Done */
342 349
		janus_config_destroy(config);
343 350
		config = NULL;
......
739 746
			json_object_set_new(event, "voicemail", json_string("event"));
740 747
			json_object_set_new(event, "status", json_string(session->started ? "started" : "starting"));
741 748
			/* Also notify event handlers */
742
			if(gateway->events_is_enabled()) {
749
			if(notify_events && gateway->events_is_enabled()) {
743 750
				json_t *info = json_object();
744 751
				json_object_set_new(info, "event", json_string("starting"));
745 752
				gateway->notify_event(session->handle, info);
......
762 769
			g_snprintf(url, 1024, "%s/janus-voicemail-%"SCNu64".opus", recordings_base, session->recording_id);
763 770
			json_object_set_new(event, "recording", json_string(url));
764 771
			/* Also notify event handlers */
765
			if(gateway->events_is_enabled()) {
772
			if(notify_events && gateway->events_is_enabled()) {
766 773
				json_t *info = json_object();
767 774
				json_object_set_new(info, "event", json_string("done"));
768 775
				gateway->notify_event(session->handle, info);

Also available in: Unified diff