Revision cea8d274
Test/pschannel_bucket_test.c | ||
---|---|---|
168 | 168 |
fprintf(stderr,"%s successfully passed!\n",__func__); |
169 | 169 |
} |
170 | 170 |
|
171 |
void pschannel_bucket_save2file_test() |
|
172 |
{ |
|
173 |
struct pschannel_bucket * psb = NULL; |
|
174 |
const struct pschannel * ch; |
|
175 |
int8_t res = 0; |
|
176 |
|
|
177 |
res = pschannel_bucket_save2file(psb); |
|
178 |
assert(res); |
|
179 |
|
|
180 |
psb = pschannel_bucket_new(NULL, NULL); |
|
181 |
res = pschannel_bucket_save2file(psb); |
|
182 |
assert(res); |
|
183 |
pschannel_bucket_destroy(&psb); |
|
184 |
|
|
185 |
psb = pschannel_bucket_new("/tmp/channel_test_file.csv", NULL); |
|
186 |
pschannel_bucket_insert(psb, "local_channel", "10.0.0.1", "8000", "1Mbps", "localhost/channel.sdp"); |
|
187 |
res = pschannel_bucket_save2file(psb); |
|
188 |
assert(res == 0); |
|
189 |
pschannel_bucket_destroy(&psb); |
|
190 |
|
|
191 |
psb = pschannel_bucket_new("/tmp/channel_test_file_out.csv", NULL); |
|
192 |
res = pschannel_bucket_loadfile(psb); |
|
193 |
assert(res == 0); |
|
194 |
ch = pschannel_bucket_find(psb, "10.0.0.1", "8000"); |
|
195 |
assert(ch); |
|
196 |
assert(res == 0); |
|
197 |
pschannel_bucket_destroy(&psb); |
|
198 |
|
|
199 |
fprintf(stderr,"%s successfully passed!\n",__func__); |
|
200 |
} |
|
201 |
|
|
171 | 202 |
int main(int argv, char ** argc) |
172 | 203 |
{ |
173 | 204 |
pschannel_bucket_destroy_test(); |
... | ... | |
176 | 207 |
pschannel_bucket_to_json_test(); |
177 | 208 |
pschannel_bucket_loadfile_test(); |
178 | 209 |
pschannel_load_local_streams_test(); |
210 |
pschannel_bucket_save2file_test(); |
|
179 | 211 |
return 0; |
180 | 212 |
} |
src/janus_instance.c | ||
---|---|---|
523 | 523 |
struct mg_connection * conn; |
524 | 524 |
int8_t res = -1; |
525 | 525 |
char * uri; |
526 |
char * fmt = "{\"transaction\":\"random_str\",\"janus\":\"message\",\"body\":{\"request\":\"create\",\"room\":%s,\"publishers\":1,\"bitrate\":128000,\"record\":false,\"description\":\"Room %s\",\"fir_freq\":100,\"audiocodec\":\"opus\",\"videocodec\":\"vp8\"}}";
|
|
526 |
char * fmt = "{\"transaction\":\"random_str\",\"janus\":\"message\",\"body\":{\"request\":\"create\",\"room\":%s,\"publishers\":1,\"bitrate\":128000,\"record\":false,\"description\":\"Room %s\",\"fir_freq\":5,\"audiocodec\":\"opus\",\"videocodec\":\"vp8\"}}";
|
|
527 | 527 |
|
528 | 528 |
char buff[280]; |
529 | 529 |
void ** data; |
src/periodic_task_intfs.c | ||
---|---|---|
65 | 65 |
if (ret == 0) |
66 | 66 |
{ |
67 | 67 |
pschannel_bucket_reset(pb); |
68 |
pschannel_bucket_loadfile(pb); |
|
69 | 68 |
pschannel_bucket_load_local_streams(pb); |
69 |
pschannel_bucket_save2file(pb); |
|
70 |
pschannel_bucket_loadfile(pb); |
|
70 | 71 |
} |
71 | 72 |
return 1; |
72 | 73 |
} |
src/pschannel.c | ||
---|---|---|
190 | 190 |
return res; |
191 | 191 |
} |
192 | 192 |
|
193 |
int8_t pschannel_bucket_save2file(struct pschannel_bucket * psb) |
|
194 |
{ |
|
195 |
int8_t res = -1; |
|
196 |
FILE *fp; |
|
197 |
char sdpfile_out[MAX_SDPFILENAME_LENGTH+4]; |
|
198 |
char ** tokens; |
|
199 |
uint32_t ntoks; |
|
200 |
const struct pschannel * iter = NULL; |
|
201 |
|
|
202 |
if (psb && psb->csvfile) |
|
203 |
{ |
|
204 |
tokens = tokens_create(psb->csvfile, '.', &ntoks); |
|
205 |
snprintf(sdpfile_out, MAX_SDPFILENAME_LENGTH, "%s_out.csv", tokens[0]); |
|
206 |
tokens_destroy(&tokens, ntoks); |
|
207 |
|
|
208 |
if ((fp = fopen(sdpfile_out, "w"))) |
|
209 |
{ |
|
210 |
if (ftrylockfile(fp) == 0) |
|
211 |
{ |
|
212 |
debug("Dumping channel list to file\n"); |
|
213 |
for(iter = NULL; (iter = pschannel_bucket_iter(psb, iter));) |
|
214 |
fprintf(fp, "%s,%s,%s,%s,%s\n", iter->name, iter->ipaddr, iter->port, |
|
215 |
iter->quality, iter->sdpfile); |
|
216 |
funlockfile(fp); |
|
217 |
res = 0; |
|
218 |
} |
|
219 |
fclose(fp); |
|
220 |
} |
|
221 |
} |
|
222 |
return res; |
|
223 |
} |
|
224 |
|
|
193 | 225 |
int8_t pschannel_bucket_load_local_streams(struct pschannel_bucket * pb) |
194 | 226 |
{ |
195 | 227 |
int8_t res = -1; |
... | ... | |
197 | 229 |
|
198 | 230 |
if (pb && pb->psm) |
199 | 231 |
{ |
200 |
while (ps = pstreamer_manager_source_iter(pb->psm, ps))
|
|
232 |
while ((ps = pstreamer_manager_source_iter(pb->psm, ps)))
|
|
201 | 233 |
if (pstreamer_get_display_name(ps)) |
202 | 234 |
pschannel_bucket_insert(pb, pstreamer_get_display_name(ps), pstreamer_source_ipaddr(ps), pstreamer_source_port(ps), "good", "nosdpfile"); |
203 | 235 |
res = 0; |
src/pschannel.h | ||
---|---|---|
53 | 53 |
|
54 | 54 |
int8_t pschannel_bucket_reset(struct pschannel_bucket * psb); |
55 | 55 |
|
56 |
int8_t pschannel_bucket_save2file(struct pschannel_bucket * psb); |
|
57 |
|
|
56 | 58 |
#endif |
Also available in: Unified diff