]> git.sesse.net Git - vlc/blobdiff - modules/demux/avformat/demux.c
avformat mux: convert to new avio API
[vlc] / modules / demux / avformat / demux.c
index 739ac2aee2836cdc5402e04b21ef0d6f022578a1..cf3ef3db10e0943e647dc2f52bc26ae95d7641c7 100644 (file)
 #include "../xiph.h"
 #include "../vobsub.h"
 
+/* Support for deprecated APIs */
+
+#if LIBAVFORMAT_VERSION_MAJOR < 54
+# define AVDictionaryEntry AVMetadataTag
+# define av_dict_get av_metadata_get
+#endif
+
 //#define AVFORMAT_DEBUG 1
 
 /* Version checking */
@@ -66,8 +73,6 @@ struct demux_sys_t
 
     AVInputFormat  *fmt;
     AVFormatContext *ic;
-    URLContext     url;
-    URLProtocol    prot;
 
     int             i_tk;
     es_out_id_t     **tk;
@@ -120,7 +125,7 @@ int OpenDemux( vlc_object_t *p_this )
     msg_Dbg( p_demux, "trying url: %s", psz_url );
     /* Init Probe data */
     pd.filename = psz_url;
-    if( ( pd.buf_size = stream_Peek( p_demux->s, &pd.buf, 2048 + 213 ) ) <= 0 )
+    if( ( pd.buf_size = stream_Peek( p_demux->s, (const uint8_t**)&pd.buf, 2048 + 213 ) ) <= 0 )
     {
         free( psz_url );
         msg_Warn( p_demux, "cannot peek" );
@@ -146,6 +151,8 @@ int OpenDemux( vlc_object_t *p_this )
             "mpeg", "vcd", "vob", "mpegts",
             /* libavformat's redirector won't work */
             "redir", "sdp",
+            /* Don't handle subtitles format */
+            "ass", "srt", "microdvd",
             ""
         };
 
@@ -204,19 +211,8 @@ int OpenDemux( vlc_object_t *p_this )
     /* Create I/O wrapper */
     p_sys->io_buffer_size = 32768;  /* FIXME */
     p_sys->io_buffer = malloc( p_sys->io_buffer_size );
-    p_sys->url.priv_data = p_demux;
-    p_sys->url.prot = &p_sys->prot;
-    p_sys->url.prot->name = "VLC I/O wrapper";
-    p_sys->url.prot->url_open = 0;
-    p_sys->url.prot->url_read =
-                    (int (*) (URLContext *, unsigned char *, int))IORead;
-    p_sys->url.prot->url_write = 0;
-    p_sys->url.prot->url_seek =
-                    (int64_t (*) (URLContext *, int64_t, int))IOSeek;
-    p_sys->url.prot->url_close = 0;
-    p_sys->url.prot->next = 0;
     init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size,
-                   0, &p_sys->url, IORead, NULL, IOSeek );
+                   0, p_demux, IORead, NULL, IOSeek );
 
     stream_Control( p_demux->s, STREAM_CAN_SEEK, &b_can_seek );
     if( !b_can_seek )
@@ -225,7 +221,6 @@ int OpenDemux( vlc_object_t *p_this )
        when trying av_find_stream_info() trying to seek all the wrong places
        init_put_byte defaults io.is_streamed=0, so thats why we set them after it
        */
-       p_sys->url.is_streamed = 1;
        p_sys->io.is_streamed = 1;
 #if defined(AVIO_SEEKABLE_NORMAL)
        p_sys->io.seekable = 0;
@@ -366,7 +361,7 @@ int OpenDemux( vlc_object_t *p_this )
                 psz_type = "attachment";
                 if( cc->codec_id == CODEC_ID_TTF )
                 {
-                    AVMetadataTag *filename = av_metadata_get( s->metadata, "filename", NULL, 0 );
+                    AVDictionaryEntry *filename = av_dict_get( s->metadata, "filename", NULL, 0 );
                     if( filename && filename->value )
                     {
                         p_attachment = vlc_input_attachment_New(
@@ -389,7 +384,7 @@ int OpenDemux( vlc_object_t *p_this )
             break;
         }
 
-        AVMetadataTag *language = av_metadata_get( s->metadata, "language", NULL, 0 );
+        AVDictionaryEntry *language = av_dict_get( s->metadata, "language", NULL, 0 );
         if ( language && language->value )
             fmt.psz_language = strdup( language->value );
 
@@ -493,7 +488,7 @@ int OpenDemux( vlc_object_t *p_this )
     {
         seekpoint_t *s = vlc_seekpoint_New();
 
-        AVMetadataTag *title = av_metadata_get( p_sys->ic->metadata, "title", NULL, 0);
+        AVDictionaryEntry *title = av_dict_get( p_sys->ic->metadata, "title", NULL, 0);
         if( title && title->value )
         {
             s->psz_name = strdup( title->value );
@@ -807,11 +802,11 @@ 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* );
 
-            AVMetadataTag *title = av_metadata_get( p_sys->ic->metadata, "language", NULL, 0 );
-            AVMetadataTag *artist = av_metadata_get( p_sys->ic->metadata, "artist", NULL, 0 );
-            AVMetadataTag *copyright = av_metadata_get( p_sys->ic->metadata, "copyright", NULL, 0 );
-            AVMetadataTag *comment = av_metadata_get( p_sys->ic->metadata, "comment", NULL, 0 );
-            AVMetadataTag *genre = av_metadata_get( p_sys->ic->metadata, "genre", NULL, 0 );
+            AVDictionaryEntry *title = av_dict_get( p_sys->ic->metadata, "language", NULL, 0 );
+            AVDictionaryEntry *artist = av_dict_get( p_sys->ic->metadata, "artist", NULL, 0 );
+            AVDictionaryEntry *copyright = av_dict_get( p_sys->ic->metadata, "copyright", NULL, 0 );
+            AVDictionaryEntry *comment = av_dict_get( p_sys->ic->metadata, "comment", NULL, 0 );
+            AVDictionaryEntry *genre = av_dict_get( p_sys->ic->metadata, "genre", NULL, 0 );
 
             if( title && title->value )
                 vlc_meta_SetTitle( p_meta, title->value );
@@ -897,8 +892,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
  *****************************************************************************/
 static int IORead( void *opaque, uint8_t *buf, int buf_size )
 {
-    URLContext *p_url = opaque;
-    demux_t *p_demux = p_url->priv_data;
+    demux_t *p_demux = opaque;
     if( buf_size < 0 ) return -1;
     int i_ret = stream_Read( p_demux->s, buf, buf_size );
     return i_ret ? i_ret : -1;
@@ -906,8 +900,7 @@ static int IORead( void *opaque, uint8_t *buf, int buf_size )
 
 static int64_t IOSeek( void *opaque, int64_t offset, int whence )
 {
-    URLContext *p_url = opaque;
-    demux_t *p_demux = p_url->priv_data;
+    demux_t *p_demux = opaque;
     int64_t i_absolute;
     int64_t i_size = stream_Size( p_demux->s );