Commit 79e0db4c authored by Dustin Puckett's avatar Dustin Puckett Committed by Max Kellermann

output/raop: new output plugin

Remote Audio Output Protocol (RAOP), for Apple devices.
parent 9ae3acf2
......@@ -739,6 +739,11 @@ if HAVE_OSX
OUTPUT_SRC += src/output/osx_plugin.c
endif
if ENABLE_RAOP_OUTPUT
OUTPUT_SRC += src/output/raop_output_plugin.c
MIXER_SRC += src/mixer/raop_mixer_plugin.c
endif
if HAVE_PULSE
OUTPUT_SRC += src/output/pulse_output_plugin.c
MIXER_SRC += src/mixer/pulse_mixer_plugin.c
......
......@@ -5,6 +5,7 @@ ver 0.17 (2010/??/??)
- mpg123: implement seeking
* output:
- osx: allow user to specify other audio devices
- raop: new output plugin
ver 0.16.1 (2010/01/09)
......
......@@ -200,6 +200,11 @@ AC_ARG_ENABLE(httpd-output,
[enables the HTTP server output]),,
[enable_httpd_output=auto])
AC_ARG_ENABLE(raop-output,
AS_HELP_STRING([--enable-httpd-output],
[enables the RAOP output]),,
[enable_raop_output=no])
AC_ARG_ENABLE(id3,
AS_HELP_STRING([--disable-id3],
[disable id3 support (default: enable)]),,
......@@ -1397,6 +1402,15 @@ esac
AM_CONDITIONAL(ENABLE_SOLARIS_OUTPUT, test x$enable_solaris_output = xyes)
dnl --------------------------------- RAOP ------------------------------------
if test x$enable_raop_output = xyes; then
AC_DEFINE(ENABLE_RAOP_OUTPUT, 1, [Define for compiling RAOP support])
MPD_LIBS="$MPD_LIBS -lssl -lcrypto"
fi
AM_CONDITIONAL(ENABLE_RAOP_OUTPUT, test x$enable_raop_output = xyes)
dnl --------------------------------- WinMM ---------------------------------
case "$host_os" in
......@@ -1425,6 +1439,7 @@ if
test x$enable_openal = xno &&
test x$enable_oss = xno &&
test x$enable_osx = xno &&
test x$enable_raop_output = xno &&
test x$enable_pipe_output = xno &&
test x$enable_pulse = xno &&
test x$enable_recorder_output = xno &&
......@@ -1556,6 +1571,7 @@ results(ffado,FFADO)
results(fifo,FIFO)
results(recorder_output,[File Recorder])
results(httpd_output,[HTTP Daemon])
results(raop_output, [RAOP])
results(jack,[JACK])
results(ao,[libao])
results(oss,[OSS])
......
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "../output/raop_output_plugin.h"
#include "../output_plugin.h"
#include "../mixer_api.h"
#include <glib.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
struct raop_mixer_plugin {
struct mixer base;
struct raop_data *rd;
};
static struct mixer *
raop_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
{
struct raop_mixer_plugin *rm = g_new(struct raop_mixer_plugin, 1);
rm->rd = (struct raop_data *) ao;
mixer_init(&rm->base, &raop_mixer_plugin);
return &rm->base;
}
static void
raop_mixer_finish(struct mixer *data)
{
struct raop_mixer_plugin *rm = (struct raop_mixer_plugin *) data;
g_free(rm);
}
static int
raop_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
{
struct raop_mixer_plugin *rm = (struct raop_mixer_plugin *)mixer;
return raop_get_volume(rm->rd);
}
static bool
raop_mixer_set_volume(struct mixer *mixer, unsigned volume, G_GNUC_UNUSED GError **error_r)
{
struct raop_mixer_plugin *rm = (struct raop_mixer_plugin *)mixer;
g_debug("raop_mixer_set_volume\n");
return raop_set_volume(rm->rd, volume);
}
const struct mixer_plugin raop_mixer_plugin = {
.init = raop_mixer_init,
.finish = raop_mixer_finish,
.get_volume = raop_mixer_get_volume,
.set_volume = raop_mixer_set_volume,
};
......@@ -29,6 +29,7 @@ extern const struct mixer_plugin software_mixer_plugin;
extern const struct mixer_plugin alsa_mixer_plugin;
extern const struct mixer_plugin oss_mixer_plugin;
extern const struct mixer_plugin pulse_mixer_plugin;
extern const struct mixer_plugin raop_mixer_plugin;
extern const struct mixer_plugin winmm_mixer_plugin;
#endif
/*
* Copyright (C) 2003-2010 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_OUTPUT_RAOP_PLUGIN_H
#define MPD_OUTPUT_RAOP_PLUGIN_H
#include <pthread.h>
#include <stdbool.h>
#include <netinet/in.h>
#include <sys/time.h>
#include <openssl/aes.h>
struct key_data {
unsigned char *key;
unsigned char *data;
struct key_data *next;
};
struct play_state {
bool playing;
unsigned short seq_num;
unsigned int rtptime;
unsigned int sync_src;
unsigned int start_rtptime;
struct timeval start_time;
struct timeval last_send;
};
/*********************************************************************/
struct rtspcl_data {
int fd;
char url[128];
int cseq;
struct key_data *kd;
struct key_data *exthds;
char *session;
char *transport;
unsigned short server_port;
unsigned short control_port;
struct in_addr host_addr;
struct in_addr local_addr;
const char *useragent;
};
enum pause_state {
NO_PAUSE = 0,
OP_PAUSE,
NODATA_PAUSE,
};
#define MINIMUM_SAMPLE_SIZE 32
#define RAOP_FD_READ (1<<0)
#define RAOP_FD_WRITE (1<<1)
/*********************************************************************/
struct encrypt_data {
AES_KEY ctx;
unsigned char iv[16]; // initialization vector for aes-cbc
unsigned char nv[16]; // next vector for aes-cbc
unsigned char key[16]; // key for aes-cbc
};
/*********************************************************************/
struct ntp_data {
unsigned short port;
int fd;
};
/*********************************************************************/
struct raop_data {
struct rtspcl_data *rtspcl;
const char *addr; // target host address
short rtsp_port;
struct sockaddr_in ctrl_addr;
struct sockaddr_in data_addr;
bool is_master;
struct raop_data *next;
unsigned volume;
pthread_mutex_t control_mutex;
bool started;
bool paused;
};
/*********************************************************************/
struct control_data {
unsigned short port;
int fd;
};
bool
send_control_command(struct control_data *ctrl, struct raop_data *rd, struct play_state *state);
/*********************************************************************/
#define NUMSAMPLES 352
#define RAOP_BUFFER_SIZE NUMSAMPLES * 4
#define RAOP_HEADER_SIZE 12
#define ALAC_MAX_HEADER_SIZE 8
#define RAOP_MAX_PACKET_SIZE RAOP_BUFFER_SIZE + RAOP_HEADER_SIZE + ALAC_MAX_HEADER_SIZE
// session
struct raop_session_data {
struct raop_data *raop_list;
struct ntp_data ntp;
struct control_data ctrl;
struct encrypt_data encrypt;
struct play_state play_state;
int data_fd;
unsigned char buffer[RAOP_BUFFER_SIZE];
size_t bufferSize;
unsigned char data[RAOP_MAX_PACKET_SIZE];
int wblk_wsize;
int wblk_remsize;
pthread_mutex_t data_mutex;
pthread_mutex_t list_mutex;
};
//static struct raop_session_data *raop_session;
/*********************************************************************/
bool
raop_set_volume(struct raop_data *rd, unsigned volume);
int
raop_get_volume(struct raop_data *rd);
#endif
......@@ -30,6 +30,7 @@ extern const struct audio_output_plugin ao_output_plugin;
extern const struct audio_output_plugin oss_output_plugin;
extern const struct audio_output_plugin openal_output_plugin;
extern const struct audio_output_plugin osxPlugin;
extern const struct audio_output_plugin raopPlugin;
extern const struct audio_output_plugin solaris_output_plugin;
extern const struct audio_output_plugin pulse_output_plugin;
extern const struct audio_output_plugin mvp_output_plugin;
......@@ -65,6 +66,9 @@ const struct audio_output_plugin *audio_output_plugins[] = {
#ifdef HAVE_OSX
&osxPlugin,
#endif
#ifdef ENABLE_RAOP_OUTPUT
&raopPlugin,
#endif
#ifdef ENABLE_SOLARIS_OUTPUT
&solaris_output_plugin,
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment