[pulseaudio-discuss] [PATCH v6 06/37] rtp: New pa_rtsp_options function

Hajime Fujita crisp.fujita at gmail.com
Sun Jan 31 20:16:03 PST 2016


From: Colin Leroy <colin at colino.net>

Add a function performing a call to the OPTIONS request; also,
in some special cases, tuning transport parameters is required (default:
"RTP/AVP/TCP;unicast;interleaved=0-1;mode=record") ! The RAOP client for
example needs to overwrite them.
---
 src/modules/raop/raop_client.c |  6 +++++-
 src/modules/rtp/rtsp_client.c  | 23 +++++++++++++++++++++--
 src/modules/rtp/rtsp_client.h  |  4 +++-
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c
index 29c4f08..a5dd29c 100644
--- a/src/modules/raop/raop_client.c
+++ b/src/modules/raop/raop_client.c
@@ -281,10 +281,14 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist *he
             break;
         }
 
+        case STATE_OPTIONS:
+            pa_log_debug("RAOP: OPTIONS");
+            break;
+
         case STATE_ANNOUNCE:
             pa_log_debug("RAOP: ANNOUNCED");
             pa_rtsp_remove_header(c->rtsp, "Apple-Challenge");
-            pa_rtsp_setup(c->rtsp);
+            pa_rtsp_setup(c->rtsp, NULL);
             break;
 
         case STATE_SETUP: {
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 56f6e15..aa0217d 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -443,6 +443,22 @@ static int rtsp_exec(pa_rtsp_client *c, const char *cmd,
     return 0;
 }
 
+int pa_rtsp_options(pa_rtsp_client *c) {
+    char *url;
+    int rv;
+
+    pa_assert(c);
+
+    url = c->url;
+    c->state = STATE_OPTIONS;
+
+    c->url = (char *)"*";
+    rv = rtsp_exec(c, "OPTIONS", NULL, NULL, 0, NULL);
+
+    c->url = url;
+    return rv;
+}
+
 int pa_rtsp_announce(pa_rtsp_client *c, const char *sdp) {
     int rv;
 
@@ -457,14 +473,17 @@ int pa_rtsp_announce(pa_rtsp_client *c, const char *sdp) {
     return rv;
 }
 
-int pa_rtsp_setup(pa_rtsp_client *c) {
+int pa_rtsp_setup(pa_rtsp_client *c, const char *transport) {
     pa_headerlist *headers;
     int rv;
 
     pa_assert(c);
 
     headers = pa_headerlist_new();
-    pa_headerlist_puts(headers, "Transport", "RTP/AVP/TCP;unicast;interleaved=0-1;mode=record");
+    if (!transport)
+        pa_headerlist_puts(headers, "Transport", "RTP/AVP/TCP;unicast;interleaved=0-1;mode=record");
+    else
+        pa_headerlist_puts(headers, "Transport", transport);
 
     c->state = STATE_SETUP;
     rv = rtsp_exec(c, "SETUP", NULL, NULL, 1, headers);
diff --git a/src/modules/rtp/rtsp_client.h b/src/modules/rtp/rtsp_client.h
index d51acda..7e9978d 100644
--- a/src/modules/rtp/rtsp_client.h
+++ b/src/modules/rtp/rtsp_client.h
@@ -33,6 +33,7 @@
 typedef struct pa_rtsp_client pa_rtsp_client;
 typedef enum {
   STATE_CONNECT,
+  STATE_OPTIONS,
   STATE_ANNOUNCE,
   STATE_SETUP,
   STATE_RECORD,
@@ -57,9 +58,10 @@ void pa_rtsp_set_url(pa_rtsp_client *c, const char *url);
 void pa_rtsp_add_header(pa_rtsp_client *c, const char *key, const char *value);
 void pa_rtsp_remove_header(pa_rtsp_client *c, const char *key);
 
+int pa_rtsp_options(pa_rtsp_client *c);
 int pa_rtsp_announce(pa_rtsp_client *c, const char *sdp);
 
-int pa_rtsp_setup(pa_rtsp_client *c);
+int pa_rtsp_setup(pa_rtsp_client *c, const char *transport);
 int pa_rtsp_record(pa_rtsp_client *c, uint16_t *seq, uint32_t *rtptime);
 int pa_rtsp_teardown(pa_rtsp_client *c);
 
-- 
2.5.0



More information about the pulseaudio-discuss mailing list