]> git.sesse.net Git - vlc/blobdiff - modules/demux/nsv.c
Initial support for Secure Real-Time Protocol (RFC3711) - refs #321
[vlc] / modules / demux / nsv.c
index 63366b8fe67408b1919a12a21afccdb35133f6ce..3e80d2352fca57b7072c08f1d8eee6cc535348a2 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * nsv.c: NullSoft Video demuxer.
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN
- * $Id: nsv.c,v 1.9 2004/02/15 16:59:18 fenrir Exp $
+ * Copyright (C) 2004 the VideoLAN team
+ * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -18,7 +18,7 @@
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -27,7 +27,7 @@
 #include <stdlib.h>                                      /* malloc(), free() */
 
 #include <vlc/vlc.h>
-#include <vlc/input.h>
+#include <vlc_demux.h>
 
 /* TODO:
  *  - implement NSVf parsing (to get meta data)
@@ -44,6 +44,8 @@ static void Close  ( vlc_object_t * );
 vlc_module_begin();
     set_description( _("NullSoft demuxer" ) );
     set_capability( "demux2", 10 );
+    set_category( CAT_INPUT );
+    set_subcategory( SUBCAT_INPUT_DEMUX );
     set_callbacks( Open, Close );
     add_shortcut( "nsv" );
 vlc_module_end();
@@ -85,19 +87,16 @@ static int Open( vlc_object_t *p_this )
     demux_sys_t *p_sys;
 
     uint8_t     *p_peek;
-    int         i;
 
     if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
-    {
-        msg_Err( p_demux, "cannot peek" );
         return VLC_EGENERIC;
-    }
-    if( strncmp( p_peek, "NSVf", 4 ) && strncmp( p_peek, "NSVs", 4 ))
+
+    if( strncmp( (char *)p_peek, "NSVf", 4 )
+            && strncmp( (char *)p_peek, "NSVs", 4 ))
     {
        /* In case we had force this demuxer we try to resynch */
         if( strcmp( p_demux->psz_demux, "nsv" ) || ReSynch( p_demux ) )
         {
-            msg_Warn( p_demux, "NSV module discarded" );
             return VLC_EGENERIC;
         }
     }
@@ -156,14 +155,14 @@ static int Demux( demux_t *p_demux )
             return 0;
         }
 
-        if( !strncmp( p_peek, "NSVf", 4 ) )
+        if( !strncmp( (char *)p_peek, "NSVf", 4 ) )
         {
             if( ReadNSVf( p_demux ) )
             {
                 return -1;
             }
         }
-        else if( !strncmp( p_peek, "NSVs", 4 ) )
+        else if( !strncmp( (char *)p_peek, "NSVs", 4 ) )
         {
             if( ReadNSVs( p_demux ) )
             {
@@ -366,13 +365,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             *pi64 = 0;
             return VLC_EGENERIC;
 
-        case DEMUX_SET_TIME:
 #endif
         case DEMUX_GET_FPS:
             pf = (double*)va_arg( args, double * );
             *pf = (double)1000000.0 / (double)p_sys->i_pcr_inc;
             return VLC_SUCCESS;
 
+        case DEMUX_SET_TIME:
         default:
             return VLC_EGENERIC;
     }
@@ -383,7 +382,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
  *****************************************************************************/
 static int ReSynch( demux_t *p_demux )
 {
-    uint8_t *p_peek;
+    uint8_t  *p_peek;
     int      i_skip;
     int      i_peek;
 
@@ -397,7 +396,8 @@ static int ReSynch( demux_t *p_demux )
 
         while( i_skip < i_peek - 4 )
         {
-            if( !strncmp( p_peek, "NSVf", 4 ) || !strncmp( p_peek, "NSVs", 4 ) )
+            if( !strncmp( (char *)p_peek, "NSVf", 4 )
+                    || !strncmp( (char *)p_peek, "NSVs", 4 ) )
             {
                 if( i_skip > 0 )
                 {
@@ -419,7 +419,7 @@ static int ReSynch( demux_t *p_demux )
  *****************************************************************************/
 static int ReadNSVf( demux_t *p_demux )
 {
-    demux_sys_t *p_sys = p_demux->p_sys;
+    /* demux_sys_t *p_sys = p_demux->p_sys; */
     uint8_t     *p;
     int         i_size;
 
@@ -449,7 +449,6 @@ static int ReadNSVs( demux_t *p_demux )
         return VLC_EGENERIC;
     }
 
-    msg_Dbg( p_demux, "new NSVs chunk" );
     /* Video */
     switch( ( fcc = VLC_FOURCC( header[4], header[5], header[6], header[7] ) ) )
     {
@@ -457,10 +456,13 @@ static int ReadNSVs( demux_t *p_demux )
         case VLC_FOURCC( 'V', 'P', '3', '1' ):
             fcc = VLC_FOURCC( 'V', 'P', '3', '1' );
             break;
+        case VLC_FOURCC( 'V', 'P', '6', '0' ):
+        case VLC_FOURCC( 'V', 'P', '6', '1' ):
+        case VLC_FOURCC( 'V', 'P', '6', '2' ):
         case VLC_FOURCC( 'N', 'O', 'N', 'E' ):
             break;
         default:
-            msg_Warn( p_demux, "unknown codec" );
+            msg_Warn( p_demux, "unknown codec %4.4s", (char *)&fcc );
             break;
     }
     if( fcc != VLC_FOURCC( 'N', 'O', 'N', 'E' ) && fcc != p_sys->fmt_video.i_codec  )
@@ -490,12 +492,13 @@ static int ReadNSVs( demux_t *p_demux )
             fcc = VLC_FOURCC( 'a', 'r', 'a', 'w' );
             break;
         case VLC_FOURCC( 'A', 'A', 'C', ' ' ):
+        case VLC_FOURCC( 'A', 'A', 'C', 'P' ):
             fcc = VLC_FOURCC( 'm', 'p', '4', 'a' );
             break;
         case VLC_FOURCC( 'N', 'O', 'N', 'E' ):
             break;
         default:
-            msg_Warn( p_demux, "unknown codec" );
+            msg_Warn( p_demux, "unknown codec %4.4s", (char *)&fcc );
             break;
     }
 
@@ -545,7 +548,7 @@ static int ReadNSVs( demux_t *p_demux )
         msg_Dbg( p_demux, "invalid fps (0x00)" );
         p_sys->i_pcr_inc = 40000;
     }
-    msg_Dbg( p_demux, "    - fps=%.3f", 1000000.0 / (double)p_sys->i_pcr_inc );
+    //msg_Dbg( p_demux, "    - fps=%.3f", 1000000.0 / (double)p_sys->i_pcr_inc );
 
     return VLC_SUCCESS;
 }