Revision 07dd477d

View differences:

Test/Makefile
14 14
../Tools/janus/bin/janus:
15 15
	make -C ../ Tools/janus/bin/janus
16 16

  
17
Libs/mongoose/mongoose.o:
18
	git submodule init Libs/mongoose/
19
	git submodule update Libs/mongoose/
17
../Libs/mongoose/mongoose.o:
18
	git submodule init ../Libs/mongoose/
19
	git submodule update ../Libs/mongoose/
20 20
	$(CC) -c -o ../Libs/mongoose/mongoose.o ../Libs/mongoose/mongoose.c $(CFLAGS) -DMG_DISABLE_MQTT -DMG_DISABLE_JSON_RPC -DMG_DISABLE_SOCKETPAIR  -DMG_DISABLE_CGI # -DMG_DISABLE_HTTP_WEBSOCKET
21 21

  
22 22
../Libs/GRAPES/src/libgrapes.a:
Test/janus_instance_test.c
108 108
	fprintf(stderr,"%s successfully passed!\n",__func__);
109 109
}
110 110

  
111
void janus_instance_ipaddr_test()
112
{
113
	struct janus_instance * janus = NULL;
114
	struct task_manager * tm;
115
	struct mg_mgr * srv;
116
	const char *res;
117

  
118
	res = janus_instance_ipaddr(janus);	
119
	assert(strlen(res) == 0);
120

  
121
	tm = task_manager_new();
122
	srv = (struct mg_mgr*) malloc(sizeof(struct mg_mgr));
123
	mg_mgr_init(srv, NULL);
124
	janus = janus_instance_create(srv, tm, janus_conf);
125
	res = janus_instance_ipaddr(janus);	
126
	assert(strlen(res));
127
	assert(strcmp(res, "127.0.0.1") == 0);
128

  
129
	janus_instance_destroy(&janus);
130
	task_manager_destroy(&tm);
131
	mg_mgr_free(srv);
132
	free(srv);
133
	fprintf(stderr,"%s successfully passed!\n",__func__);
134
}
135

  
111 136
int main(int argv, char ** argc)
112 137
{
113 138
	char wdir[200];
114 139
	strncpy(wdir, dirname(argc[0]), 200);
115
	sprintf(janus_conf, "janus_executable=%s/../Tools/janus/bin/janus,janus_param=--configs-folder=%s/../Tools/janus_conf", wdir, wdir);
140
	sprintf(janus_conf, "janus_executable=%s/../Tools/janus/bin/janus", wdir);
116 141

  
117 142
	janus_instance_create_test();
118 143
	janus_instance_launch_test();
119 144
	janus_instance_create_streaming_point_test();
145
	janus_instance_ipaddr_test();
120 146
	return 0;
121 147
}
src/janus_instance.c
23 23
#include<debug.h>
24 24
#include<unistd.h>
25 25
#include<tokens.h>
26
#include<name_lengths.h>
26 27
#include<grapes_config.h>
27 28
#include <sys/prctl.h>  // for process sync
28 29

  
......
102 103
struct janus_instance * janus_instance_create(struct mg_mgr *mongoose_srv, struct task_manager *tm, const char *config)
103 104
{
104 105
	struct janus_instance * ji = NULL;
106
	char * ptr = NULL;
105 107
	struct tag* tags;
106 108

  
107 109
	if (mongoose_srv && tm)
......
111 113
		ji = malloc(sizeof(struct janus_instance));
112 114
		ji->endpoint = strdup(grapes_config_value_str_default(tags, "janus_endpoint", "127.0.0.1:8088/janus"));
113 115
		ji->executable = strdup(grapes_config_value_str_default(tags, "janus_executable", "Tools/janus/bin/janus"));
114
		ji->conf_param = strdup(grapes_config_value_str_default(tags, "janus_param", "--configs-folder=Tools/janus_conf"));
116
		ji->conf_param = strdup(grapes_config_value_str_default(tags, "janus_param", "--configs-folder:Tools/janus_conf"));
117
		while ((ptr = strchr(ji->conf_param, ':')))
118
			*ptr='=';
119

  
115 120
		ji->logfile = strdup(grapes_config_value_str_default(tags, "janus_logfile", "janus.log"));
116 121
		ji->janus_pid = INVALID_PID;
117 122
		ji->management_session = 0;
......
602 607
	}
603 608
	return res;
604 609
}
610

  
611
const char * janus_instance_ipaddr(const struct janus_instance * janus)
612
{
613
	static char res[MAX_IPADDR_LENGTH];
614
    char *ptr;
615
	res[0] = '\0';
616

  
617
	if (janus && janus->endpoint)
618
	{
619
		ptr = strchr(janus->endpoint, ':');
620
		if (ptr)
621
		{
622
			strncpy(res, janus->endpoint, ptr - janus->endpoint);
623
			res[janus->endpoint - ptr] = '\0';
624
		} else
625
			strncpy(res, janus->endpoint, MAX_IPADDR_LENGTH);
626
	}
627
	return res;
628
}
src/janus_instance.h
45 45

  
46 46
int8_t janus_instance_forward_rtp(struct janus_instance const * janus, const char * room_id, uint64_t participant_id, const char * rtp_ip, uint16_t audio_port, uint16_t video_port);
47 47

  
48
const char * janus_instance_ipaddr(const struct janus_instance * janus);
49

  
48 50
#endif
src/path_handlers.c
149 149
	mg_get_http_var(&hm->body, "port", port, MAX_PORT_LENGTH);
150 150

  
151 151
	id = mg_uri_field(hm, 1);
152
	mg_conn_addr_to_str(nc, rtp_dst_ip, MAX_IPADDR_LENGTH, MG_SOCK_STRINGIFY_IP|MG_SOCK_STRINGIFY_REMOTE);
152
	strncpy(rtp_dst_ip, janus_instance_ipaddr(c->janus), MAX_IPADDR_LENGTH);
153 153

  
154
	info("POST request for resource %s from %s\n", id, rtp_dst_ip);
154
	info("POST request for resource %s to %s\n", id, rtp_dst_ip);
155 155
	ch = pschannel_bucket_find(c->pb, ipaddr, port);
156 156

  
157 157
	if (ch)
......
229 229
	char rtp_source_ip[MAX_IPADDR_LENGTH];
230 230
	char * id;
231 231
	const struct pstreamer * ps = NULL;
232
	const struct pschannel * ch = NULL;
233 232

  
234 233
	c = (const struct context *) nc->user_data;
235 234

  
236 235
	id = mg_uri_field(hm, 1);
237
	mg_conn_addr_to_str(nc, rtp_source_ip, MAX_IPADDR_LENGTH, MG_SOCK_STRINGIFY_IP);
236
	mg_conn_addr_to_str(nc, rtp_source_ip, MAX_IPADDR_LENGTH, MG_SOCK_STRINGIFY_IP); // PeerStreamer-ng ipaddr, shared with the psistances
238 237

  
239
	info("POST request for source resource %s from %s\n", id, rtp_source_ip);
238
	info("POST request for source resource %s to %s\n", id, rtp_source_ip);
240 239

  
241 240
	ps = pstreamer_manager_create_source_streamer(c->psm, id, rtp_source_ip, streamer_creation_callback_new(nc, c->pb, source_streamer_creation_handler)); 
242 241
	if(ps)

Also available in: Unified diff