Revision 18943780

View differences:

plugins/janus_echotest.c
508 508
			return;
509 509
		if(buf == NULL || len <= 0)
510 510
			return;
511
		char *text = calloc(len+1, sizeof(char));
511
		char *text = g_malloc0(len+1);
512 512
		memcpy(text, buf, len);
513 513
		*(text+len) = '\0';
514 514
		JANUS_LOG(LOG_VERB, "Got a DataChannel message (%zu bytes) to bounce back: %s\n", strlen(text), text);
515
		char reply[1<<16];
516
		memset(reply, 0, 1<<16);
517
		g_snprintf(reply, 1<<16, "Janus EchoTest here! You wrote: %s", text);
518
		free(text);
515
		/* We send back the same text with a custom prefix */
516
		const char *prefix = "Janus EchoTest here! You wrote: ";
517
		char *reply = g_malloc0(strlen(prefix)+len+1);
518
		g_snprintf(reply, strlen(prefix)+len, "%s%s", prefix, text);
519
		g_free(text);
519 520
		gateway->relay_data(handle, reply, strlen(reply));
521
		g_free(reply);
520 522
	}
521 523
}
522 524

  
plugins/janus_videocall.c
672 672
			return;
673 673
		if(buf == NULL || len <= 0)
674 674
			return;
675
		char text[1<<16];
676
		memset(text, 0, 1<<16);
675
		char *text = g_malloc0(len+1);
677 676
		memcpy(text, buf, len);
678
		text[len] = '\0';
677
		*(text+len) = '\0';
679 678
		JANUS_LOG(LOG_VERB, "Got a DataChannel message (%zu bytes) to forward: %s\n", strlen(text), text);
680 679
		gateway->relay_data(session->peer->handle, text, strlen(text));
680
		g_free(text);
681 681
	}
682 682
}
683 683

  
plugins/janus_videoroom.c
339 339
	uint16_t seq_number;
340 340
} janus_videoroom_rtp_relay_packet;
341 341

  
342
typedef struct janus_videoroom_data_relay_packet {
343
	char *data;
344
	gint length;
345
} janus_videoroom_data_relay_packet;
346

  
347 342
/* SDP offer/answer templates */
348 343
#define OPUS_PT		111
349 344
#define VP8_PT		100
......
1865 1860
	if(!session || session->destroyed || !session->participant || session->participant_type != janus_videoroom_p_type_publisher)
1866 1861
		return;
1867 1862
	janus_videoroom_participant *participant = (janus_videoroom_participant *)session->participant;
1868
	janus_videoroom_data_relay_packet packet;
1869
	packet.data = buf;
1870
	packet.length = len;
1871
	g_slist_foreach(participant->listeners, janus_videoroom_relay_data_packet, &packet);
1863
	/* Get a string out of the data */
1864
	char *text = g_malloc0(len+1);
1865
	memcpy(text, buf, len);
1866
	*(text+len) = '\0';
1867
	JANUS_LOG(LOG_VERB, "Got a DataChannel message (%zu bytes) to forward: %s\n", strlen(text), text);
1868
	g_slist_foreach(participant->listeners, janus_videoroom_relay_data_packet, text);
1869
	g_free(text);
1872 1870
}
1873 1871

  
1874 1872
void janus_videoroom_slow_link(janus_plugin_session *handle, int uplink, int video) {
......
3719 3717
}
3720 3718

  
3721 3719
static void janus_videoroom_relay_data_packet(gpointer data, gpointer user_data) {
3722
	janus_videoroom_data_relay_packet *packet = (janus_videoroom_data_relay_packet *)user_data;
3720
	char *text = (char *)user_data;
3723 3721
	janus_videoroom_listener *listener = (janus_videoroom_listener *)data;
3724 3722
	if(!listener || !listener->session || !listener->data || listener->paused) {
3725 3723
		return;
......
3731 3729
	if(!session->started) {
3732 3730
		return;
3733 3731
	}
3734
	if(gateway != NULL) {
3735
		char text[1<<16];
3736
		memset(text, 0, 1<<16);
3737
		memcpy(text, packet->data, packet->length);
3738
		text[packet->length] = '\0';
3739
		JANUS_LOG(LOG_VERB, "Got a DataChannel message (%zu bytes) to forward: %s\n", strlen(text), text);
3732
	if(gateway != NULL && text != NULL) {
3733
		JANUS_LOG(LOG_VERB, "Forwarding DataChannel message (%zu bytes) to viewer: %s\n", strlen(text), text);
3740 3734
		gateway->relay_data(session->handle, text, strlen(text));
3741 3735
	}
3742 3736
	return;
sctp.c
1310 1310
	JANUS_LOG(LOG_INFO, "[%"SCNu64"] Leaving SCTP association thread\n", sctp->handle_id);
1311 1311
	/* This association has been destroyed, wait a bit and then free all the resources */
1312 1312
	g_usleep (1*G_USEC_PER_SEC);
1313
	g_queue_free(sctp->in_messages);
1313
	GQueue *tmp = sctp->in_messages;
1314 1314
	sctp->in_messages = NULL;
1315
	g_queue_free(sctp->out_messages);
1315
	while(!g_queue_is_empty(tmp)) {
1316
		message = g_queue_pop_head(tmp);
1317
		janus_sctp_message_destroy(message);
1318
	}
1319
	g_queue_free(tmp);
1320
	tmp = sctp->out_messages;
1316 1321
	sctp->out_messages = NULL;
1322
	while(!g_queue_is_empty(tmp)) {
1323
		message = g_queue_pop_head(tmp);
1324
		janus_sctp_message_destroy(message);
1325
	}
1326
	g_queue_free(tmp);
1317 1327
	sctp->thread = NULL;
1318 1328
#ifdef DEBUG_SCTP
1319 1329
	if(sctp->debug_dump != NULL)

Also available in: Unified diff