]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/standard.c
Cosmetics
[vlc] / modules / stream_out / standard.c
index 4e39c777570e2f8e89f1710ffc3a2b72d662a30b..33acabad7db97e6c745a51b15585b7b6b20b4faf 100644 (file)
@@ -27,9 +27,6 @@
 #include <vlc/vlc.h>
 #include <vlc_sout.h>
 
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
 
 #include <vlc_network.h>
 #include "vlc_url.h"
@@ -182,7 +179,7 @@ static int Open( vlc_object_t *p_this )
     if( psz_url && strrchr( psz_url, '.' ) )
     {
         /* by extension */
-        static struct { const char *ext; const char *mux; } exttomux[] =
+        static struct { const char ext[6]; const char mux[16]; } exttomux[] =
         {
             { "avi", "avi" },
             { "ogg", "ogg" },
@@ -199,15 +196,15 @@ static int Open( vlc_object_t *p_this )
             { "mpeg","ps" },
             { "ps",  "ps" },
             { "mpeg1","mpeg1" },
-            { "wav","wav" },
+            { "wav", "wav" },
             { "flv", "ffmpeg{mux=flv}" },
-            { NULL,  NULL }
+            { "",    "" }
         };
         const char *psz_ext = strrchr( psz_url, '.' ) + 1;
         int  i;
 
         msg_Dbg( p_this, "extension is %s", psz_ext );
-        for( i = 0; exttomux[i].ext != NULL; i++ )
+        for( i = 0; exttomux[i].ext[0]; i++ )
         {
             if( !strcasecmp( psz_ext, exttomux[i].ext ) )
             {
@@ -245,9 +242,7 @@ static int Open( vlc_object_t *p_this )
             psz_mux = strdup("asfh");
         }
         else if (!strcmp (psz_access, "udp")
-              || !strcmp (psz_access, "rtp") || !strcmp (psz_access, "udplite")
-              || !strcmp (psz_access, "tcp") || !strcmp (psz_access, "sctp")
-              || !strcmp (psz_access, "dccp"))
+              || !strcmp (psz_access, "rtp"))
         {
             psz_mux = strdup("ts");
         }
@@ -276,38 +271,37 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* fix or warn of incompatible couple */
-    if( psz_mux && psz_access )
+    if( !strncmp( psz_access, "mmsh", 4 ) &&
+        strncmp( psz_mux, "asfh", 4 ) )
     {
-        if( !strncmp( psz_access, "mmsh", 4 ) &&
-            strncmp( psz_mux, "asfh", 4 ) )
-        {
-            char *p = strchr( psz_mux,'{' );
+        char *p = strchr( psz_mux,'{' );
 
-            msg_Warn( p_stream, "fixing to mmsh/asfh" );
-            if( p )
-            {
-                /* -> a little memleak but ... */
-                psz_mux = malloc( strlen( "asfh" ) + strlen( p ) + 1);
-                sprintf( psz_mux, "asfh%s", p );
-            }
-            else
-            {
-                psz_mux = strdup("asfh");
-            }
-        }
-        else if( ( !strncmp( psz_access, "rtp", 3 ) ||
-                   !strncmp( psz_access, "udp", 3 ) ) &&
-                 strncmp( psz_mux, "ts", 2 ) )
+        msg_Warn( p_stream, "fixing to mmsh/asfh" );
+        if( p )
         {
-            msg_Err( p_stream, "for now udp and rtp are only valid with TS" );
+            if( asprintf( &p, "asfh%s", p ) == -1 )
+                p = NULL;
+            free( psz_mux );
+            psz_mux = p;
         }
-        else if( strncmp( psz_access, "file", 4 ) &&
-                 ( !strncmp( psz_mux, "mov", 3 ) ||
-                   !strncmp( psz_mux, "mp4", 3 ) ) )
+        else
         {
-            msg_Err( p_stream, "mov and mp4 work only with file output" );
+            free( psz_mux );
+            psz_mux = strdup("asfh");
         }
     }
+    else if( ( !strncmp( psz_access, "rtp", 3 ) ||
+               !strncmp( psz_access, "udp", 3 ) ) &&
+             strncmp( psz_mux, "ts", 2 ) )
+    {
+        msg_Err( p_stream, "UDP and RTP are only valid with TS" );
+    }
+    else if( strncmp( psz_access, "file", 4 ) &&
+             ( !strncmp( psz_mux, "mov", 3 ) ||
+               !strncmp( psz_mux, "mp4", 3 ) ) )
+    {
+        msg_Err( p_stream, "mov and mp4 work only with file output" );
+    }
 
     msg_Dbg( p_this, "using `%s/%s://%s'", psz_access, psz_mux, psz_url );
 
@@ -317,8 +311,8 @@ static int Open( vlc_object_t *p_this )
     {
         msg_Err( p_stream, "no suitable sout access module for `%s/%s://%s'",
                  psz_access, psz_mux, psz_url );
-        if( psz_access ) free( psz_access );
-        if( psz_mux ) free( psz_mux );
+        free( psz_access );
+        free( psz_mux );
         return VLC_EGENERIC;
     }
     msg_Dbg( p_stream, "access opened" );
@@ -331,8 +325,8 @@ static int Open( vlc_object_t *p_this )
                  psz_access, psz_mux, psz_url );
 
         sout_AccessOutDelete( p_access );
