[vlc-devel] Rémi Denis-Courmont : Special case support --sout URL syntax for RTP demux.

git version control git at videolan.org
Sun Mar 2 09:48:46 CET 2008


Module: vlc
Branch: master
Commit: ac0f8aa5591e34646577220e8a25c2da230eeb39
URL:    http://git2.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac0f8aa5591e34646577220e8a25c2da230eeb39

Author: Rémi Denis-Courmont <rem at videolan.org>
Date:   Sat Mar  1 23:36:03 2008 +0200

Special case support --sout URL syntax for RTP demux.
This is meant so that this will still work:
$ vlc --sout rtp/ts://239.255.12.42

Also, these new constructs will work:
$ vlc --sout dccp/ts://[::]
$ vlc --sout udplite/ts://239.255.42.12

Signed-off-by: Rémi Denis-Courmont <rem at videolan.org>

---

 src/stream_output/stream_output.c |   48 ++++++++++++++++++++++++++----------
 1 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index c7da6fe..8489d87 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -52,7 +52,7 @@
  *****************************************************************************/
 #define sout_stream_url_to_chain( p, s ) \
     _sout_stream_url_to_chain( VLC_OBJECT(p), s )
-static char *_sout_stream_url_to_chain( vlc_object_t *, char * );
+static char *_sout_stream_url_to_chain( vlc_object_t *, const char * );
 
 /*
  * Generic MRL parser
@@ -859,29 +859,49 @@ void sout_StreamDelete( sout_stream_t *p_stream )
     vlc_object_release( p_stream );
 }
 
-static char *_sout_stream_url_to_chain( vlc_object_t *p_this, char *psz_url )
+static char *_sout_stream_url_to_chain( vlc_object_t *p_this,
+                                        const char *psz_url )
 {
     mrl_t       mrl;
-    char        *psz_chain, *p;
+    char        *psz_chain;
+    const char  *fmt = "standard{mux=\"%s\",access=\"%s\",dst=\"%s\"}";
+    static const char rtpfmt[] = "rtp{mux=\"%s\",proto=\"%s\",dst=\"%s\"}";
 
     mrl_Parse( &mrl, psz_url );
-    p = psz_chain = malloc( 500 + strlen( mrl.psz_way ) +
-                                  strlen( mrl.psz_access ) +
-                                  strlen( mrl.psz_name ) );
 
-
-    if( config_GetInt( p_this, "sout-display" ) )
+    /* Check if the URLs goes #rtp - otherwise we'll use #standard */
+    if (strcmp (mrl.psz_access, "rtp") == 0)
     {
-        p += sprintf( p, "duplicate{dst=display,dst=std{mux=\"%s\","
-                      "access=\"%s\",dst=\"%s\"}}",
-                      mrl.psz_way, mrl.psz_access, mrl.psz_name );
+        /* For historical reasons, rtp:// means RTP over UDP */
+        strcpy (mrl.psz_access, "udp");
+        fmt = rtpfmt;
     }
     else
     {
-        p += sprintf( p, "std{mux=\"%s\",access=\"%s\",dst=\"%s\"}",
-                      mrl.psz_way, mrl.psz_access, mrl.psz_name );
+        static const char list[] = "dccp\0sctp\0tcp\0udplite\0";
+        for (const char *a = list; *a; a += strlen (a) + 1)
+             if (strcmp (a, mrl.psz_access) == 0)
+             {
+                 fmt = rtpfmt;
+                 break;
+             }
+    }
+
+    /* Convert the URL to a basic sout chain */
+    if (asprintf (&psz_chain, fmt,
+                  mrl.psz_way, mrl.psz_access, mrl.psz_name) == -1)
+        psz_chain = NULL;
+
+    /* Duplicate and wrap if sout-display is on */
+    if (psz_chain && (config_GetInt( p_this, "sout-display" ) > 0))
+    {
+        char *tmp;
+        if (asprintf (&tmp, "duplicate{dst=display,dst=%s}", tmp) == -1)
+            tmp = NULL;
+        free (psz_chain);
+        psz_chain = tmp;
     }
 
     mrl_Clean( &mrl );
-    return( psz_chain );
+    return psz_chain;
 }




More information about the vlc-devel mailing list