From 1a1958cfba08314fc70e0b29309097f0509ee61e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Sun, 7 Apr 2013 21:37:41 +0300 Subject: [PATCH 01/16] Rename README to README.md and add a disclaimer --- README => README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) rename README => README.md (84%) diff --git a/README b/README.md similarity index 84% rename from README rename to README.md index bb06220..d8c7183 100644 --- a/README +++ b/README.md @@ -1,3 +1,14 @@ +Shairplay +========= +Free portable AirPlay server implementation. + +Disclaimer +---------- +All the resources in this repository are written using only freely available +information from the internet. The code and related resources are meant for +educational purposes only. It is up to the user to make sure all local laws are +adhered to. + Licenses -------- -- 2.34.1 From 2fa7773505d13b87edefd309d9a6564b473cd3b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Sun, 7 Apr 2013 21:44:40 +0300 Subject: [PATCH 02/16] Add a LICENSE file and cleanup README.md a bit --- LICENSE | 13 +++++++++++++ README.md | 18 ++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..763188f --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Following licenses apply: + +src/lib/alac/* - MIT License +src/lib/crypto/* - New BSD License +src/lib/http_parser.* - MIT License +src/lib/bindings/* - MIT License +src/lib/* - LGPLv2.1+ License +AirTV-Qt/* - LGPLv2.1+ License + +Also the following files are used, although not necessary: + +AirTV-Qt/qtsingleapplication/src/* - New BSD License + diff --git a/README.md b/README.md index d8c7183..e578bbe 100644 --- a/README.md +++ b/README.md @@ -9,21 +9,11 @@ information from the internet. The code and related resources are meant for educational purposes only. It is up to the user to make sure all local laws are adhered to. -Licenses --------- +Related software +---------------- -Following licenses apply: - -src/lib/alac/* - MIT License -src/lib/crypto/* - New BSD License -src/lib/http_parser.* - MIT License -src/lib/bindings/* - MIT License -src/lib/* - LGPLv2.1+ License -AirTV-Qt/* - LGPLv2.1+ License - -Also the following files are used, although not necessary: - -AirTV-Qt/qtsingleapplication/src/* - New BSD License +* [ShairPort](https://github.com/abrasive/shairport), original AirPort Express emulator +* [ALAC](http://craz.net/programs/itunes/alac.html), ALAC decoder by David Hammerton Description ----------- -- 2.34.1 From 61c2f5d5fa6f775ba9bee01788962cdae41c0b6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 11:47:17 +0300 Subject: [PATCH 03/16] Print error if dnssd library not available --- src/shairplay.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/shairplay.c b/src/shairplay.c index b125bbe..6ee23ba 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -233,6 +233,8 @@ main(int argc, char *argv[]) raop_t *raop; raop_callbacks_t raop_cbs; + int error; + memset(&options, 0, sizeof(options)); if (parse_options(&options, argc, argv)) { return 0; @@ -266,8 +268,20 @@ main(int argc, char *argv[]) raop_set_log_level(raop, RAOP_LOG_DEBUG); raop_start(raop, &options.port, hwaddr, sizeof(hwaddr), NULL); - dnssd = dnssd_init(NULL); + error = 0; + dnssd = dnssd_init(&error); + if (error) { + fprintf(stderr, "ERROR: Could not initialize dnssd library!\n"); + fprintf(stderr, "------------------------------------------\n"); + fprintf(stderr, "You could try the following resolutions based on your OS:\n"); + fprintf(stderr, "Windows: Try installing http://support.apple.com/kb/DL999\n"); + fprintf(stderr, "Debian/Ubuntu: Try installing libavahi-compat-libdnssd1 package\n"); + raop_destroy(raop); + return -1; + } + dnssd_register_raop(dnssd, options.apname, options.port, hwaddr, sizeof(hwaddr), 0); + dnssd_register_airplay(dnssd, options.apname, 1234, hwaddr, sizeof(hwaddr)); #ifndef WIN32 sleep(100); -- 2.34.1 From fb0fa0be72145b912cfeda38a94a2ccf7897394c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 11:54:39 +0300 Subject: [PATCH 04/16] Some clarifications in the README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e578bbe..5a0d70c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Shairplay ========= -Free portable AirPlay server implementation. +Free portable AirPlay server implementation similar to [ShairPort](https://github.com/abrasive/shairport). + +Currently only AirPort Express emulation is supported. Disclaimer ---------- @@ -20,6 +22,7 @@ Description Short description about what each file in the main library does: +``` src/lib/base64.* - base64 encoder/decoder src/lib/dnssd.* - dnssd helper functions src/lib/http_parser.* - HTTP parser from joyent (nginx fork) @@ -35,12 +38,15 @@ src/lib/rsakey.* - Decrypts and parses the RSA key to bigints src/lib/rsapem.* - Converts the RSA PEM key to DER encoded bytes src/lib/sdp.* - Extremely simple RAOP specific SDP parser src/lib/utils.* - Utils for reading a file and handling strings +``` Short description about what each file in the Qt application does: +``` AirTV-Qt/main.cpp - Initializes the application AirTV-Qt/mainapplication.cpp - Creates the tray icon and starts RAOP AirTV-Qt/raopservice.cpp - Handles all communication with the library AirTV-Qt/raopcallbackhandler.cpp - Converts C callbacks to Qt callbacks AirTV-Qt/audiooutput.cpp - Takes care of the actual audio output +``` -- 2.34.1 From d16f10bfe753ce41f9add2acb361f4283f737195 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 12:05:02 +0300 Subject: [PATCH 05/16] Add installation and usage instructions --- README.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5a0d70c..70fcde9 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,27 @@ Disclaimer ---------- All the resources in this repository are written using only freely available information from the internet. The code and related resources are meant for -educational purposes only. It is up to the user to make sure all local laws are -adhered to. +educational purposes only. It is the responsibility of the user to make sure +all local laws are adhered to. + +Installation +------------ + +``` +./configure +make +sudo make install +``` + +Notice that libao is required in order to install the shairplay binary, +otherwise only the library is compiled and installed. + +Usage +----- + +Check available options with ```shairplay --help``` and start server with +```shairplay```, if you are connected to a Wi-Fi the server should show as an +AirPort Express on your iOS devices and Mac OS X computers in the same network. Related software ---------------- -- 2.34.1 From 258e9fb821c5ee9b39628d1694e48d5518e28ac3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 12:29:19 +0300 Subject: [PATCH 06/16] Make shairplay not exit after 100 seconds --- src/shairplay.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shairplay.c b/src/shairplay.c index 6ee23ba..9cccf03 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -37,6 +37,9 @@ typedef struct { } shairplay_session_t; +static int running; + + static ao_device * audio_open_device(shairplay_options_t *opt, int bits, int channels, int samplerate) { @@ -283,11 +286,14 @@ main(int argc, char *argv[]) dnssd_register_raop(dnssd, options.apname, options.port, hwaddr, sizeof(hwaddr), 0); dnssd_register_airplay(dnssd, options.apname, 1234, hwaddr, sizeof(hwaddr)); + running = 1; + while (running) { #ifndef WIN32 - sleep(100); + sleep(1); #else - Sleep(100*1000); + Sleep(1000); #endif + } dnssd_unregister_raop(dnssd); dnssd_destroy(dnssd); -- 2.34.1 From 2c4250f147fa35b9adf48ea33067249f8d9cea25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 12:40:26 +0300 Subject: [PATCH 07/16] Add signal handlers to shairplay to make it shut down gracefully --- src/shairplay.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/shairplay.c b/src/shairplay.c index 9cccf03..09210bf 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -6,7 +6,7 @@ #include #ifdef WIN32 -#include +# include #endif #include @@ -39,6 +39,33 @@ typedef struct { static int running; +#ifndef WIN32 + +#include +static void +signal_handler(int sig) +{ + switch (sig) { + case SIGINT: + case SIGTERM: + running = 0; + break; + } +} +static void +init_signals(void) +{ + struct sigaction sigact; + + sigact.sa_handler = signal_handler; + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGTERM, &sigact, NULL); +} + +#endif + static ao_device * audio_open_device(shairplay_options_t *opt, int bits, int channels, int samplerate) @@ -238,6 +265,10 @@ main(int argc, char *argv[]) int error; +#ifndef WIN32 + init_signals(); +#endif + memset(&options, 0, sizeof(options)); if (parse_options(&options, argc, argv)) { return 0; -- 2.34.1 From 5d98fafe59a4b2795bc3507fa0ddf7f2511b9a9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 12:51:59 +0300 Subject: [PATCH 08/16] Add supported flags to the README --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 70fcde9..66ec140 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,23 @@ otherwise only the library is compiled and installed. Usage ----- -Check available options with ```shairplay --help``` and start server with -```shairplay```, if you are connected to a Wi-Fi the server should show as an -AirPort Express on your iOS devices and Mac OS X computers in the same network. +Check available options with ```shairplay --help```: + +``` +Usage: shairplay [OPTION...] + + -a, --apname=AirPort Sets Airport name + -p, --password=secret Sets password + -o, --server_port=5000 Sets port for RAOP service + --ao_driver=driver Sets the ao driver (optional) + --ao_devicename=devicename Sets the ao device name (optional) + --ao_deviceid=id Sets the ao device id (optional) + -h, --help This help +``` + +Start the server with ```shairplay```, if you are connected to a Wi-Fi the +server should show as an AirPort Express on your iOS devices and Mac OS X +computers in the same network. Related software ---------------- -- 2.34.1 From 26af58b3727b665464481ce9a7fb7a53ddd71f0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Tue, 9 Apr 2013 14:22:11 +0300 Subject: [PATCH 09/16] Remove dnssd_register_airplay that was accidentally added --- src/shairplay.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/shairplay.c b/src/shairplay.c index 09210bf..22be17d 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -315,7 +315,6 @@ main(int argc, char *argv[]) } dnssd_register_raop(dnssd, options.apname, options.port, hwaddr, sizeof(hwaddr), 0); - dnssd_register_airplay(dnssd, options.apname, 1234, hwaddr, sizeof(hwaddr)); running = 1; while (running) { -- 2.34.1 From f95c4d2da37b73c2010b4332831cb1f582314b6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20V=C3=A4h=C3=A4-Herttua?= Date: Tue, 9 Apr 2013 22:50:23 +0300 Subject: [PATCH 10/16] Change the Ubuntu libdns_sd package name to be correct --- src/shairplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shairplay.c b/src/shairplay.c index 22be17d..64cc864 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -309,7 +309,7 @@ main(int argc, char *argv[]) fprintf(stderr, "------------------------------------------\n"); fprintf(stderr, "You could try the following resolutions based on your OS:\n"); fprintf(stderr, "Windows: Try installing http://support.apple.com/kb/DL999\n"); - fprintf(stderr, "Debian/Ubuntu: Try installing libavahi-compat-libdnssd1 package\n"); + fprintf(stderr, "Debian/Ubuntu: Try installing libavahi-compat-libdnssd-dev package\n"); raop_destroy(raop); return -1; } -- 2.34.1 From ad16b2df67b966a39e250e86acc0e246c28510e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20V=C3=A4h=C3=A4-Herttua?= Date: Tue, 9 Apr 2013 23:18:09 +0300 Subject: [PATCH 11/16] Add indentation to src/Makefile.am --- src/Makefile.am | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index e9428d1..3672969 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,12 +3,12 @@ SUBDIRS = lib AM_CPPFLAGS = -I$(top_srcdir)/include if USE_LIBAO -bin_PROGRAMS = shairplay -shairplay_SOURCES = shairplay.c -shairplay_LDADD = lib/libshairplay.la -shairplay_CFLAGS = -shairplay_LDFLAGS = -static-libtool-libs + bin_PROGRAMS = shairplay + shairplay_SOURCES = shairplay.c + shairplay_LDADD = lib/libshairplay.la + shairplay_CFLAGS = + shairplay_LDFLAGS = -static-libtool-libs -shairplay_CFLAGS += $(libao_CFLAGS) -shairplay_LDADD += $(libao_LIBS) + shairplay_CFLAGS += $(libao_CFLAGS) + shairplay_LDADD += $(libao_LIBS) endif -- 2.34.1 From 668e175b7b1a9e0c8afdc4e01ddbc9c7ac96fdd2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20V=C3=A4h=C3=A4-Herttua?= Date: Wed, 10 Apr 2013 01:06:08 +0300 Subject: [PATCH 12/16] Update licensing information --- LICENSE | 3 ++- src/shairplay.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 763188f..0f0c8eb 100644 --- a/LICENSE +++ b/LICENSE @@ -3,8 +3,9 @@ Following licenses apply: src/lib/alac/* - MIT License src/lib/crypto/* - New BSD License src/lib/http_parser.* - MIT License -src/lib/bindings/* - MIT License src/lib/* - LGPLv2.1+ License +src/bindings/* - MIT License +src/* - MIT License AirTV-Qt/* - LGPLv2.1+ License Also the following files are used, although not necessary: diff --git a/src/shairplay.c b/src/shairplay.c index 64cc864..691b24f 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -1,3 +1,26 @@ +/** + * Copyright (C) 2012-2013 Juho Vähä-Herttua + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + #include #include #include -- 2.34.1 From b1df60b553e2f6f944216d5d94b39a25109d17f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20V=C3=A4h=C3=A4-Herttua?= Date: Wed, 10 Apr 2013 19:19:09 +0300 Subject: [PATCH 13/16] Clean up the autotools scripts a bit --- configure.ac | 4 ++-- src/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4822373..94a1bbd 100644 --- a/configure.ac +++ b/configure.ac @@ -67,8 +67,8 @@ AM_CONDITIONAL([OS_GNU],[test "$os_gnu" = "yes"]) AM_CONDITIONAL([OS_FREEBSD],[test "$os_freebsd" = "yes"]) # Custom check for libao -PKG_CHECK_MODULES([libao], [ao >= 1.1.0], [HAVE_LIBAO=1], [HAVE_LIBAO=0]) -AM_CONDITIONAL([USE_LIBAO], [test "$HAVE_LIBAO" -eq 1]) +PKG_CHECK_MODULES([libao], [ao >= 1.1.0], [have_libao=1], [have_libao=0]) +AM_CONDITIONAL([HAVE_LIBAO], [test "$have_libao" -eq 1]) diff --git a/src/Makefile.am b/src/Makefile.am index 3672969..3697bbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = lib AM_CPPFLAGS = -I$(top_srcdir)/include -if USE_LIBAO +if HAVE_LIBAO bin_PROGRAMS = shairplay shairplay_SOURCES = shairplay.c shairplay_LDADD = lib/libshairplay.la -- 2.34.1 From c6e5e8b92e81690133d2f51237fb90c1668bd146 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Sun, 14 Apr 2013 21:58:26 +0300 Subject: [PATCH 14/16] Make the password option work on shairplay CLI --- src/shairplay.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shairplay.c b/src/shairplay.c index 691b24f..bf269ef 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -285,6 +285,7 @@ main(int argc, char *argv[]) dnssd_t *dnssd; raop_t *raop; raop_callbacks_t raop_cbs; + char *password = NULL; int error; @@ -322,8 +323,11 @@ main(int argc, char *argv[]) return -1; } + if (strlen(options.password)) { + password = options.password; + } raop_set_log_level(raop, RAOP_LOG_DEBUG); - raop_start(raop, &options.port, hwaddr, sizeof(hwaddr), NULL); + raop_start(raop, &options.port, hwaddr, sizeof(hwaddr), password); error = 0; dnssd = dnssd_init(&error); -- 2.34.1 From 093f6e0042a9e1d673052d7dbf35508c3f305bb6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Sun, 14 Apr 2013 22:04:21 +0300 Subject: [PATCH 15/16] Remove some redundant code from shairplay CLI --- src/shairplay.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/shairplay.c b/src/shairplay.c index bf269ef..9bb9537 100644 --- a/src/shairplay.c +++ b/src/shairplay.c @@ -226,7 +226,8 @@ parse_options(shairplay_options_t *opt, int argc, char *argv[]) char *path = argv[0]; char *arg; - strcpy(opt->apname, "Shairplay"); + /* Set default values for apname and port */ + strncpy(opt->apname, "Shairplay", sizeof(opt->apname)-1); opt->port = 5000; while ((arg = *++argv)) { @@ -264,13 +265,6 @@ parse_options(shairplay_options_t *opt, int argc, char *argv[]) } } - /* Set default values for apname and port */ - if (!strlen(opt->apname)) { - strncpy(opt->apname, "Shairplay", sizeof(opt->apname)-1); - } - if (!opt->port) { - opt->port = 5000; - } return 0; } -- 2.34.1 From 88631dc4d381e81cca5e7b627ebc5d56b6827537 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20Va=CC=88ha=CC=88-Herttua?= Date: Sun, 14 Apr 2013 22:05:31 +0300 Subject: [PATCH 16/16] Add some more logging to authentication --- src/lib/raop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/raop.c b/src/lib/raop.c index f3cc399..e5c6539 100644 --- a/src/lib/raop.c +++ b/src/lib/raop.c @@ -167,8 +167,9 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) res = http_response_init("RTSP/1.0", 401, "Unauthorized"); http_response_add_header(res, "WWW-Authenticate", authstr); free(authstr); + logger_log(conn->raop->logger, LOGGER_DEBUG, "Authentication unsuccessful, sending Unauthorized"); } else { - logger_log(conn->raop->logger, LOGGER_DEBUG, "AUTHENTICATION SUCCESS!"); + logger_log(conn->raop->logger, LOGGER_DEBUG, "Authentication successful!"); } } -- 2.34.1