#include <string.h>
#include <assert.h>
#include <errno.h>
+#include <netinet/in.h>
#include "log.h"
#include "mem.h"
#include "vector.h"
#include "heap.h"
#include "timeval.h"
+#include "client.h"
#include "playrtp.h"
#define readahead linux_headers_are_borked
+/** @brief Obsolete synonym */
+#ifndef IPV6_JOIN_GROUP
+# define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
+#endif
+
/** @brief RTP socket */
static int rtpfd;
#if HAVE_ALSA_ASOUNDLIB_H
# define DEFAULT_BACKEND playrtp_alsa
-#elif HAVE_SYS_SOUNDCARD_H
+#elif HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
# define DEFAULT_BACKEND playrtp_oss
#elif HAVE_COREAUDIO_AUDIOHARDWARE_H
# define DEFAULT_BACKEND playrtp_coreaudio
{ "buffer", required_argument, 0, 'b' },
{ "rcvbuf", required_argument, 0, 'R' },
{ "multicast", required_argument, 0, 'M' },
-#if HAVE_SYS_SOUNDCARD_H
+#if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
{ "oss", no_argument, 0, 'o' },
#endif
#if HAVE_ALSA_ASOUNDLIB_H
#if HAVE_COREAUDIO_AUDIOHARDWARE_H
{ "core-audio", no_argument, 0, 'c' },
#endif
+ { "config", required_argument, 0, 'C' },
{ 0, 0, 0, 0 }
};
" --max, -x FRAMES Buffer maximum size\n"
" --rcvbuf, -R BYTES Socket receive buffer size\n"
" --multicast, -M GROUP Join multicast group\n"
+ " --config, -C PATH Set configuration file\n"
#if HAVE_ALSA_ASOUNDLIB_H
" --alsa, -a Use ALSA to play audio\n"
#endif
-#if HAVE_SYS_SOUNDCARD_H
+#if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
" --oss, -o Use OSS to play audio\n"
#endif
#if HAVE_COREAUDIO_AUDIOHARDWARE_H
char *multicast_group = 0;
struct ip_mreq mreq;
struct ipv6_mreq mreq6;
+ disorder_client *c;
+ char *address, *port;
static const struct addrinfo prefs = {
AI_PASSIVE,
mem_init();
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
- while((n = getopt_long(argc, argv, "hVdD:m:b:x:L:R:M:aoc", options, 0)) >= 0) {
+ while((n = getopt_long(argc, argv, "hVdD:m:b:x:L:R:M:aocC:", options, 0)) >= 0) {
switch(n) {
case 'h': help();
case 'V': version();
#if HAVE_ALSA_ASOUNDLIB_H
case 'a': backend = playrtp_alsa; break;
#endif
-#if 0
-#if HAVE_SYS_SOUNDCARD_H
+#if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
case 'o': backend = playrtp_oss; break;
#endif
#if HAVE_COREAUDIO_AUDIOHARDWARE_H
case 'c': backend = playrtp_coreaudio; break;
#endif
-#endif
+ case 'C': configfile = optarg; break;
default: fatal(0, "invalid option");
}
}
+ if(config_read(0)) fatal(0, "cannot read configuration");
if(!maxbuffer)
maxbuffer = 4 * readahead;
argc -= optind;
argv += optind;
- if(argc < 1 || argc > 2)
- fatal(0, "usage: disorder-playrtp [OPTIONS] ADDRESS [PORT]");
- sl.n = argc;
- sl.s = argv;
+ switch(argc) {
+ case 0:
+ case 1:
+ if(!(c = disorder_new(1))) exit(EXIT_FAILURE);
+ if(disorder_connect(c)) exit(EXIT_FAILURE);
+ if(disorder_rtp_address(c, &address, &port)) exit(EXIT_FAILURE);
+ sl.n = 1;
+ sl.s = &port;
+ /* set multicast_group if address is a multicast address */
+ break;
+ case 2:
+ sl.n = argc;
+ sl.s = argv;
+ break;
+ default:
+ fatal(0, "usage: disorder-playrtp [OPTIONS] [ADDRESS [PORT]]");
+ }
/* Listen for inbound audio data */
if(!(res = get_address(&sl, &prefs, &sockname)))
exit(1);
+ info("listening on %s", sockname);
if((rtpfd = socket(res->ai_family,
res->ai_socktype,
res->ai_protocol)) < 0)