source: roaraudio/roarclients/roarcatvio.c @ 5949:9528e85ba67c

Last change on this file since 5949:9528e85ba67c was 5949:9528e85ba67c, checked in by phi, 10 years ago

Marked roarcatvio as obsolete. Added all unique features to roarcatplay.

File size: 4.1 KB
Line 
1//roarcatvio.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2013
5 *
6 *  This file is part of roarclients 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 *  RoarAudio 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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include <roaraudio.h>
27
28#define BUFSIZE 1024
29
30void usage (void) {
31 printf("roarcatvio [OPTIONS]... [FILE]\n");
32
33 printf("\nOptions:\n\n");
34
35 printf("  --server -s SERVER    - Set server hostname\n"
36        "  --rate   -R RATE      - Set sample rate\n"
37        "  --bits   -B BITS      - Set bits per sample\n"
38        "  --chans  -C CHANNELS  - Set number of channels\n"
39        "  --codec  -E CODEC     - Set the codec\n"
40        "  --aiprofile PROFILE   - Set audio profile\n"
41        "  --help                - Show this help\n"
42       );
43
44}
45
46int main (int argc, char * argv[]) {
47 struct roar_audio_info info = {.rate = ROAR_RATE_DEFAULT,
48                                .bits = ROAR_BITS_DEFAULT,
49                                .channels = ROAR_CHANNELS_DEFAULT,
50                                .codec = ROAR_AUDIO_INFO_INVALID};
51 int    auinfo_changed = 0;
52 const char * server   = NULL;
53 const char * k;
54 int    i;
55 const char * name = "roarcatvio";
56 roar_vs_t * vss;
57 const char * filename = NULL;
58 int err;
59
60 roar_debug_bin_obsolete(argv[0], "roarcatplay", NULL);
61
62 for (i = 1; i < argc; i++) {
63  k = argv[i];
64
65  if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) {
66   server = argv[++i];
67  } else if ( !strcmp(k, "-n") ) {
68   name = argv[++i];
69  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) {
70   info.rate = roar_str2rate(argv[++i]);
71   auinfo_changed = 1;
72  } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) {
73   info.bits = roar_str2bits(argv[++i]);
74   auinfo_changed = 1;
75  } else if ( !strcmp(k, "-b") ) {
76   info.bits = 8;
77   auinfo_changed = 1;
78  } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) {
79   info.channels = roar_str2channels(argv[++i]);
80   auinfo_changed = 1;
81  } else if ( !strcmp(k, "-m") ) {
82   info.channels = 1;
83   auinfo_changed = 1;
84  } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) {
85   info.codec = roar_str2codec(argv[++i]);
86   auinfo_changed = 1;
87  } else if ( !strcmp(k, "--aiprofile") ) {
88   if ( roar_profile2info(&info, argv[++i]) == -1 ) {
89    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
90    return 1;
91   }
92   auinfo_changed = 1;
93  } else if ( !strcmp(k, "--help") ) {
94   usage();
95   return 0;
96  } else if ( filename == NULL ) {
97   filename    = k;
98  } else {
99   fprintf(stderr, "Error: unknown argument: %s\n", k);
100   usage();
101   return 1;
102  }
103 }
104
105 if ( info.codec == ROAR_AUDIO_INFO_INVALID )
106  info.codec = ROAR_CODEC_DEFAULT;
107
108 if ( (vss = roar_vs_new(server, name, &err)) == NULL ) {
109  fprintf(stderr, "Error: can not connect to server: %s: %s\n",
110   server == NULL ? "(default)" : server, roar_error2str(err));
111  return 10;
112 }
113
114 if ( auinfo_changed ) {
115  if ( roar_vs_stream(vss, &info, ROAR_DIR_PLAY, &err) == -1 ) {
116   fprintf(stderr, "Error: can not create new stream: %s\n", roar_error2str(err));
117   roar_vs_close(vss, ROAR_VS_TRUE, NULL);
118   return 10;
119  }
120 }
121
122 if ( roar_vs_file_simple(vss, filename, &err) == -1 ) {
123  fprintf(stderr, "Error: can not open file: %s: %s\n", filename, roar_error2str(err));
124  roar_vs_close(vss, ROAR_VS_TRUE, NULL);
125  return 10;
126 }
127
128 roar_vs_run(vss, NULL);
129
130 roar_vs_sync(vss, ROAR_VS_WAIT, NULL);
131 roar_vs_close(vss, ROAR_VS_FALSE, NULL);
132
133 return 0;
134}
135
136//ll
Note: See TracBrowser for help on using the repository browser.