output/raop: delete the RAOP plugin
This plugin is horrible code, I mean it. Last year, I tried hard to fix it, but I figured would take less time to do a full rewrite. Given that I don't even have any device that supports RAOP, I can't do that properly. After 16 months, nobody volunteered for fixing it. Hereby, I delete it, because having no RAOP plugin is better than having this mess. Sorry.
This commit is contained in:
parent
3c3f1b7ff2
commit
457d98c860
18
Makefile.am
18
Makefile.am
@ -841,15 +841,6 @@ if HAVE_OSX
|
||||
liboutput_plugins_a_SOURCES += src/output/osx_output_plugin.c
|
||||
endif
|
||||
|
||||
if ENABLE_RAOP_OUTPUT
|
||||
liboutput_plugins_a_SOURCES += \
|
||||
src/ntp_server.c src/ntp_server.h \
|
||||
src/rtsp_client.c src/rtsp_client.h \
|
||||
src/output/raop_output_plugin.c
|
||||
libmixer_plugins_a_SOURCES += src/mixer/raop_mixer_plugin.c
|
||||
OUTPUT_LIBS += $(OPENSSL_LIBS)
|
||||
endif
|
||||
|
||||
if HAVE_PULSE
|
||||
liboutput_plugins_a_SOURCES += \
|
||||
src/output/pulse_output_plugin.c src/output/pulse_output_plugin.h
|
||||
@ -992,7 +983,6 @@ noinst_PROGRAMS = \
|
||||
test/dump_playlist \
|
||||
test/run_decoder \
|
||||
test/read_tags \
|
||||
test/run_ntp_server \
|
||||
test/run_filter \
|
||||
test/run_output \
|
||||
test/run_convert \
|
||||
@ -1131,14 +1121,6 @@ test_dump_rva2_SOURCES = test/dump_rva2.c \
|
||||
src/tag_rva2.c
|
||||
endif
|
||||
|
||||
test_run_ntp_server_LDADD = \
|
||||
$(GLIB_LIBS)
|
||||
test_run_ntp_server_SOURCES = test/run_ntp_server.c \
|
||||
test/signals.c test/signals.h \
|
||||
src/io_thread.c src/io_thread.h \
|
||||
src/udp_server.c src/udp_server.h \
|
||||
src/ntp_server.c src/ntp_server.h
|
||||
|
||||
test_run_filter_LDADD = \
|
||||
$(FILTER_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
1
NEWS
1
NEWS
@ -24,7 +24,6 @@ ver 0.17 (2011/??/??)
|
||||
- openal: improve buffer cancellation
|
||||
- osx: allow user to specify other audio devices
|
||||
- osx: implement 32 bit playback
|
||||
- raop: new output plugin
|
||||
- shout: add possibility to set url
|
||||
- roar: new output plugin for RoarAudio
|
||||
- winmm: fail if wrong device specified instead of using default device
|
||||
|
18
configure.ac
18
configure.ac
@ -230,11 +230,6 @@ AC_ARG_ENABLE(httpd-output,
|
||||
[enables the HTTP server output]),,
|
||||
[enable_httpd_output=auto])
|
||||
|
||||
AC_ARG_ENABLE(raop-output,
|
||||
AS_HELP_STRING([--enable-raop-output],
|
||||
[enables the RAOP output]),,
|
||||
[enable_raop_output=auto])
|
||||
|
||||
AC_ARG_ENABLE(id3,
|
||||
AS_HELP_STRING([--enable-id3],
|
||||
[enable id3 support]),,
|
||||
@ -1428,17 +1423,6 @@ fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_SOLARIS_OUTPUT, test x$enable_solaris_output = xyes)
|
||||
|
||||
dnl --------------------------------- RAOP ------------------------------------
|
||||
|
||||
MPD_AUTO_PKG(raop_output, OPENSSL, [openssl],
|
||||
[RAOP output], [OpenSSL not found])
|
||||
|
||||
if test x$enable_raop_output = xyes; then
|
||||
AC_DEFINE(ENABLE_RAOP_OUTPUT, 1, [Define for compiling RAOP support])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_RAOP_OUTPUT, test x$enable_raop_output = xyes)
|
||||
|
||||
dnl --------------------------------- WinMM ---------------------------------
|
||||
|
||||
case "$host_os" in
|
||||
@ -1468,7 +1452,6 @@ 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 &&
|
||||
@ -1601,7 +1584,6 @@ results(osx, [OS X])
|
||||
results(pipe_output, [Pipeline])
|
||||
printf '\n\t'
|
||||
results(pulse, [PulseAudio])
|
||||
results(raop_output, [RAOP])
|
||||
results(roar,[ROAR])
|
||||
results(shout, [SHOUTcast])
|
||||
results(solaris_output, [Solaris])
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
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, GError **error_r)
|
||||
{
|
||||
struct raop_mixer_plugin *rm = (struct raop_mixer_plugin *)mixer;
|
||||
return raop_set_volume(rm->rd, volume, error_r);
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
@ -30,7 +30,6 @@ extern const struct mixer_plugin alsa_mixer_plugin;
|
||||
extern const struct mixer_plugin oss_mixer_plugin;
|
||||
extern const struct mixer_plugin roar_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
|
||||
|
131
src/ntp_server.c
131
src/ntp_server.c
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 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 "ntp_server.h"
|
||||
#include "udp_server.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Calculate the current NTP time, store it in the buffer.
|
||||
*/
|
||||
static void
|
||||
fill_int(unsigned char *buffer, uint32_t value)
|
||||
{
|
||||
uint32_t be = GINT32_TO_BE(value);
|
||||
memcpy(buffer, &be, sizeof(be));
|
||||
}
|
||||
|
||||
/*
|
||||
* Store time in the NTP format in the buffer
|
||||
*/
|
||||
static void
|
||||
fill_time_buffer_with_time(unsigned char *buffer, struct timeval *tout)
|
||||
{
|
||||
unsigned long secs_to_baseline = 964697997;
|
||||
double fraction;
|
||||
unsigned long long_fraction;
|
||||
unsigned long secs;
|
||||
|
||||
fraction = ((double) tout->tv_usec) / 1000000.0;
|
||||
long_fraction = (unsigned long) (fraction * 256.0 * 256.0 * 256.0 * 256.0);
|
||||
secs = secs_to_baseline + tout->tv_sec;
|
||||
fill_int(buffer, secs);
|
||||
fill_int(buffer + 4, long_fraction);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the current NTP time, store it in the buffer.
|
||||
*/
|
||||
static void
|
||||
fill_time_buffer(unsigned char *buffer)
|
||||
{
|
||||
struct timeval current_time;
|
||||
|
||||
gettimeofday(¤t_time,NULL);
|
||||
fill_time_buffer_with_time(buffer, ¤t_time);
|
||||
}
|
||||
|
||||
static void
|
||||
ntp_server_datagram(int fd, const void *data, size_t num_bytes,
|
||||
const struct sockaddr *source_address,
|
||||
size_t source_address_length, G_GNUC_UNUSED void *ctx)
|
||||
{
|
||||
unsigned char buf[32];
|
||||
int iter;
|
||||
|
||||
if (num_bytes > sizeof(buf))
|
||||
num_bytes = sizeof(buf);
|
||||
memcpy(buf, data, num_bytes);
|
||||
|
||||
fill_time_buffer(buf + 16);
|
||||
// set to response
|
||||
buf[1] = 0xd3;
|
||||
// copy request
|
||||
for (iter = 0; iter < 8; iter++) {
|
||||
buf[8 + iter] = buf[24 + iter];
|
||||
}
|
||||
fill_time_buffer(buf + 24);
|
||||
|
||||
sendto(fd, (void *)buf, num_bytes, 0,
|
||||
source_address, source_address_length);
|
||||
}
|
||||
|
||||
static const struct udp_server_handler ntp_server_handler = {
|
||||
.datagram = ntp_server_datagram,
|
||||
};
|
||||
|
||||
void
|
||||
ntp_server_init(struct ntp_server *ntp)
|
||||
{
|
||||
ntp->port = 6002;
|
||||
ntp->udp = NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
ntp_server_open(struct ntp_server *ntp, GError **error_r)
|
||||
{
|
||||
assert(ntp->udp == NULL);
|
||||
|
||||
ntp->udp = udp_server_new(ntp->port, &ntp_server_handler, ntp,
|
||||
error_r);
|
||||
return ntp->udp != NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ntp_server_close(struct ntp_server *ntp)
|
||||
{
|
||||
if (ntp->udp != NULL) {
|
||||
udp_server_free(ntp->udp);
|
||||
ntp->udp = NULL;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 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_NTP_SERVER_H
|
||||
#define MPD_NTP_SERVER_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct timeval;
|
||||
|
||||
struct ntp_server {
|
||||
unsigned short port;
|
||||
|
||||
struct udp_server *udp;
|
||||
};
|
||||
|
||||
void
|
||||
ntp_server_init(struct ntp_server *ntp);
|
||||
|
||||
bool
|
||||
ntp_server_open(struct ntp_server *ntp, GError **error_r);
|
||||
|
||||
void
|
||||
ntp_server_close(struct ntp_server *ntp);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 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_RAOP_OUTPUT_PLUGIN_H
|
||||
#define MPD_RAOP_OUTPUT_PLUGIN_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct raop_data;
|
||||
|
||||
extern const struct audio_output_plugin raop_output_plugin;
|
||||
|
||||
bool
|
||||
raop_set_volume(struct raop_data *rd, unsigned volume, GError **error_r);
|
||||
|
||||
int
|
||||
raop_get_volume(struct raop_data *rd);
|
||||
|
||||
#endif
|
@ -33,7 +33,6 @@
|
||||
#include "output/osx_output_plugin.h"
|
||||
#include "output/pipe_output_plugin.h"
|
||||
#include "output/pulse_output_plugin.h"
|
||||
#include "output/raop_output_plugin.h"
|
||||
#include "output/recorder_output_plugin.h"
|
||||
#include "output/roar_output_plugin.h"
|
||||
#include "output/shout_output_plugin.h"
|
||||
@ -69,9 +68,6 @@ const struct audio_output_plugin *audio_output_plugins[] = {
|
||||
#ifdef HAVE_OSX
|
||||
&osx_output_plugin,
|
||||
#endif
|
||||
#ifdef ENABLE_RAOP_OUTPUT
|
||||
&raop_output_plugin,
|
||||
#endif
|
||||
#ifdef ENABLE_SOLARIS_OUTPUT
|
||||
&solaris_output_plugin,
|
||||
#endif
|
||||
|
@ -1,732 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on the RTSP client by Shiro Ninomiya <shiron@snino.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "rtsp_client.h"
|
||||
#include "tcp_socket.h"
|
||||
#include "fd_util.h"
|
||||
#include "glib_compat.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Free all memory associated with key_data
|
||||
*/
|
||||
void
|
||||
free_kd(struct key_data *kd)
|
||||
{
|
||||
struct key_data *iter = kd;
|
||||
while (iter) {
|
||||
g_free(iter->key);
|
||||
g_free(iter->data);
|
||||
iter = iter->next;
|
||||
g_free(kd);
|
||||
kd = iter;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* key_data type data look up
|
||||
*/
|
||||
char *
|
||||
kd_lookup(struct key_data *kd, const char *key)
|
||||
{
|
||||
while (kd) {
|
||||
if (!strcmp(kd->key, key)) {
|
||||
return kd->data;
|
||||
}
|
||||
kd = kd->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct rtspcl_data *
|
||||
rtspcl_open(void)
|
||||
{
|
||||
struct rtspcl_data *rtspcld;
|
||||
rtspcld = g_new0(struct rtspcl_data, 1);
|
||||
rtspcld->mutex = g_mutex_new();
|
||||
rtspcld->cond = g_cond_new();
|
||||
rtspcld->received_lines = g_queue_new();
|
||||
rtspcld->useragent = "RTSPClient";
|
||||
return rtspcld;
|
||||
}
|
||||
|
||||
/* bind an opened socket to specified hostname and port.
|
||||
* if hostname=NULL, use INADDR_ANY.
|
||||
* if *port=0, use dynamically assigned port
|
||||
*/
|
||||
static int bind_host(int sd, char *hostname, unsigned long ulAddr,
|
||||
unsigned short *port, GError **error_r)
|
||||
{
|
||||
struct sockaddr_in my_addr;
|
||||
socklen_t nlen = sizeof(struct sockaddr);
|
||||
struct hostent *h;
|
||||
|
||||
memset(&my_addr, 0, sizeof(my_addr));
|
||||
/* use specified hostname */
|
||||
if (hostname) {
|
||||
/* get server IP address (no check if input is IP address or DNS name) */
|
||||
h = gethostbyname(hostname);
|
||||
if (h == NULL) {
|
||||
if (strstr(hostname, "255.255.255.255") == hostname) {
|
||||
my_addr.sin_addr.s_addr=-1;
|
||||
} else {
|
||||
if ((my_addr.sin_addr.s_addr = inet_addr(hostname)) == 0xFFFFFFFF) {
|
||||
g_set_error(error_r, rtsp_client_quark(), 0,
|
||||
"failed to resolve host '%s'",
|
||||
hostname);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
my_addr.sin_family = AF_INET;
|
||||
} else {
|
||||
my_addr.sin_family = h->h_addrtype;
|
||||
memcpy((char *) &my_addr.sin_addr.s_addr,
|
||||
h->h_addr_list[0], h->h_length);
|
||||
}
|
||||
} else {
|
||||
// if hostname=NULL, use INADDR_ANY
|
||||
if (ulAddr)
|
||||
my_addr.sin_addr.s_addr = ulAddr;
|
||||
else
|
||||
my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
my_addr.sin_family = AF_INET;
|
||||
}
|
||||
|
||||
/* bind a specified port */
|
||||
my_addr.sin_port = htons(*port);
|
||||
|
||||
if (bind(sd, (struct sockaddr *) &my_addr, sizeof(my_addr)) < 0) {
|
||||
g_set_error(error_r, rtsp_client_quark(), errno,
|
||||
"failed to bind socket: %s",
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*port == 0) {
|
||||
getsockname(sd, (struct sockaddr *) &my_addr, &nlen);
|
||||
*port = ntohs(my_addr.sin_port);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* open tcp port
|
||||
*/
|
||||
static int
|
||||
open_tcp_socket(char *hostname, unsigned short *port,
|
||||
GError **error_r)
|
||||
{
|
||||
int sd;
|
||||
|
||||
/* socket creation */
|
||||
sd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sd < 0) {
|
||||
g_set_error(error_r, rtsp_client_quark(), errno,
|
||||
"failed to create TCP socket: %s",
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (bind_host(sd, hostname, 0, port, error_r)) {
|
||||
close_socket(sd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sd;
|
||||
}
|
||||
|
||||
static bool
|
||||
get_sockaddr_by_host(const char *host, short destport,
|
||||
struct sockaddr_in *addr,
|
||||
GError **error_r)
|
||||
{
|
||||
struct hostent *h;
|
||||
|
||||
h = gethostbyname(host);
|
||||
if (h) {
|
||||
addr->sin_family = h->h_addrtype;
|
||||
memcpy((char *) &addr->sin_addr.s_addr, h->h_addr_list[0], h->h_length);
|
||||
} else {
|
||||
addr->sin_family = AF_INET;
|
||||
if ((addr->sin_addr.s_addr=inet_addr(host))==0xFFFFFFFF) {
|
||||
g_set_error(error_r, rtsp_client_quark(), 0,
|
||||
"failed to resolve host '%s'", host);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
addr->sin_port = htons(destport);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* create tcp connection
|
||||
* as long as the socket is not non-blocking, this can block the process
|
||||
* nsport is network byte order
|
||||
*/
|
||||
static bool
|
||||
get_tcp_connect(int sd, struct sockaddr_in dest_addr, GError **error_r)
|
||||
{
|
||||
if (connect(sd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr))){
|
||||
g_usleep(100000);
|
||||
// try one more time
|
||||
if (connect(sd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr))) {
|
||||
g_set_error(error_r, rtsp_client_quark(), errno,
|
||||
"failed to connect to %s:%d: %s",
|
||||
inet_ntoa(dest_addr.sin_addr),
|
||||
ntohs(dest_addr.sin_port),
|
||||
g_strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
get_tcp_connect_by_host(int sd, const char *host, short destport,
|
||||
GError **error_r)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
|
||||
return get_sockaddr_by_host(host, destport, &addr, error_r) &&
|
||||
get_tcp_connect(sd, addr, error_r);
|
||||
}
|
||||
|
||||
static void
|
||||
rtsp_client_flush_received(struct rtspcl_data *rtspcld)
|
||||
{
|
||||
char *line;
|
||||
while ((line = g_queue_pop_head(rtspcld->received_lines)) != NULL)
|
||||
g_free(line);
|
||||
}
|
||||
|
||||
static size_t
|
||||
rtsp_client_socket_data(const void *_data, size_t length, void *ctx)
|
||||
{
|
||||
struct rtspcl_data *rtspcld = ctx;
|
||||
|
||||
g_mutex_lock(rtspcld->mutex);
|
||||
|
||||
if (rtspcld->tcp_socket == NULL) {
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const bool was_empty = g_queue_is_empty(rtspcld->received_lines);
|
||||
bool added = false;
|
||||
const char *data = _data, *end = data + length, *p = data, *eol;
|
||||
while ((eol = memchr(p, '\n', end - p)) != NULL) {
|
||||
const char *next = eol + 1;
|
||||
|
||||
if (rtspcld->received_lines->length < 64) {
|
||||
if (eol > p && eol[-1] == '\r')
|
||||
--eol;
|
||||
|
||||
g_queue_push_tail(rtspcld->received_lines,
|
||||
g_strndup(p, eol - p));
|
||||
added = true;
|
||||
}
|
||||
|
||||
p = next;
|
||||
}
|
||||
|
||||
if (was_empty && added)
|
||||
g_cond_broadcast(rtspcld->cond);
|
||||
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
|
||||
return p - data;
|
||||
}
|
||||
|
||||
static void
|
||||
rtsp_client_socket_error(GError *error, void *ctx)
|
||||
{
|
||||
struct rtspcl_data *rtspcld = ctx;
|
||||
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
|
||||
g_mutex_lock(rtspcld->mutex);
|
||||
|
||||
rtsp_client_flush_received(rtspcld);
|
||||
|
||||
struct tcp_socket *s = rtspcld->tcp_socket;
|
||||
rtspcld->tcp_socket = NULL;
|
||||
|
||||
g_cond_broadcast(rtspcld->cond);
|
||||
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
|
||||
if (s != NULL)
|
||||
tcp_socket_free(s);
|
||||
}
|
||||
|
||||
static void
|
||||
rtsp_client_socket_disconnected(void *ctx)
|
||||
{
|
||||
struct rtspcl_data *rtspcld = ctx;
|
||||
|
||||
g_mutex_lock(rtspcld->mutex);
|
||||
|
||||
rtsp_client_flush_received(rtspcld);
|
||||
|
||||
struct tcp_socket *s = rtspcld->tcp_socket;
|
||||
rtspcld->tcp_socket = NULL;
|
||||
|
||||
g_cond_broadcast(rtspcld->cond);
|
||||
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
|
||||
if (s != NULL)
|
||||
tcp_socket_free(s);
|
||||
}
|
||||
|
||||
static const struct tcp_socket_handler rtsp_client_socket_handler = {
|
||||
.data = rtsp_client_socket_data,
|
||||
.error = rtsp_client_socket_error,
|
||||
.disconnected = rtsp_client_socket_disconnected,
|
||||
};
|
||||
|
||||
bool
|
||||
rtspcl_connect(struct rtspcl_data *rtspcld, const char *host, short destport,
|
||||
const char *sid, GError **error_r)
|
||||
{
|
||||
assert(rtspcld->tcp_socket == NULL);
|
||||
|
||||
unsigned short myport = 0;
|
||||
struct sockaddr_in name;
|
||||
socklen_t namelen = sizeof(name);
|
||||
|
||||
int fd = open_tcp_socket(NULL, &myport, error_r);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
|
||||
if (!get_tcp_connect_by_host(fd, host, destport, error_r))
|
||||
return false;
|
||||
|
||||
getsockname(fd, (struct sockaddr*)&name, &namelen);
|
||||
memcpy(&rtspcld->local_addr, &name.sin_addr,sizeof(struct in_addr));
|
||||
sprintf(rtspcld->url, "rtsp://%s/%s", inet_ntoa(name.sin_addr), sid);
|
||||
getpeername(fd, (struct sockaddr*)&name, &namelen);
|
||||
memcpy(&rtspcld->host_addr, &name.sin_addr, sizeof(struct in_addr));
|
||||
|
||||
rtspcld->tcp_socket = tcp_socket_new(fd, &rtsp_client_socket_handler,
|
||||
rtspcld);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
rtspcl_disconnect(struct rtspcl_data *rtspcld)
|
||||
{
|
||||
g_mutex_lock(rtspcld->mutex);
|
||||
rtsp_client_flush_received(rtspcld);
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
|
||||
if (rtspcld->tcp_socket != NULL) {
|
||||
tcp_socket_free(rtspcld->tcp_socket);
|
||||
rtspcld->tcp_socket = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rtspcl_remove_all_exthds(struct rtspcl_data *rtspcld)
|
||||
{
|
||||
free_kd(rtspcld->exthds);
|
||||
rtspcld->exthds = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
rtspcl_close(struct rtspcl_data *rtspcld)
|
||||
{
|
||||
rtspcl_disconnect(rtspcld);
|
||||
g_queue_free(rtspcld->received_lines);
|
||||
rtspcl_remove_all_exthds(rtspcld);
|
||||
g_free(rtspcld->session);
|
||||
g_cond_free(rtspcld->cond);
|
||||
g_mutex_free(rtspcld->mutex);
|
||||
g_free(rtspcld);
|
||||
}
|
||||
|
||||
void
|
||||
rtspcl_add_exthds(struct rtspcl_data *rtspcld, const char *key, char *data)
|
||||
{
|
||||
struct key_data *new_kd;
|
||||
new_kd = g_new(struct key_data, 1);
|
||||
new_kd->key = g_strdup(key);
|
||||
new_kd->data = g_strdup(data);
|
||||
new_kd->next = NULL;
|
||||
if (!rtspcld->exthds) {
|
||||
rtspcld->exthds = new_kd;
|
||||
} else {
|
||||
struct key_data *iter = rtspcld->exthds;
|
||||
while (iter->next) {
|
||||
iter = iter->next;
|
||||
}
|
||||
iter->next = new_kd;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* read one line from the file descriptor
|
||||
* timeout: msec unit, -1 for infinite
|
||||
* if CR comes then following LF is expected
|
||||
* returned string in line is always null terminated, maxlen-1 is maximum string length
|
||||
*/
|
||||
static int
|
||||
read_line(struct rtspcl_data *rtspcld, char *line, int maxlen,
|
||||
int timeout)
|
||||
{
|
||||
g_mutex_lock(rtspcld->mutex);
|
||||
|
||||
GTimeVal end_time;
|
||||
if (timeout >= 0) {
|
||||
g_get_current_time(&end_time);
|
||||
|
||||
end_time.tv_sec += timeout / 1000;
|
||||
timeout %= 1000;
|
||||
end_time.tv_usec = timeout * 1000;
|
||||
if (end_time.tv_usec > 1000000) {
|
||||
end_time.tv_usec -= 1000000;
|
||||
++end_time.tv_sec;
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (!g_queue_is_empty(rtspcld->received_lines)) {
|
||||
/* success, copy to buffer */
|
||||
|
||||
char *p = g_queue_pop_head(rtspcld->received_lines);
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
|
||||
g_strlcpy(line, p, maxlen);
|
||||
g_free(p);
|
||||
|
||||
return strlen(line);
|
||||
}
|
||||
|
||||
if (rtspcld->tcp_socket == NULL) {
|
||||
/* error */
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (timeout < 0) {
|
||||
g_cond_wait(rtspcld->cond, rtspcld->mutex);
|
||||
} else if (!g_cond_timed_wait(rtspcld->cond, rtspcld->mutex,
|
||||
&end_time)) {
|
||||
g_mutex_unlock(rtspcld->mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* send RTSP request, and get response if it's needed
|
||||
* if this gets a success, *kd is allocated or reallocated (if *kd is not NULL)
|
||||
*/
|
||||
bool
|
||||
exec_request(struct rtspcl_data *rtspcld, const char *cmd,
|
||||
const char *content_type, const char *content,
|
||||
int get_response,
|
||||
const struct key_data *hds, struct key_data **kd,
|
||||
GError **error_r)
|
||||
{
|
||||
char line[1024];
|
||||
char req[1024];
|
||||
char reql[128];
|
||||
const char delimiters[] = " ";
|
||||
char *token, *dp;
|
||||
int dsize = 0;
|
||||
int timeout = 5000; // msec unit
|
||||
|
||||
if (!rtspcld) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"not connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
sprintf(req, "%s %s RTSP/1.0\r\nCSeq: %d\r\n", cmd, rtspcld->url, ++rtspcld->cseq );
|
||||
|
||||
if ( rtspcld->session != NULL ) {
|
||||
sprintf(reql,"Session: %s\r\n", rtspcld->session );
|
||||
g_strlcat(req, reql, sizeof(req));
|
||||
}
|
||||
|
||||
const struct key_data *hd_iter = hds;
|
||||
while (hd_iter) {
|
||||
sprintf(reql, "%s: %s\r\n", hd_iter->key, hd_iter->data);
|
||||
g_strlcat(req, reql, sizeof(req));
|
||||
hd_iter = hd_iter->next;
|
||||
}
|
||||
|
||||
if (content_type && content) {
|
||||
sprintf(reql, "Content-Type: %s\r\nContent-Length: %d\r\n",
|
||||
content_type, (int) strlen(content));
|
||||
g_strlcat(req, reql, sizeof(req));
|
||||
}
|
||||
|
||||
sprintf(reql, "User-Agent: %s\r\n", rtspcld->useragent);
|
||||
g_strlcat(req, reql, sizeof(req));
|
||||
|
||||
hd_iter = rtspcld->exthds;
|
||||
while (hd_iter) {
|
||||
sprintf(reql, "%s: %s\r\n", hd_iter->key, hd_iter->data);
|
||||
g_strlcat(req, reql, sizeof(req));
|
||||
hd_iter = hd_iter->next;
|
||||
}
|
||||
g_strlcat(req, "\r\n", sizeof(req));
|
||||
|
||||
if (content_type && content)
|
||||
g_strlcat(req, content, sizeof(req));
|
||||
|
||||
if (!tcp_socket_send(rtspcld->tcp_socket, req, strlen(req))) {
|
||||
g_set_error(error_r, rtsp_client_quark(), errno,
|
||||
"write error: %s",
|
||||
g_strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!get_response) return true;
|
||||
|
||||
if (read_line(rtspcld, line, sizeof(line), timeout) <= 0) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"request failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
token = strtok(line, delimiters);
|
||||
token = strtok(NULL, delimiters);
|
||||
if (token == NULL) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"request failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(token, "200") != 0) {
|
||||
g_set_error(error_r, rtsp_client_quark(), 0,
|
||||
"request failed: %s", token);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if the caller isn't interested in response headers, put
|
||||
them on the trash, which is freed before returning from
|
||||
this function */
|
||||
struct key_data *trash = NULL;
|
||||
if (kd == NULL)
|
||||
kd = &trash;
|
||||
|
||||
struct key_data *cur_kd = *kd;
|
||||
|
||||
struct key_data *new_kd = NULL;
|
||||
while (read_line(rtspcld, line, sizeof(line), timeout) > 0) {
|
||||
timeout = 1000; // once it started, it shouldn't take a long time
|
||||
if (new_kd != NULL && line[0] == ' ') {
|
||||
const char *j = line;
|
||||
while (*j == ' ')
|
||||
++j;
|
||||
|
||||
dsize += strlen(j);
|
||||
new_kd->data = g_realloc(new_kd->data, dsize);
|
||||
strcat(new_kd->data, j);
|
||||
continue;
|
||||
}
|
||||
dp = strstr(line, ":");
|
||||
if (!dp) {
|
||||
free_kd(*kd);
|
||||
*kd = NULL;
|
||||
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"request failed, bad header");
|
||||
return false;
|
||||
}
|
||||
|
||||
*dp++ = 0;
|
||||
new_kd = g_new(struct key_data, 1);
|
||||
new_kd->key = g_strdup(line);
|
||||
dsize = strlen(dp) + 1;
|
||||
new_kd->data = g_strdup(dp);
|
||||
new_kd->next = NULL;
|
||||
if (cur_kd == NULL) {
|
||||
cur_kd = *kd = new_kd;
|
||||
} else {
|
||||
cur_kd->next = new_kd;
|
||||
cur_kd = new_kd;
|
||||
}
|
||||
}
|
||||
|
||||
free_kd(trash);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
rtspcl_set_parameter(struct rtspcl_data *rtspcld, const char *parameter,
|
||||
GError **error_r)
|
||||
{
|
||||
return exec_request(rtspcld, "SET_PARAMETER", "text/parameters",
|
||||
parameter, 1, NULL, NULL, error_r);
|
||||
}
|
||||
|
||||
void
|
||||
rtspcl_set_useragent(struct rtspcl_data *rtspcld, const char *name)
|
||||
{
|
||||
rtspcld->useragent = name;
|
||||
}
|
||||
|
||||
bool
|
||||
rtspcl_announce_sdp(struct rtspcl_data *rtspcld, const char *sdp,
|
||||
GError **error_r)
|
||||
{
|
||||
return exec_request(rtspcld, "ANNOUNCE", "application/sdp", sdp, 1,
|
||||
NULL, NULL, error_r);
|
||||
}
|
||||
|
||||
bool
|
||||
rtspcl_setup(struct rtspcl_data *rtspcld, struct key_data **kd,
|
||||
int control_port, int ntp_port,
|
||||
GError **error_r)
|
||||
{
|
||||
struct key_data *rkd = NULL, hds;
|
||||
const char delimiters[] = ";";
|
||||
char *buf = NULL;
|
||||
char *token, *pc;
|
||||
int rval = false;
|
||||
|
||||
static char transport_key[] = "Transport";
|
||||
|
||||
char transport_value[256];
|
||||
snprintf(transport_value, sizeof(transport_value),
|
||||
"RTP/AVP/UDP;unicast;interleaved=0-1;mode=record;control_port=%d;timing_port=%d",
|
||||
control_port, ntp_port);
|
||||
|
||||
hds.key = transport_key;
|
||||
hds.data = transport_value;
|
||||
hds.next = NULL;
|
||||
if (!exec_request(rtspcld, "SETUP", NULL, NULL, 1,
|
||||
&hds, &rkd, error_r))
|
||||
return false;
|
||||
|
||||
if (!(rtspcld->session = g_strdup(kd_lookup(rkd, "Session")))) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"no session in response");
|
||||
goto erexit;
|
||||
}
|
||||
if (!(rtspcld->transport = kd_lookup(rkd, "Transport"))) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"no transport in response");
|
||||
goto erexit;
|
||||
}
|
||||
buf = g_strdup(rtspcld->transport);
|
||||
token = strtok(buf, delimiters);
|
||||
rtspcld->server_port = 0;
|
||||
rtspcld->control_port = 0;
|
||||
while (token) {
|
||||
if ((pc = strstr(token, "="))) {
|
||||
*pc = 0;
|
||||
if (!strcmp(token,"server_port")) {
|
||||
rtspcld->server_port=atoi(pc + 1);
|
||||
}
|
||||
if (!strcmp(token,"control_port")) {
|
||||
rtspcld->control_port=atoi(pc + 1);
|
||||
}
|
||||
}
|
||||
token = strtok(NULL, delimiters);
|
||||
}
|
||||
if (rtspcld->server_port == 0) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"no server_port in response");
|
||||
goto erexit;
|
||||
}
|
||||
if (rtspcld->control_port == 0) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"no control_port in response");
|
||||
goto erexit;
|
||||
}
|
||||
rval = true;
|
||||
erexit:
|
||||
g_free(buf);
|
||||
|
||||
if (!rval || kd == NULL) {
|
||||
free_kd(rkd);
|
||||
rkd = NULL;
|
||||
}
|
||||
|
||||
if (kd != NULL)
|
||||
*kd = rkd;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool
|
||||
rtspcl_record(struct rtspcl_data *rtspcld,
|
||||
int seq_num, int rtptime,
|
||||
GError **error_r)
|
||||
{
|
||||
if (!rtspcld->session) {
|
||||
g_set_error_literal(error_r, rtsp_client_quark(), 0,
|
||||
"no session in progress");
|
||||
return false;
|
||||
}
|
||||
|
||||
char buf[128];
|
||||
sprintf(buf, "seq=%d,rtptime=%u", seq_num, rtptime);
|
||||
|
||||
struct key_data rtp;
|
||||
static char rtp_key[] = "RTP-Info";
|
||||
rtp.key = rtp_key;
|
||||
rtp.data = buf;
|
||||
rtp.next = NULL;
|
||||
|
||||
struct key_data range;
|
||||
static char range_key[] = "Range";
|
||||
range.key = range_key;
|
||||
static char range_value[] = "npt=0-";
|
||||
range.data = range_value;
|
||||
range.next = &rtp;
|
||||
|
||||
return exec_request(rtspcld, "RECORD", NULL, NULL, 1, &range,
|
||||
NULL, error_r);
|
||||
}
|
||||
|
||||
char *
|
||||
rtspcl_local_ip(struct rtspcl_data *rtspcld)
|
||||
{
|
||||
return inet_ntoa(rtspcld->local_addr);
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on the RTSP client by Shiro Ninomiya <shiron@snino.com>
|
||||
*/
|
||||
|
||||
#ifndef MPD_RTSP_CLIENT_H
|
||||
#define MPD_RTSP_CLIENT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
struct key_data {
|
||||
char *key;
|
||||
char *data;
|
||||
struct key_data *next;
|
||||
};
|
||||
|
||||
struct rtspcl_data {
|
||||
GMutex *mutex;
|
||||
GCond *cond;
|
||||
|
||||
GQueue *received_lines;
|
||||
|
||||
struct tcp_socket *tcp_socket;
|
||||
|
||||
char url[128];
|
||||
int cseq;
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* The quark used for GError.domain.
|
||||
*/
|
||||
static inline GQuark
|
||||
rtsp_client_quark(void)
|
||||
{
|
||||
return g_quark_from_static_string("rtsp_client");
|
||||
}
|
||||
|
||||
void
|
||||
free_kd(struct key_data *kd);
|
||||
|
||||
char *
|
||||
kd_lookup(struct key_data *kd, const char *key);
|
||||
|
||||
G_GNUC_MALLOC
|
||||
struct rtspcl_data *
|
||||
rtspcl_open(void);
|
||||
|
||||
bool
|
||||
rtspcl_connect(struct rtspcl_data *rtspcld, const char *host, short destport,
|
||||
const char *sid, GError **error_r);
|
||||
|
||||
void
|
||||
rtspcl_close(struct rtspcl_data *rtspcld);
|
||||
|
||||
void
|
||||
rtspcl_add_exthds(struct rtspcl_data *rtspcld, const char *key, char *data);
|
||||
|
||||
bool
|
||||
exec_request(struct rtspcl_data *rtspcld, const char *cmd,
|
||||
const char *content_type, const char *content,
|
||||
int get_response,
|
||||
const struct key_data *hds, struct key_data **kd,
|
||||
GError **error_r);
|
||||
|
||||
bool
|
||||
rtspcl_set_parameter(struct rtspcl_data *rtspcld, const char *parameter,
|
||||
GError **error_r);
|
||||
|
||||
void
|
||||
rtspcl_set_useragent(struct rtspcl_data *rtspcld, const char *name);
|
||||
|
||||
bool
|
||||
rtspcl_announce_sdp(struct rtspcl_data *rtspcld, const char *sdp,
|
||||
GError **error_r);
|
||||
|
||||
bool
|
||||
rtspcl_setup(struct rtspcl_data *rtspcld, struct key_data **kd,
|
||||
int control_port, int ntp_port,
|
||||
GError **error_r);
|
||||
|
||||
bool
|
||||
rtspcl_record(struct rtspcl_data *rtspcld,
|
||||
int seq_num, int rtptime,
|
||||
GError **error_r);
|
||||
|
||||
char *
|
||||
rtspcl_local_ip(struct rtspcl_data *rtspcld);
|
||||
|
||||
#endif
|
@ -83,25 +83,6 @@ roar_output_set_volume(G_GNUC_UNUSED struct roar *roar,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_RAOP_OUTPUT
|
||||
#include "output/raop_output_plugin.h"
|
||||
|
||||
bool
|
||||
raop_set_volume(G_GNUC_UNUSED struct raop_data *rd,
|
||||
G_GNUC_UNUSED unsigned volume,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
raop_get_volume(G_GNUC_UNUSED struct raop_data *rd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
event_pipe_emit(G_GNUC_UNUSED enum pipe_event event)
|
||||
{
|
||||
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 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 "config.h"
|
||||
#include "ntp_server.h"
|
||||
#include "signals.h"
|
||||
#include "io_thread.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
on_quit(void)
|
||||
{
|
||||
io_thread_quit();
|
||||
}
|
||||
|
||||
int
|
||||
main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
|
||||
{
|
||||
g_thread_init(NULL);
|
||||
signals_init();
|
||||
io_thread_init();
|
||||
|
||||
struct ntp_server ntp;
|
||||
ntp_server_init(&ntp);
|
||||
|
||||
GError *error = NULL;
|
||||
if (!ntp_server_open(&ntp, &error)) {
|
||||
io_thread_deinit();
|
||||
g_printerr("%s\n", error->message);
|
||||
g_error_free(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
io_thread_run();
|
||||
|
||||
ntp_server_close(&ntp);
|
||||
io_thread_deinit();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user