Revision 18943780 plugins/janus_videoroom.c

View differences:

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;

Also available in: Unified diff