[pulseaudio-discuss] [PATCH] Add configurable RTP stream name

Ing. Jaroslav Safka devel at safka.org
Thu Jun 28 14:08:45 UTC 2018


Path add configuration option 'stream_name' for stream/session name
So user will see it on receiver side as RTP Strean ($stream_name)

ex: load-module module-rtp-send source=rtp.monitor stream_name=MyServerMedia
---
 src/modules/rtp/module-rtp-send.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c
index 61900c01..a65f1ba3 100644
--- a/src/modules/rtp/module-rtp-send.c
+++ b/src/modules/rtp/module-rtp-send.c
@@ -66,6 +66,7 @@ PA_MODULE_USAGE(
         "loop=<loopback to local host?> "
         "ttl=<ttl value> "
         "inhibit_auto_suspend=<always|never|only_with_non_monitor_sources>"
+        "stream_name=<name of the stream>"
 );
 
 #define DEFAULT_PORT 46000
@@ -90,6 +91,7 @@ static const char* const valid_modargs[] = {
     "loop",
     "ttl",
     "inhibit_auto_suspend",
+    "stream_name",
     NULL
 };
 
@@ -229,6 +231,7 @@ int pa__init(pa_module*m) {
     bool loop = false;
     enum inhibit_auto_suspend inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_ONLY_WITH_NON_MONITOR_SOURCES;
     const char *inhibit_auto_suspend_str;
+    const char *stream_name = NULL;
     pa_source_output_new_data data;
 
     pa_assert(m);
@@ -261,6 +264,8 @@ int pa__init(pa_module*m) {
         }
     }
 
+    stream_name = pa_modargs_get_value(ma, "stream_name", NULL);
+
     ss = s->sample_spec;
     pa_rtp_sample_spec_fixup(&ss);
     cm = s->channel_map;
@@ -469,23 +474,27 @@ int pa__init(pa_module*m) {
     k = sizeof(sa_dst);
     pa_assert_se((r = getsockname(fd, (struct sockaddr*) &sa_dst, &k)) >= 0);
 
-    n = pa_sprintf_malloc("PulseAudio RTP Stream on %s", pa_get_fqdn(hn, sizeof(hn)));
+    n = NULL;
+    if(stream_name == NULL) {
+        n = pa_sprintf_malloc("PulseAudio RTP Stream on %s", pa_get_fqdn(hn, sizeof(hn)));
+        stream_name = n;
+    }
 
     if (af == AF_INET) {
         p = pa_sdp_build(af,
                      (void*) &((struct sockaddr_in*) &sa_dst)->sin_addr,
                      (void*) &dst_sa4.sin_addr,
-                     n, (uint16_t) port, payload, &ss);
+                     stream_name, (uint16_t) port, payload, &ss);
 #ifdef HAVE_IPV6
     } else {
         p = pa_sdp_build(af,
                      (void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr,
                      (void*) &dst_sa6.sin6_addr,
-                     n, (uint16_t) port, payload, &ss);
+                     stream_name, (uint16_t) port, payload, &ss);
 #endif
     }
 
-    pa_xfree(n);
+    pa_xfree(n); /* safe for NULL */
 
     pa_rtp_context_init_send(&u->rtp_context, fd, m->core->cookie, payload, pa_frame_size(&ss));
     pa_sap_context_init_send(&u->sap_context, sap_fd, p);
-- 
2.18.0



More information about the pulseaudio-discuss mailing list