From 8022e565810af61ffea436fcad8ef8085fc912aa Mon Sep 17 00:00:00 2001 From: Martin Blanchard Date: Sun, 6 Nov 2016 12:54:07 -0600 Subject: [PATCH] raop: Merge TCP and UDP code paths + refactoring TCP and UDP implementation are following two diffrent code path while code logic is quite the same. This patch merges both code path into a unique one and, thus, leads to a big refactoring. Major changes include: - moving sink implementation to a separate file (raop-sink.c) - move raop-sink.c protocol specific code to raop-client.c - modernise RTSP session handling in TCP mode - reduce code duplications between TCP and UDP modes - introduce authentication support - TCP mode does not constantly send silent audio anymore About authentication: OPTIONS is now issued when the sink is preliminary loaded. Client authentication appends at that time and credential is kept for the whole sink lifetime. Later RTSP connection will thus look like this: ANNOUNCE > 200 OK > SETUP > 200 OK > RECORD > 200 OK (no more OPTIONS). This behaviour is similar to iTunes one. Also this patch includes file name changes to match Pulseaudio naming rules, as most of pulseaudio source code files seem to be using '-' instead of '_' as a word separator. --- src/Makefile.am | 10 +- src/modules/raop/module-raop-sink.c | 986 +---------- src/modules/raop/raop-client.c | 1732 ++++++++++++++++++++ src/modules/raop/raop-client.h | 83 + src/modules/raop/{raop_crypto.c => raop-crypto.c} | 4 +- src/modules/raop/{raop_crypto.h => raop-crypto.h} | 0 .../{raop_packet_buffer.c => raop-packet-buffer.c} | 6 +- .../{raop_packet_buffer.h => raop-packet-buffer.h} | 0 src/modules/raop/raop-sink.c | 670 ++++++++ src/modules/raop/raop-sink.h | 33 + src/modules/raop/{raop_util.c => raop-util.c} | 2 +- src/modules/raop/{raop_util.h => raop-util.h} | 0 src/modules/raop/raop_client.c | 1722 ------------------- src/modules/raop/raop_client.h | 78 - src/modules/rtp/rtsp_client.c | 4 +- src/modules/rtp/rtsp_client.h | 10 +- 16 files changed, 2557 insertions(+), 2783 deletions(-) create mode 100644 src/modules/raop/raop-client.c create mode 100644 src/modules/raop/raop-client.h rename src/modules/raop/{raop_crypto.c => raop-crypto.c} (98%) rename src/modules/raop/{raop_crypto.h => raop-crypto.h} (100%) rename src/modules/raop/{raop_packet_buffer.c => raop-packet-buffer.c} (97%) rename src/modules/raop/{raop_packet_buffer.h => raop-packet-buffer.h} (100%) create mode 100644 src/modules/raop/raop-sink.c create mode 100644 src/modules/raop/raop-sink.h rename src/modules/raop/{raop_util.c => raop-util.c} (99%) rename src/modules/raop/{raop_util.h => raop-util.h} (100%) delete mode 100644 src/modules/raop/raop_client.c delete mode 100644 src/modules/raop/raop_client.h diff --git a/src/Makefile.am b/src/Makefile.am index c3ddc86..5b723e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1154,10 +1154,12 @@ librtp_la_LDFLAGS = $(AM_LDFLAGS) $(AM_LIBLDFLAGS) -avoid-version librtp_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la libraop_la_SOURCES = \ - modules/raop/raop_client.c modules/raop/raop_client.h \ - modules/raop/raop_packet_buffer.h modules/raop/raop_packet_buffer.c \ - modules/raop/raop_crypto.c modules/raop/raop_crypto.h \ - modules/raop/raop_util.c modules/raop/raop_util.h + modules/raop/raop-util.c modules/raop/raop-util.h \ + modules/raop/raop-crypto.c modules/raop/raop-crypto.h \ + modules/raop/raop-packet-buffer.h modules/raop/raop-packet-buffer.c \ + modules/raop/raop-client.c modules/raop/raop-client.h \ + modules/raop/raop-sink.c modules/raop/raop-sink.h + libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/modules/rtp libraop_la_LDFLAGS = $(AM_LDFLAGS) $(AM_LIBLDFLAGS) -avoid-version libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libpulsecore-@PA_MAJORMINOR@.la librtp.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c index e251f2f..82fa48d 100644 --- a/src/modules/raop/module-raop-sink.c +++ b/src/modules/raop/module-raop-sink.c @@ -22,107 +22,34 @@ #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_LINUX_SOCKIOS_H -#include -#endif - -#include -#include -#include - -#include -#include #include -#include +#include #include -#include -#include -#include -#include -#include -#include + +#include "raop-sink.h" #include "module-raop-sink-symdef.h" -#include "rtp.h" -#include "sdp.h" -#include "sap.h" -#include "raop_client.h" PA_MODULE_AUTHOR("Colin Guthrie"); PA_MODULE_DESCRIPTION("RAOP Sink"); PA_MODULE_VERSION(PACKAGE_VERSION); PA_MODULE_LOAD_ONCE(false); PA_MODULE_USAGE( + "name= " "sink_name= " "sink_properties= " - "server=
" + "server=
" "protocol= " "encryption= " "codec=