Revision 92a361ca

View differences:

.gitignore
3 3
*.test
4 4
peerstreamer-ng
5 5
*.sdp
6
*.log
6 7
*.sample
7 8
Tools/janus
Public/assets/psng.js
1 1
function response_channel(ch)
2 2
{
3 3
	channel = ch.id;
4
	set_state(ch.janus_streaming_id);
4
	set_state(ch.name);
5 5
	startStream(ch.janus_streaming_id);
6 6
}
7 7

  
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);
src/pstreamer.c
321 321

  
322 322
	return res;
323 323
}
324

  
325
const char * pstreamer_source_ipaddr(const struct pstreamer *ps)
326
{
327
	if (ps)
328
		return ps->source_ip;
329
	return NULL;
330
}
331

  
332
const char * pstreamer_source_port(const struct pstreamer *ps)
333
{
334
	static char buff[6];
335

  
336
	if (ps)
337
	{
338
		sprintf(buff, "%"PRId16"", ps->source_port);
339
		return buff;
340
	}
341
	return NULL;
342
}
src/pstreamer.h
54 54

  
55 55
void pstreamer_touch(struct pstreamer *ps);
56 56

  
57
const char * pstreamer_source_ipaddr(const struct pstreamer *ps);
58

  
59
const char * pstreamer_source_port(const struct pstreamer *ps);
60

  
57 61
int8_t pstreamer_manager_set_streamer_options(struct pstreamer_manager *psm, const char * opts);
58 62

  
59 63
#endif
src/streamer_creation_callback.c
22 22
struct streamer_creation_callback {
23 23
	streamer_creation_handler_t callback;	
24 24
	const struct pstreamer * ps;
25
	const struct pschannel_bucket * psb;
25 26
	struct mg_connection *nc;
26 27
};
27 28

  
......
35 36
	return -1;
36 37
}
37 38

  
38
struct streamer_creation_callback * streamer_creation_callback_new(struct mg_connection *nc, streamer_creation_handler_t handler)
39
struct streamer_creation_callback * streamer_creation_callback_new(struct mg_connection *nc, const struct pschannel_bucket * psb, streamer_creation_handler_t handler)
39 40
{
40 41
	struct streamer_creation_callback * scc = NULL;
41 42

  
42
	if (nc && handler)
43
	if (nc && handler && psb)
43 44
	{
44 45
		scc = malloc(sizeof(struct streamer_creation_callback));
45 46
		scc->ps = NULL;
46 47
		scc->callback = handler;
47 48
		scc->nc = nc;
49
		scc->psb = psb;
48 50
	}
49 51
	return scc;
50 52
}
......
53 55
{
54 56
	int8_t res = -1;
55 57
	if (scc)
56
		res = scc->callback(scc->nc, scc->ps, ret);
58
		res = scc->callback(scc->nc, scc->psb, scc->ps, ret);
57 59
	return res;
58 60
}
59 61

  
src/streamer_creation_callback.h
21 21
#define __STREAMER_CREATION_CALLBACK_H__
22 22

  
23 23
#include<pstreamer.h>
24
#include<pschannel.h>
24 25
#include<stdint.h>
25 26
#include<mongoose.h>
26 27

  
27 28
struct pstreamer;
28 29
struct streamer_creation_callback;
29 30

  
30
typedef int8_t (*streamer_creation_handler_t)(struct mg_connection *nc, const struct pstreamer *ps, int8_t ret);
31
typedef int8_t (*streamer_creation_handler_t)(struct mg_connection *nc, const struct pschannel_bucket * psb,  const struct pstreamer *ps, int8_t ret);
31 32

  
32
struct streamer_creation_callback * streamer_creation_callback_new(struct mg_connection *nc, streamer_creation_handler_t handler);
33
struct streamer_creation_callback * streamer_creation_callback_new(struct mg_connection *nc, const struct pschannel_bucket * psb, streamer_creation_handler_t handler);
33 34
 
34 35
int8_t streamer_creation_set_pstreamer_ref(struct streamer_creation_callback * scc, const struct pstreamer *ps);
35 36

  

Also available in: Unified diff