Revision 92a361ca src/path_handlers.c

View differences:

src/path_handlers.c
71 71
	free(channels);
72 72
}
73 73

  
74
int8_t streamer_creation_handler(struct mg_connection *nc, const struct pstreamer * ps, int8_t ret)
74
int8_t streamer_creation_handler(struct mg_connection *nc, const struct pschannel_bucket *psb, const struct pstreamer * ps, int8_t ret)
75 75
{
76 76
	char * json = NULL;
77 77
	int8_t res = -1;
78
	const struct pschannel * ch = NULL;
78 79

  
79 80
	info("Inside creation handler\n");
80 81
	if (ps)
82
	{
83
		ch = pschannel_bucket_find(psb, pstreamer_source_ipaddr(ps), pstreamer_source_port(ps));
81 84
		json = pstreamer_to_json(ps);
85
		if (ch)
86
			json[strlen(json)-1] = '\0';
87
	}
82 88

  
83 89
	if (ret == 0 && json)
84 90
	{
85 91
		mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nContent-type: application/json\r\n\r\n");
86 92
		mg_printf_http_chunk(nc, json);
93
		if (ch)
94
			mg_printf_http_chunk(nc, ",\"name\":\"%s\"}", ch->name);
87 95
		res = 0;
88 96
		info("Stream created and served\n");
89 97
	} else {
......
125 133
	if (ch)
126 134
	{
127 135
		debug("Channel: %s\n", ch->name);
128
		ps = pstreamer_manager_create_streamer(c->psm, ipaddr, port, id, rtp_dst_ip, streamer_creation_callback_new(nc, streamer_creation_handler)); 
136
		ps = pstreamer_manager_create_streamer(c->psm, ipaddr, port, id, rtp_dst_ip, streamer_creation_callback_new(nc, c->pb, streamer_creation_handler)); 
129 137
		if(ps)
130 138
		{
131 139
			pstreamer_schedule_tasks((struct pstreamer*)ps, c->tm);

Also available in: Unified diff