]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/standard.c
sout: constify format parameter to sout_stream_t.pf_add
[vlc] / modules / stream_out / standard.c
index 30d809a998052710dbdf45249c61ef5c672da764..c86adf910d4eb4ae825fa69c13808e4d6779180a 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * standard.c: standard stream output module
  *****************************************************************************
- * Copyright (C) 2003-2011 the VideoLAN team
+ * Copyright (C) 2003-2011 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -128,26 +128,20 @@ struct sout_stream_sys_t
     session_descriptor_t *p_session;
 };
 
-struct sout_stream_id_t
+static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
 {
-};
-
-static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
-{
-    return (sout_stream_id_t*)sout_MuxAddStream( p_stream->p_sys->p_mux, p_fmt );
+    return (sout_stream_id_sys_t*)sout_MuxAddStream( p_stream->p_sys->p_mux, p_fmt );
 }
 
-static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
+static void Del( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
 {
     sout_MuxDeleteStream( p_stream->p_sys->p_mux, (sout_input_t*)id );
-    return VLC_SUCCESS;
 }
 
-static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
+static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
                  block_t *p_buffer )
 {
-    sout_MuxSendBuffer( p_stream->p_sys->p_mux, (sout_input_t*)id, p_buffer );
-    return VLC_SUCCESS;
+    return sout_MuxSendBuffer( p_stream->p_sys->p_mux, (sout_input_t*)id, p_buffer );
 }
 static void create_SDP(sout_stream_t *p_stream, sout_access_out_t *p_access)
 {
@@ -293,24 +287,33 @@ static int fixAccessMux( sout_stream_t *p_stream, char **ppsz_mux,
     return 0;
 }
 
+static bool exactMatch( const char *psz_target, const char *psz_string,
+                        size_t i_len )
+{
+    if ( strncmp( psz_target, psz_string, i_len ) )
+        return false;
+    else
+        return ( psz_target[i_len] < 'a' || psz_target[i_len] > 'z' );
+}
+
 static void checkAccessMux( sout_stream_t *p_stream, char *psz_access,
                             char *psz_mux )
 {
-    if( !strncmp( psz_access, "mmsh", 4 ) && strncmp( psz_mux, "asfh", 4 ) )
+    if( exactMatch( psz_access, "mmsh", 4 ) && !exactMatch( psz_mux, "asfh", 4 ) )
         msg_Err( p_stream, "mmsh output is only valid with asfh mux" );
-    else if( strncmp( psz_access, "file", 4 ) &&
-            ( !strncmp( psz_mux, "mov", 3 ) || !strncmp( psz_mux, "mp4", 3 ) ) )
+    else if( !exactMatch( psz_access, "file", 4 ) &&
+             ( exactMatch( psz_mux, "mov", 3 ) || exactMatch( psz_mux, "mp4", 3 ) ) )
         msg_Err( p_stream, "mov and mp4 mux are only valid with file output" );
-    else if( !strncmp( psz_access, "udp", 3 ) )
+    else if( exactMatch( psz_access, "udp", 3 ) )
     {
-        if( !strncmp( psz_mux, "ffmpeg", 6 ) || !strncmp( psz_mux, "avformat", 8 ) )
+        if( exactMatch( psz_mux, "ffmpeg", 6 ) || exactMatch( psz_mux, "avformat", 8 ) )
         {   /* why would you use ffmpeg's ts muxer ? YOU DON'T LOVE VLC ??? */
             char *psz_ffmpeg_mux = var_CreateGetString( p_stream, "sout-avformat-mux" );
             if( !psz_ffmpeg_mux || strncmp( psz_ffmpeg_mux, "mpegts", 6 ) )
                 msg_Err( p_stream, "UDP output is only valid with TS mux" );
             free( psz_ffmpeg_mux );
         }
-        else if( strncmp( psz_mux, "ts", 2 ) )
+        else if( !exactMatch( psz_mux, "ts", 2 ) )
             msg_Err( p_stream, "UDP output is only valid with TS mux" );
     }
 }
@@ -333,14 +336,7 @@ static int Open( vlc_object_t *p_this )
 
     psz_access = var_GetNonEmptyString( p_stream, SOUT_CFG_PREFIX "access" );
     if( !psz_access )
-    {
-        if( !strcmp( p_stream->psz_name, "http" ) )
-            psz_access = strdup("http");
-        else if (!strcmp (p_stream->psz_name, "udp"))
-            psz_access = strdup("udp");
-        else if (!strcmp (p_stream->psz_name, "file"))
-            psz_access = strdup("file");
-    }
+        psz_access = strdup(p_stream->psz_name);
 
     psz_url = var_GetNonEmptyString( p_stream, SOUT_CFG_PREFIX "dst" );
     if (!psz_url)
@@ -406,12 +402,11 @@ static int Open( vlc_object_t *p_this )
     if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) )
         create_SDP( p_stream, p_access );
 
-    if( !sout_AccessOutCanControlPace( p_access ) )
-        p_stream->p_sout->i_out_pace_nocontrol++;
-
     p_stream->pf_add    = Add;
     p_stream->pf_del    = Del;
     p_stream->pf_send   = Send;
+    if( !sout_AccessOutCanControlPace( p_access ) )
+        p_stream->pace_nocontrol = true;
 
     ret = VLC_SUCCESS;
 
@@ -440,8 +435,6 @@ static void Close( vlc_object_t * p_this )
         sout_AnnounceUnRegister( p_stream, p_sys->p_session );
 
     sout_MuxDelete( p_sys->p_mux );
-    if( !sout_AccessOutCanControlPace( p_access ) )
-        p_stream->p_sout->i_out_pace_nocontrol--;
     sout_AccessOutDelete( p_access );
 
     free( p_sys );