]> git.sesse.net Git - vlc/blobdiff - modules/demux/avformat/demux.c
Force avcodec to be at least 52.25.0 and avfomat 52.30.0...
[vlc] / modules / demux / avformat / demux.c
index 98d857cbbfb2d3030f2ac54c7f1b89be43b47957..60c9941387c34bfd76fc21922842ab328995a983 100644 (file)
 #   define HAVE_FFMPEG_CODEC_ATTACHMENT 1
 #endif
 
-#if (LIBAVFORMAT_VERSION_INT >= ((52<<16)+(15<<8)+0) )
-#   define HAVE_FFMPEG_CHAPTERS 1
-#endif
-
 /*****************************************************************************
  * demux_sys_t: demux descriptor
  *****************************************************************************/
@@ -117,11 +113,21 @@ int OpenDemux( vlc_object_t *p_this )
     unsigned int  i;
     int64_t       i_start_time = -1;
     bool          b_can_seek;
+    char         *psz_url;
 
+    if( p_demux->psz_file )
+        psz_url = strdup( p_demux->psz_file );
+    else
+    {
+        if( asprintf( &psz_url, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1)
+            return VLC_ENOMEM;
+    }
+    msg_Dbg( p_demux, "trying url: %s", psz_url );
     /* Init Probe data */
-    pd.filename = p_demux->psz_path;
+    pd.filename = psz_url;
     if( ( pd.buf_size = stream_Peek( p_demux->s, &pd.buf, 2048 + 213 ) ) <= 0 )
     {
+        free( psz_url );
         msg_Warn( p_demux, "cannot peek" );
         return VLC_EGENERIC;
     }
@@ -134,6 +140,7 @@ int OpenDemux( vlc_object_t *p_this )
     if( !( fmt = av_probe_input_format( &pd, 1 ) ) )
     {
         msg_Dbg( p_demux, "couldn't guess format" );
+        free( psz_url );
         return VLC_EGENERIC;
     }
 
@@ -147,6 +154,7 @@ int OpenDemux( vlc_object_t *p_this )
           !strcmp( fmt->name, "redir" ) ||
           !strcmp( fmt->name, "sdp" ) ) )
     {
+        free( psz_url );
         return VLC_EGENERIC;
     }
 
@@ -155,15 +163,24 @@ int OpenDemux( vlc_object_t *p_this )
     {
         int i_len;
 
-        if( !p_demux->psz_path ) return VLC_EGENERIC;
+        if( !p_demux->psz_file )
+        {
+            free( psz_url );
+            return VLC_EGENERIC;
+        }
 
-        i_len = strlen( p_demux->psz_path );
-        if( i_len < 4 ) return VLC_EGENERIC;
+        i_len = strlen( p_demux->psz_file );
+        if( i_len < 4 )
+        {
+            free( psz_url );
+            return VLC_EGENERIC;
+        }
 
-        if( strcasecmp( &p_demux->psz_path[i_len - 4], ".str" ) &&
-            strcasecmp( &p_demux->psz_path[i_len - 4], ".xai" ) &&
-            strcasecmp( &p_demux->psz_path[i_len - 3], ".xa" ) )
+        if( strcasecmp( &p_demux->psz_file[i_len - 4], ".str" ) &&
+            strcasecmp( &p_demux->psz_file[i_len - 4], ".xai" ) &&
+            strcasecmp( &p_demux->psz_file[i_len - 3], ".xa" ) )
         {
+            free( psz_url );
             return VLC_EGENERIC;
         }
     }
@@ -214,13 +231,16 @@ int OpenDemux( vlc_object_t *p_this )
 
 
     /* Open it */
-    if( av_open_input_stream( &p_sys->ic, &p_sys->io, p_demux->psz_path,
+    if( av_open_input_stream( &p_sys->ic, &p_sys->io, psz_url,
                               p_sys->fmt, NULL ) )
     {
         msg_Err( p_demux, "av_open_input_stream failed" );
+        free( psz_url );
         CloseDemux( p_this );
         return VLC_EGENERIC;
     }
+    free( psz_url );
+    psz_url = NULL;
 
     vlc_avcodec_lock(); /* avformat calls avcodec behind our back!!! */
     if( av_find_stream_info( p_sys->ic ) < 0 )
@@ -249,11 +269,7 @@ int OpenDemux( vlc_object_t *p_this )
             fmt.i_bitrate = cc->bit_rate;
             fmt.audio.i_channels = cc->channels;
             fmt.audio.i_rate = cc->sample_rate;
-#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
-            fmt.audio.i_bitspersample = cc->bits_per_sample;
-#else
             fmt.audio.i_bitspersample = cc->bits_per_coded_sample;
-#endif
             fmt.audio.i_blockalign = cc->block_align;
             psz_type = "audio";
             break;
@@ -272,6 +288,10 @@ int OpenDemux( vlc_object_t *p_this )
                 else
                     fmt.i_codec = fmt.video.i_chroma;
             }
+            /* We need this for the h264 packetizer */
+            else if( cc->codec_id == CODEC_ID_H264 && ( !strcmp( p_sys->fmt->name, "flv" ) ||
+                !strcmp( p_sys->fmt->name, "matroska" ) || !strcmp( p_sys->fmt->name, "mp4" ) ) )
+                fmt.i_original_fourcc = VLC_FOURCC( 'a', 'v', 'c', '1' );
 
             fmt.video.i_width = cc->width;
             fmt.video.i_height = cc->height;
@@ -444,7 +464,6 @@ int OpenDemux( vlc_object_t *p_this )
              ( p_sys->ic->duration != (int64_t)AV_NOPTS_VALUE ) ?
              p_sys->ic->duration * 1000000 / AV_TIME_BASE : -1 );
 
-#ifdef HAVE_FFMPEG_CHAPTERS
     if( p_sys->ic->nb_chapters > 0 )
         p_sys->p_title = vlc_input_title_New();
     for( i = 0; i < p_sys->ic->nb_chapters; i++ )
@@ -463,7 +482,6 @@ int OpenDemux( vlc_object_t *p_this )
             (i_start_time != -1 ? i_start_time : 0 );
         TAB_APPEND( p_sys->p_title->i_seekpoint, p_sys->p_title->seekpoint, s );
     }
-#endif
 
     return VLC_SUCCESS;
 }
@@ -738,13 +756,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         {
             vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
 
-            if( !p_sys->ic->title[0] || !p_sys->ic->author[0] ||
-                !p_sys->ic->copyright[0] || !p_sys->ic->comment[0] ||
-                /*!p_sys->ic->album[0] ||*/ !p_sys->ic->genre[0] )
-            {
-                return VLC_EGENERIC;
-            }
-
             if( p_sys->ic->title[0] )
                 vlc_meta_SetTitle( p_meta, p_sys->ic->title );
             if( p_sys->ic->author[0] )