-        if( psz_access ) free( psz_access );
-        if( psz_mux ) free( psz_mux );
+        free( psz_access );
+        free( psz_mux );
         return VLC_EGENERIC;
     }
     msg_Dbg( p_stream, "mux opened" );
@@ -342,37 +336,22 @@ static int Open( vlc_object_t *p_this )
     {
         session_descriptor_t *p_session;
         announce_method_t *p_method = sout_SAPMethod ();
-        const int payload_type = 33;
 
         static const struct { const char *access; const char *fmt; } fmts[] =
             {
-                /* TLS/DTLS variants (none implemented): */
-                { "dtlslite", "UDPLite/TLS/RTP/AVP %d" },
-                { "dtls",     "UDP/TLS/RTP/AVP %d" },
-                { "dccps",    "DCCP/TLS/RTP/AVP %d" },
-                { "tls",      "TCP/TLS/RTP/AVP %d" },
                 /* Plain text: */
-                { "udplite",  "UDPLite/RTP/AVP %d" },
                 { "udp",      "udp mpeg" },
-                { "rtp",      "RTP/AVP %d" },
-                /* Currently unsupported access outputs: */
-                { "dccp",     "DCCP/RTP/AVP %d" },
-                { "tcp",      "TCP/RTP/AVP %d" },
-                /* SRTP (none implemented): */
-                { "srtp",     "RTP/SAVP %d" },
-                { "sudplite", "UDPLite/RTP/SAVP %d" },
-                { "sdccp",    "DCCP/RTP/SAVP %d" },
-                { "stcp",     "TCP/RTP/SAVP %d" },
+                { "rtp",      "RTP/AVP 33" },
                 { NULL,       NULL }
             };
-        const char *psz_sdp_fmt = NULL;
-        char *fmt, *src, *dst;
+        const char *fmt = NULL;
+        char *src, *dst;
         int sport, dport;
 
         for (unsigned i = 0; fmts[i].access != NULL; i++)
             if (strncasecmp (fmts[i].access, psz_access, strlen (fmts[i].access)) == 0)
             {
-                psz_sdp_fmt = fmts[i].fmt;
+                fmt = fmts[i].fmt;
                 break;
             }
 
@@ -381,10 +360,6 @@ static int Open( vlc_object_t *p_this )
         sport = var_GetInteger (p_access, "src-port");
         dport = var_GetInteger (p_access, "dst-port");
 
-        if ((psz_sdp_fmt == NULL)
-         || (asprintf (&fmt, psz_sdp_fmt, payload_type) == -1))
-            fmt = NULL;
-
         msg_Dbg( p_stream, "SAP advertized format: %s", fmt);
         if ((fmt == NULL) || ((src == NULL) && (dst == NULL)))
         {
@@ -402,7 +377,6 @@ static int Open( vlc_object_t *p_this )
         sout_MethodRelease (p_method);
 
 nosap:
-        free (fmt);
         free (src);
         free (dst);
     }
@@ -413,10 +387,9 @@ nosap:
 
     p_stream->p_sys->p_mux = p_mux;
 
-    if( psz_access ) free( psz_access );
-    if( psz_mux ) free( psz_mux );
-    if( psz_url ) free( psz_url );
-
+    free( psz_access );
+    free( psz_mux );
+    free( psz_url );
 
     return VLC_SUCCESS;
 }