source: roaraudio/roarclients/roarshout.c @ 599:383c9508e3f4

Last change on this file since 599:383c9508e3f4 was 599:383c9508e3f4, checked in by phi, 16 years ago

added roarshout

File size: 1.6 KB
Line 
1//roarshout.c:
2
3#include <roaraudio.h>
4
5#define BUFSIZE 1024
6
7void usage (void) {
8 printf("roarmon [OPTIONS]...\n");
9
10 printf("\nOptions:\n\n");
11
12 printf("  --server SERVER    - Set server hostname\n"
13        "  --rate   RATE      - Set sample rate\n"
14        "  --bits   BITS      - Set bits per sample\n"
15        "  --chans  CHANNELS  - Set number of channels\n"
16        "  --codec  CODEC     - Set the codec\n"
17        "  --help             - Show this help\n"
18       );
19
20}
21
22int main (int argc, char * argv[]) {
23 int    rate     = 44100;
24 int    bits     = 16;
25 int    channels = 2;
26 int    codec    = ROAR_CODEC_OGG_VORBIS;
27 char * server   = NULL;
28 char * k;
29 char * s_server = NULL;
30 char * s_mount  = "/roar.ogg";
31 char * s_pw     = "hackme";
32 int    s_port   = 8000;
33 int    fh;
34 int    i;
35 char buf[BUFSIZE];
36
37 for (i = 1; i < argc; i++) {
38  k = argv[i];
39
40  if ( strcmp(k, "--server") == 0 ) {
41   server = argv[++i];
42  } else if ( strcmp(k, "--rate") == 0 ) {
43   rate = atoi(argv[++i]);
44  } else if ( strcmp(k, "--bits") == 0 ) {
45   bits = atoi(argv[++i]);
46  } else if ( strcmp(k, "--channels") == 0 ) {
47   channels = atoi(argv[++i]);
48  } else if ( strcmp(k, "--codec") == 0 ) {
49   codec = roar_str2codec(argv[++i]);
50  } else if ( strcmp(k, "--help") == 0 ) {
51   usage();
52   return 0;
53  } else {
54   fprintf(stderr, "Error: unknown argument: %s\n", k);
55   usage();
56   return 1;
57  }
58 }
59
60 if ( (fh = roar_simple_monitor(rate, channels, bits, codec, server, "roarmon")) == -1 ) {
61  fprintf(stderr, "Error: can not start monetoring\n");
62  return 1;
63 }
64
65 while((i = read(fh, buf, BUFSIZE)))
66  if (write(1, buf, i) != i)
67   break;
68
69 roar_simple_close(fh);
70
71 return 0;
72}
73
74//ll
Note: See TracBrowser for help on using the repository browser.