source: roaraudio/libroar/stream.c @ 2951:276f334ed927

Last change on this file since 2951:276f334ed927 was 2951:276f334ed927, checked in by phi, 15 years ago

added support for extended flags

File size: 16.7 KB
Line 
1//stream.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
5 *
6 *  This file is part of libroar a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  libroar is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 *  NOTE for everyone want's to change something and send patches:
24 *  read README and HACKING! There a addition information on
25 *  the license of this document you need to read before you send
26 *  any patches.
27 *
28 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
29 *  or libpulse*:
30 *  The libs libroaresd, libroararts and libroarpulse link this lib
31 *  and are therefore GPL. Because of this it may be illigal to use
32 *  them with any software that uses libesd, libartsc or libpulse*.
33 */
34
35#include "libroar.h"
36
37int roar_stream_connect (struct roar_connection * con, struct roar_stream * s, int dir) {
38 struct roar_message m;
39
40 s->dir = dir;
41
42 m.cmd     = ROAR_CMD_NEW_STREAM;
43 m.stream  = -1;
44 m.pos     = 0;
45
46 roar_stream_s2m(s, &m);
47
48 if ( roar_req(con, &m, NULL) != 0 )
49  return -1;
50
51 if ( m.cmd == ROAR_CMD_OK ) {
52  s->id = m.stream;
53
54  ROAR_DBG("roar_stream_connect(*) = 0");
55  return 0;
56 }
57
58 ROAR_ERR("roar_stream_connect(*): Connecting new stream faild!");
59 ROAR_DBG("roar_stream_connect(*) = -1");
60 return -1;
61}
62
63int roar_stream_new (struct roar_stream * s, unsigned int rate,
64                     unsigned int channels, unsigned int bits, unsigned int codec) {
65
66 if ( s == NULL )
67  return -1;
68
69 s->fh         = -1;
70 s->id         = -1;
71 s->pos        =  0;
72 s->pos_rel_id = -1;
73
74 s->dir        = ROAR_DIR_DEFAULT;
75
76/*
77 s->datalen    = 0;
78 s->offset     = 0;
79
80 s->database   = NULL;
81 s->dataoff    = NULL;
82*/
83
84 s->info.rate     = rate;
85 s->info.channels = channels;
86 s->info.bits     = bits;
87 s->info.codec    = codec;
88
89 if ( bits > ROAR_BITS_MAX )
90  return -1;
91
92 return 0;
93}
94
95int roar_stream_set_rel_id(struct roar_stream * s, int id) {
96 if ( s == NULL )
97  return -1;
98
99 s->pos_rel_id = id;
100
101 return 0;
102}
103
104int roar_stream_get_rel_id(struct roar_stream * s) {
105 if ( s == NULL )
106  return -1;
107
108 return s->pos_rel_id;
109}
110
111int roar_stream_new_by_id(struct roar_stream * s, int id) {
112 if ( s == NULL )
113  return -1;
114
115 if ( roar_stream_new_empty(s) == -1 )
116  return -1;
117
118 return roar_stream_set_id(s, id);
119}
120
121int roar_stream_new_empty(struct roar_stream * s) {
122 if ( s == NULL )
123  return -1;
124
125 return roar_stream_new(s, 0, 0, 0, 0);
126}
127
128int roar_stream_set_id (struct roar_stream * s, int id) {
129 if ( s == NULL )
130  return -1;
131
132 s->id = id;
133
134 return 0;
135}
136
137int roar_stream_get_id (struct roar_stream * s) {
138 if ( s == NULL )
139  return -1;
140
141 return s->id;
142}
143
144int roar_stream_set_fh (struct roar_stream * s, int fh) {
145 if ( s == NULL )
146  return -1;
147
148 s->fh = fh;
149
150 return 0;
151}
152
153int roar_stream_get_fh (struct roar_stream * s) {
154 if ( s == NULL )
155  return -1;
156
157 return s->fh;
158}
159
160int roar_stream_set_dir (struct roar_stream * s, int dir) {
161 if ( s == NULL )
162  return -1;
163
164 s->dir = dir;
165
166 return 0;
167}
168
169int roar_stream_get_dir (struct roar_stream * s) {
170 if ( s == NULL )
171  return -1;
172
173 return s->dir;
174}
175
176
177int roar_stream_exec    (struct roar_connection * con, struct roar_stream * s) {
178 struct roar_message m;
179
180 m.cmd     = ROAR_CMD_EXEC_STREAM;
181 m.stream  = s->id;
182 m.datalen = 0;
183 m.pos     = 0;
184
185 if ( roar_req(con, &m, NULL) == -1 )
186  return -1;
187
188 if ( m.cmd == ROAR_CMD_OK )
189  return 0;
190 return -1;
191}
192
193int roar_stream_connect_to (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port) {
194 struct roar_message m;
195
196 if ( roar_stream_connect_to_ask(con, s, type, host, port) == -1 )
197  return -1;
198
199 if ( roar_recv_message(con, &m, NULL) == -1 )
200  return -1;
201
202 if ( m.cmd == ROAR_CMD_OK )
203  return 0;
204 return -1;
205}
206
207int roar_stream_connect_to_ask (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port) {
208 struct roar_message m;
209 int len = 0;
210
211 if ( host == NULL )
212  return -1;
213
214 ROAR_DBG("roar_stream_connect_to_ask(*): Ask the server to connect to: %s:%i", host, port);
215
216 m.cmd     = ROAR_CMD_CON_STREAM;
217 m.stream  = s->id;
218 m.pos     = 0;
219
220 m.data[0] = 0;
221 m.data[1] = type;
222 ((uint16_t*)&(m.data))[1] = ROAR_HOST2NET16(port);
223
224 len = strlen(host);
225
226 if ( len > 76 )
227  return -1;
228
229 strncpy(&(m.data[4]), host, len);
230
231 m.datalen = len + 4;
232
233 if ( roar_send_message(con, &m, NULL) == -1 )
234  return -1;
235
236 return 0;
237}
238
239int roar_stream_passfh  (struct roar_connection * con, struct roar_stream * s, int fh) {
240 struct roar_message m;
241 int confh;
242
243 m.cmd     = ROAR_CMD_PASSFH;
244 m.stream  = s->id;
245 m.pos     = 0;
246 m.datalen = 0;
247
248 ROAR_DBG("roar_stream_passfh(con=%p{...}, s={.id=%i,...}, fh=%i) = ?", con, s->id, fh);
249
250 if ( (confh = roar_get_connection_fh(con)) == -1 )
251  return -1;
252
253 if ( roar_send_message(con, &m, NULL) == -1 ) {
254  ROAR_DBG("roar_stream_passfh(con=%p{...}, s={.id=%i,...}, fh=%i) = -1 // can not send message", con, s->id, fh);
255  return -1;
256 }
257
258 ROAR_DBG("roar_stream_passfh(*): msg send");
259
260 if ( roar_socket_send_fh(confh, fh, NULL, 0) == -1 )
261  return -1;
262
263 ROAR_DBG("roar_stream_passfh(*): fh send");
264
265 if ( roar_recv_message(con, &m, NULL) == -1 )
266  return -1;
267
268 ROAR_DBG("roar_stream_passfh(*): mes recved");
269
270 if ( m.cmd == ROAR_CMD_OK )
271  return 0;
272
273 return -1;
274}
275
276int roar_stream_attach_simple (struct roar_connection * con, struct roar_stream * s, int client) {
277 struct roar_message m;
278 uint16_t * info = (uint16_t *) m.data;
279 int i;
280
281 m.cmd     = ROAR_CMD_ATTACH;
282 m.stream  = s->id;
283 m.pos     = 0;
284 m.datalen = 6;
285
286 info[0] = 0;
287 info[1] = ROAR_ATTACH_SIMPLE;
288 info[2] = client;
289
290 for (i = 0; i < m.datalen/2; i++) {
291  info[i] = ROAR_HOST2NET16(info[i]);
292 }
293
294 if ( roar_req(con, &m, NULL) == -1 )
295  return -1;
296
297 if ( m.cmd != ROAR_CMD_OK )
298  return -1;
299
300 return 0;
301}
302
303int roar_stream_add_data (struct roar_connection * con, struct roar_stream * s, char * data, size_t len) {
304 struct roar_message m;
305
306 m.cmd     = ROAR_CMD_ADD_DATA;
307 m.stream  = s->id;
308 m.pos     = 0;
309 m.datalen = len;
310
311// if ( roar_req(con, &m, (void**)&data) == -1 )
312//  return -1;
313 if ( roar_send_message(con, &m, data) != 0 )
314  return -1;
315
316 if ( roar_recv_message(con, &m, NULL) == -1 )
317  return -1;
318
319 if ( m.cmd == ROAR_CMD_OK )
320  return 0;
321 return -1;
322}
323
324int roar_stream_send_data (struct roar_connection * con, struct roar_stream * s, char * data, size_t len) {
325 if ( ! s )
326  return -1;
327
328 if ( s->fh == -1 ) {
329  if ( !con )
330   return -1;
331
332  if ( roar_stream_add_data(con, s, data, len) == -1 )
333   return -1;
334
335  return len;
336 }
337
338#ifdef ROAR_HAVE_IO_POSIX
339 return write(s->fh, data, len);
340#endif
341
342 return -1;
343}
344
345int roar_stream_get_info (struct roar_connection * con, struct roar_stream * s, struct roar_stream_info * info) {
346 struct roar_message m;
347 uint16_t * data = (uint16_t *) m.data;
348 int i;
349
350 m.cmd     = ROAR_CMD_GET_STREAM_PARA;
351 m.stream  = s->id;
352 m.datalen = 4;
353 m.pos     = 0;
354
355 data[0] = 0; // Version and reserved
356 data[1] = ROAR_STREAM_PARA_INFO; // stream
357
358 for (i = 0; i < m.datalen/2; i++) {
359  data[i] = ROAR_HOST2NET16(data[i]);
360 }
361
362 if ( roar_req(con, &m, NULL) == -1 )
363  return -1;
364
365 if ( m.cmd != ROAR_CMD_OK )
366  return -1;
367
368 for (i = 0; i < m.datalen/2; i++) {
369  data[i] = ROAR_NET2HOST16(data[i]);
370 }
371
372 if ( m.datalen < 7*2 )
373  return -1;
374
375 if ( data[0] != 0 || data[1] != 1 )
376  return -1;
377
378 memset(info, 0, sizeof(struct roar_stream_info));
379
380 info->block_size     = data[2];
381 info->pre_underruns  = data[3];
382 info->post_underruns = data[4];
383 info->codec          = data[5];
384 info->flags          = data[6];
385 info->delay          = data[7]*1000;
386
387 if ( m.datalen < 9*2 ) {
388  info->state         = ROAR_STREAMSTATE_UNKNOWN;
389  return 0;
390 } else {
391  info->state         = data[8];
392 }
393
394 if ( m.datalen < 10*2 ) {
395  return 0;
396 } else {
397  info->flags        |= ((uint32_t)data[9]) << 16;
398 }
399
400 return 0;
401}
402
403int roar_stream_get_name (struct roar_connection * con, struct roar_stream * s, char * name, size_t len) {
404 struct roar_message m;
405 uint16_t * data = (uint16_t *) m.data;
406
407 if ( con == NULL || s == NULL || name == NULL || len == 0 )
408  return -1;
409
410 name[0] = 0; // just in case...
411
412 m.cmd     = ROAR_CMD_GET_STREAM_PARA;
413 m.stream  = s->id;
414 m.datalen = 4;
415 m.pos     = 0;
416
417 data[0] = 0; // Version and reserved
418 data[1] = ROAR_STREAM_PARA_NAME; // stream
419
420 data[0] = ROAR_HOST2NET16(data[0]);
421 data[1] = ROAR_HOST2NET16(data[1]);
422
423 ROAR_DBG("roar_stream_get_name(*) = ?");
424
425 if ( roar_req(con, &m, NULL) == -1 )
426  return -1;
427
428 ROAR_DBG("roar_stream_get_name(*) = ?");
429
430 if ( m.cmd != ROAR_CMD_OK )
431  return -1;
432
433 ROAR_DBG("roar_stream_get_name(*) = ?");
434
435 if ( m.datalen < 4 )
436  return -1;
437
438 data[0] = ROAR_NET2HOST16(data[0]);
439 data[1] = ROAR_NET2HOST16(data[1]);
440
441 ROAR_DBG("roar_stream_get_name(*) = ?");
442
443 if ( data[0] != 0 || data[1] != ROAR_STREAM_PARA_NAME )
444  return -1;
445
446 m.datalen -= 4;
447
448 len--;
449
450 if ( len > m.datalen )
451  len = m.datalen;
452
453 strncpy(name, ((char*)m.data)+4, len);
454 name[len] = 0;
455
456 ROAR_DBG("roar_stream_get_name(*) = 0");
457
458 return 0;
459}
460
461int roar_stream_set_flags (struct roar_connection * con, struct roar_stream * s, int flags, int reset) {
462 struct roar_message m;
463 uint16_t * data = (uint16_t *) m.data;
464 int i;
465
466 m.cmd     = ROAR_CMD_SET_STREAM_PARA;
467 m.stream  = s->id;
468 m.datalen = 8;
469 m.pos     = 0;
470
471 data[0] = 0; // Version and reserved
472 data[1] = 2; // flags
473 data[2] = reset == ROAR_RESET_FLAG ? ROAR_RESET_FLAG : ROAR_SET_FLAG;
474 data[3] = flags;
475
476 for (i = 0; i < m.datalen/2; i++) {
477  data[i] = ROAR_HOST2NET16(data[i]);
478 }
479
480 if ( roar_req(con, &m, NULL) == -1 )
481  return -1;
482
483 if ( m.cmd != ROAR_CMD_OK )
484  return -1;
485
486 return 0;
487}
488
489#define _ROAR_STREAM_MESSAGE_LEN ((5+1)*4)
490
491int roar_stream_s2m     (struct roar_stream * s, struct roar_message * m) {
492 uint32_t * data;
493 int i;
494
495 if ( !(s && m) )
496  return -1;
497
498 m->datalen = _ROAR_STREAM_MESSAGE_LEN;
499 data = (uint32_t*) m->data;
500
501 data[0] = s->dir;
502 data[1] = s->pos_rel_id;
503 data[2] = s->info.rate;
504 data[3] = s->info.bits;
505 data[4] = s->info.channels;
506 data[5] = s->info.codec;
507
508 for (i = 0; i < _ROAR_STREAM_MESSAGE_LEN/4; i++)
509  data[i] = ROAR_HOST2NET32(data[i]);
510
511 ROAR_DBG("roar_stream_s2m(*): s->info:");
512 roar_debug_audio_info_print(&s->info);
513
514 m->pos = s->pos;
515
516 return 0;
517}
518int roar_stream_m2s     (struct roar_stream * s, struct roar_message * m) {
519 uint32_t * data;
520 int i;
521
522 if ( !(s && m) )
523  return -1;
524
525 if ( m->datalen != _ROAR_STREAM_MESSAGE_LEN )
526  return -1;
527
528 s->pos = m->pos;
529
530 data = (uint32_t*) m->data;
531
532 for (i = 0; i < _ROAR_STREAM_MESSAGE_LEN/4; i++)
533  data[i] = ROAR_NET2HOST32(data[i]);
534
535 s->id            = m->stream;
536 s->dir           = data[0];
537 s->pos_rel_id    = data[1];
538 s->info.rate     = data[2];
539 s->info.bits     = data[3];
540 s->info.channels = data[4];
541 s->info.codec    = data[5];
542
543 ROAR_DBG("roar_stream_m2s(*): s->info:");
544 roar_debug_audio_info_print(&s->info);
545
546 return 0;
547}
548
549// stream direction funcs:
550/*
551#define roar_dir2str(x)   ((x) == ROAR_DIR_PLAY   ? "play"   : (x) == ROAR_DIR_MONITOR ? "monitor" : \
552                           (x) == ROAR_DIR_FILTER ? "filter" : (x) == ROAR_DIR_RECORD  ? "record"  : \
553                           (x) == ROAR_DIR_OUTPUT ? "output" : (x) == ROAR_DIR_BIDIR   ? "bidir"   : \
554                           (x) == ROAR_DIR_MIXING ? "mixing" : \
555                           "unknown")
556*/
557
558struct {
559 int    dir;
560 char * name;
561} _libroar_dir[] = {
562 {ROAR_DIR_PLAY,        "play"       },
563 {ROAR_DIR_RECORD,      "record"     },
564 {ROAR_DIR_MONITOR,     "monitor"    },
565 {ROAR_DIR_FILTER,      "filter"     },
566 {ROAR_DIR_OUTPUT,      "output"     },
567 {ROAR_DIR_MIXING,      "mixing"     },
568 {ROAR_DIR_META,        "meta"       },
569 {ROAR_DIR_BIDIR,       "bidir"      },
570 {ROAR_DIR_THRU,        "thru"       },
571 {ROAR_DIR_BRIDGE,      "bridge"     },
572 {ROAR_DIR_MIDI_IN,     "midi_in"    },
573 {ROAR_DIR_MIDI_OUT,    "midi_out"   },
574 {ROAR_DIR_LIGHT_IN,    "light_in"   },
575 {ROAR_DIR_LIGHT_OUT,   "light_out"  },
576 {ROAR_DIR_RAW_IN,      "raw_in"     },
577 {ROAR_DIR_RAW_OUT,     "raw_out"    },
578 {ROAR_DIR_COMPLEX_IN,  "complex_in" },
579 {ROAR_DIR_COMPLEX_OUT, "complex_out"},
580 {ROAR_DIR_RDTCS_IN,    "rdtcs_in"   },
581 {ROAR_DIR_RDTCS_OUT,   "rdtcs_out"  },
582 {-1,                   "unknown"    }
583};
584
585char * roar_dir2str (int dir) {
586 int i;
587
588 for (i = 0; _libroar_dir[i].dir != -1; i++)
589  if ( _libroar_dir[i].dir == dir )
590   return _libroar_dir[i].name;
591
592 return _libroar_dir[i].name;
593}
594
595int roar_str2dir (char * name) {
596 int i;
597
598 for (i = 0; _libroar_dir[i].dir != -1; i++)
599  if ( !strcmp(_libroar_dir[i].name, name) )
600   return _libroar_dir[i].dir;
601
602 return _libroar_dir[i].dir;
603}
604
605// codec funcs:
606
607/*
608#define roar_codec2str(x) ((x) == ROAR_CODEC_PCM_S_LE  ? "pcm_s_le"  : (x) == ROAR_CODEC_PCM_S_BE  ? "pcm_s_be"  : \
609                           (x) == ROAR_CODEC_PCM_S_PDP ? "pcm_s_pdp" : (x) == ROAR_CODEC_MIDI_FILE ? "midi_file" : \
610                           "unknown" )
611*/
612
613struct {
614 int    codec;
615 char * name;
616} _libroar_codec[] = {
617 // PCM:
618 {ROAR_CODEC_PCM_S_LE,    "pcm_s_le"   },
619 {ROAR_CODEC_PCM_S_BE,    "pcm_s_be"   },
620 {ROAR_CODEC_PCM_S_PDP,   "pcm_s_pdp"  },
621 {ROAR_CODEC_PCM_U_LE,    "pcm_u_le"   },
622 {ROAR_CODEC_PCM_U_BE,    "pcm_u_be"   },
623 {ROAR_CODEC_PCM_U_PDP,   "pcm_u_pdp"  },
624 {ROAR_CODEC_DEFAULT,     "default"    }, // alias
625 {ROAR_CODEC_DEFAULT,     "pcm"        }, // alias
626 {ROAR_CODEC_DEFAULT,     "raw"        }, // alias
627
628 // MIDI:
629 {ROAR_CODEC_MIDI_FILE,   "midi_file"  },
630 {ROAR_CODEC_MIDI,        "midi"       },
631
632 // XIPH:
633 {ROAR_CODEC_OGG_VORBIS,  "ogg_vorbis" },
634 {ROAR_CODEC_OGG_VORBIS,  "vorbis"     }, // alias
635 {ROAR_CODEC_FLAC,        "flac"       },
636 {ROAR_CODEC_OGG_SPEEX,   "ogg_speex"  },
637 {ROAR_CODEC_OGG_SPEEX,   "speex"      }, // alias
638 {ROAR_CODEC_OGG_FLAC,    "ogg_flac"   },
639 {ROAR_CODEC_OGG_GENERAL, "ogg_general"},
640 {ROAR_CODEC_OGG_CELT,    "ogg_celt"   },
641 {ROAR_CODEC_OGG,         "ogg"        },
642 {ROAR_CODEC_ROAR_CELT,   "roar_celt"  },
643 {ROAR_CODEC_ROAR_SPEEX,  "roar_speex" },
644
645 // RAUM:
646 {ROAR_CODEC_RAUM,        "raum"       },
647 {ROAR_CODEC_RAUM_VORBIS, "raum_vorbis"},
648 {ROAR_CODEC_RAUM_FLAC,   "raum_flac"  },
649
650 // RIFF/WAVE like:
651 {ROAR_CODEC_RIFF_WAVE,   "riff_wave"  },
652 {ROAR_CODEC_RIFF_WAVE,   "wave"       }, // alias
653 {ROAR_CODEC_RIFF_WAVE,   "wav"        }, // alias
654
655 //Log codecs:
656 {ROAR_CODEC_ALAW,        "alaw"       },
657 {ROAR_CODEC_MULAW,       "mulaw"      },
658 {ROAR_CODEC_MULAW,       "ulaw"       }, // alias
659
660 // Meta Codecs:
661 {ROAR_CODEC_META_VCLT,     "meta_vclt"    },
662 {ROAR_CODEC_META_RALT,     "meta_ralt"    },
663 {ROAR_CODEC_META_RALB,     "meta_ralb"    },
664 {ROAR_CODEC_META_RALB_LE,  "meta_ralb_le" },
665 {ROAR_CODEC_META_RALB_BE,  "meta_ralb_be" },
666 {ROAR_CODEC_META_RALB_PDP, "meta_ralb_pdp"},
667
668 // light control:
669 {ROAR_CODEC_DMX512,      "dmx512"     },
670 {ROAR_CODEC_ROARDMX,     "roardmx"    },
671
672 // Radio Data and Transmitter Control System:
673 {ROAR_CODEC_RDS,         "rds"        },
674
675 // User specific:
676 {ROAR_CODEC_USER0,       "user0"      },
677 {ROAR_CODEC_USER1,       "user1"      },
678 {ROAR_CODEC_USER2,       "user2"      },
679 {ROAR_CODEC_USER3,       "user3"      },
680 {ROAR_CODEC_USER4,       "user4"      },
681 {ROAR_CODEC_USER5,       "user5"      },
682 {ROAR_CODEC_USER6,       "user6"      },
683 {ROAR_CODEC_USER7,       "user7"      },
684 {ROAR_CODEC_USER8,       "user8"      },
685 {ROAR_CODEC_USER9,       "user9"      },
686 {ROAR_CODEC_USER10,      "user10"     },
687 {ROAR_CODEC_USER11,      "user11"     },
688 {ROAR_CODEC_USER12,      "user12"     },
689 {ROAR_CODEC_USER13,      "user13"     },
690 {ROAR_CODEC_USER14,      "user14"     },
691 {ROAR_CODEC_USER15,      "user15"     },
692 {-1, NULL}
693};
694
695int roar_str2codec(char * codec) {
696 int i;
697 int guess;
698
699 if ( codec == NULL || *codec == 0 )
700  return ROAR_CODEC_DEFAULT;
701
702 if ( (guess = atoi(codec)) > 0 )
703  return guess;
704
705 if ( codec == NULL || *codec == 0 )
706  return ROAR_CODEC_DEFAULT;
707
708 for (i = 0; _libroar_codec[i].codec != -1; i++)
709  if ( strcasecmp(_libroar_codec[i].name, codec) == 0 )
710   return _libroar_codec[i].codec;
711
712 return -1;
713}
714
715
716char * roar_codec2str (int codec) {
717 int i;
718
719 for (i = 0; _libroar_codec[i].codec != -1; i++)
720  if ( _libroar_codec[i].codec == codec )
721   return _libroar_codec[i].name;
722
723 return "unknown";
724}
725
726char * roar_streamstate2str(int streamstate) {
727 switch (streamstate) {
728  case ROAR_STREAMSTATE_UNUSED:  return "unused";  break;
729  case ROAR_STREAMSTATE_INITING: return "initing"; break;
730  case ROAR_STREAMSTATE_NEW:     return "new";     break;
731  case ROAR_STREAMSTATE_OLD:     return "old";     break;
732  case ROAR_STREAMSTATE_CLOSING: return "closing"; break;
733 }
734
735 return "unknown";
736}
737
738//ll
Note: See TracBrowser for help on using the repository browser.