]> git.sesse.net Git - vlc/blobdiff - modules/demux/mod.c
Mark rtsp-kasenna as safe
[vlc] / modules / demux / mod.c
index 15e45bdd56814aa0c61f0dc42f63be2f7ec3537c..37deaa496a059b230b99705121868e255dc6d837 100644 (file)
@@ -5,6 +5,7 @@
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ * Konstanty Bialkowski <konstanty@ieee.org>
  *
  * 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
@@ -234,7 +235,7 @@ static int Open( vlc_object_t *p_this )
 
     /* init time */
     date_Init( &p_sys->pts, settings.mFrequency, 1 );
-    date_Set( &p_sys->pts, 1 );
+    date_Set( &p_sys->pts, 0 );
     p_sys->i_length = ModPlug_GetLength( p_sys->f ) * INT64_C(1000);
 
     msg_Dbg( p_demux, "MOD loaded name=%s lenght=%"PRId64"ms",
@@ -291,7 +292,7 @@ static int Demux( demux_t *p_demux )
     }
     p_frame->i_buffer = i_read;
     p_frame->i_dts =
-    p_frame->i_pts = date_Increment( &p_sys->pts, p_frame->i_buffer / i_bk );
+    p_frame->i_pts = VLC_TS_0 + date_Get( &p_sys->pts );
 
     /* Set PCR */
     es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_frame->i_pts );
@@ -299,6 +300,8 @@ static int Demux( demux_t *p_demux )
     /* Send data */
     es_out_Send( p_demux->out, p_sys->es, p_frame );
 
+    date_Increment( &p_sys->pts, i_read / i_bk );
+
     return 1;
 }
 
@@ -317,7 +320,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         pf = (double*) va_arg( args, double* );
         if( p_sys->i_length > 0 )
         {
-            *pf = (double)date_Get( &p_sys->pts ) / (double)p_sys->i_length;
+            double current = date_Get( &p_sys->pts );
+            double length = p_sys->i_length;
+            *pf = current / length;
             return VLC_SUCCESS;
         }
         return VLC_EGENERIC;
@@ -329,7 +334,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         if( i64 >= 0 && i64 <= p_sys->i_length )
         {
             ModPlug_Seek( p_sys->f, i64 / 1000 );
-            date_Set( &p_sys->pts, i64 + 1 );
+            date_Set( &p_sys->pts, i64 );
 
             return VLC_SUCCESS;
         }
@@ -351,7 +356,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         if( i64 >= 0 && i64 <= p_sys->i_length )
         {
             ModPlug_Seek( p_sys->f, i64 / 1000 );
-            date_Set( &p_sys->pts, i64 + 1 );
+            date_Set( &p_sys->pts, i64 );
 
             return VLC_SUCCESS;
         }
@@ -366,9 +371,68 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     case DEMUX_GET_META:
     {
         vlc_meta_t *p_meta = (vlc_meta_t *)va_arg( args, vlc_meta_t* );
+        unsigned i_num_samples = ModPlug_NumSamples( p_sys->f ),
+                 i_num_instruments = ModPlug_NumInstruments( p_sys->f );
+        unsigned i_num_patterns = ModPlug_NumPatterns( p_sys->f ),
+                 i_num_channels = ModPlug_NumChannels( p_sys->f );
+        //      unsigned modType = ModPlug_GetModuleType( p_sys->f );
+
+        char psz_temp[2048]; /* 32 * 240 max, but only need start  */
+        char *psz_module_info, *psz_instrument_info;
+        unsigned i_temp_index = 0;
         const char *psz_name = ModPlug_GetName( p_sys->f );
         if( psz_name && *psz_name )
             vlc_meta_SetTitle( p_meta, psz_name );
+
+        /* Comment field from artist - not in every type of MOD */
+        psz_name = ModPlug_GetMessage( p_sys->f );
+        if( psz_name && *psz_name )
+            vlc_meta_SetDescription( p_meta, psz_name );
+
+        /* Instruments only in newer MODs - so don't show if 0 */
+        if( asprintf( &psz_instrument_info, ", %i Instruments",
+                      i_num_instruments ) >= 0 )
+        {
+            if( asprintf( &psz_module_info,
+                          "%i Channels, %i Patterns\n"
+                          "%i Samples%s\n",
+                          i_num_channels, i_num_patterns, i_num_samples,
+                          ( i_num_instruments ? psz_instrument_info : "" ) ) >= 0 )
+            {
+                vlc_meta_AddExtra( p_meta, "Module Information",
+                                   psz_module_info );
+                free( psz_module_info );
+            }
+
+            free( psz_instrument_info );
+        }
+
+        /* Make list of instruments (XM, IT, etc) */
+        if( i_num_instruments )
+        {
+            i_temp_index = 0;
+            for( unsigned i = 0; i < i_num_instruments && i_temp_index < sizeof(psz_temp); i++ )
+            {
+                char lBuffer[33];
+                ModPlug_InstrumentName( p_sys->f, i, lBuffer );
+                if ( !lBuffer[0] ) continue; // don't add empty fields.
+                i_temp_index += snprintf( &psz_temp[i_temp_index], sizeof(psz_temp) - i_temp_index, "%s\n", lBuffer );
+            }
+
+            vlc_meta_AddExtra( p_meta, "Instruments", psz_temp );
+        }
+
+        /* Make list of samples */
+        for( unsigned int i = 0; i < i_num_samples && i_temp_index < sizeof(psz_temp); i++ )
+        {
+            char psz_buffer[33];
+            ModPlug_SampleName( p_sys->f, i, psz_buffer );
+            if ( !psz_buffer[0] ) continue; // don't add empty fields.
+            i_temp_index += snprintf( &psz_temp[i_temp_index], sizeof(psz_temp) - i_temp_index, "%s\n", psz_buffer );
+        }
+
+        vlc_meta_AddExtra( p_meta, "Samples", psz_temp );
+
         return VLC_SUCCESS;
     }
 
@@ -401,8 +465,10 @@ static int Validate( demux_t *p_demux, const char *psz_ext )
         { 20, "!SCREAM!" },             /* STM */
         { 20, "!Scream!" },             /* STM */
         { 20, "BMOD2STM" },             /* STM */
-        {  0, "MMD0" },                 /* MED */
-        {  0, "MMD1" },                 /* MED */
+        {  0, "MMD0" },                 /* MED v0 */
+        {  0, "MMD1" },                 /* MED v1 */
+        {  0, "MMD2" },                 /* MED v2 */
+        {  0, "MMD3" },                 /* MED v3 */
         {  0, "MTM" },                  /* MTM */
         {  0, "DMDL" },                 /* MDL */
         {  0, "DBM0" },                 /* DBM */
@@ -416,7 +482,8 @@ static int Validate( demux_t *p_demux, const char *psz_ext )
         {  0, "DDMF" },                 /* DMF */
         {  8, "DSMFSONG" },             /* DSM */
         {  0, "\xc1\x83\x2a\x9e" },     /* UMX */
-        {  0, "ASYLUM Music Format V1.0" }, /* AMF */
+        {  0, "ASYLUM Music Format V1.0" }, /* AMF Type 0 */
+        {  0, "AMF" },                  /* AMF */
         {  0, "PSM\xfe" },              /* PSM */
         {  0, "PSM " },                 /* PSM */
         {  0, "MT20" },                 /* MT2 */