]> git.sesse.net Git - mlt/commitdiff
Remove mlt protocol, use ByteIOContext if <v53 libavformat.
authorDan Dennedy <dan@dennedy.org>
Mon, 25 Jul 2011 04:41:14 +0000 (21:41 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 25 Jul 2011 05:34:03 +0000 (22:34 -0700)
src/modules/avformat/consumer_avformat.c

index 01cdd318e45eea3b968ce5caf0867998c2688f94..d868e46c18df662d0c22da94d8f650a2d438df4d 100644 (file)
@@ -37,6 +37,7 @@
 
 // avformat header files
 #include <libavformat/avformat.h>
+#include <libavformat/avio.h>
 #ifdef SWSCALE
 #include <libswscale/swscale.h>
 #endif
@@ -50,7 +51,6 @@
 #endif
 
 #if LIBAVCODEC_VERSION_MAJOR >= 53
-#include <libavformat/avio.h>
 #include <libavutil/opt.h>
 #define CODEC_TYPE_VIDEO      AVMEDIA_TYPE_VIDEO
 #define CODEC_TYPE_AUDIO      AVMEDIA_TYPE_AUDIO
@@ -963,7 +963,6 @@ static inline long time_difference( struct timeval *time1 )
        return time2.tv_sec * 1000000 + time2.tv_usec - time1->tv_sec * 1000000 - time1->tv_usec;
 }
 
-#if LIBAVFORMAT_VERSION_MAJOR > 52
 static int mlt_write(void *h, uint8_t *buf, int size)
 {
        mlt_properties properties = (mlt_properties) h;
@@ -975,7 +974,6 @@ static void write_transmitter( mlt_listener listener, mlt_properties owner, mlt_
 {
        listener( owner, service, (uint8_t*) args[0], (int) args[1] );
 }
-#endif
 
 
 /** The main thread - the argument is simply the consumer.
@@ -1281,18 +1279,22 @@ static void *consumer_thread( void *arg )
                                audio_st[i] = NULL;
                }
 
-#if LIBAVFORMAT_VERSION_MAJOR > 52
                // Setup custom I/O if redirecting
                if ( mlt_properties_get_int( properties, "redirect" ) )
                {
                        int buffer_size = 32768;
                        unsigned char *buffer = av_malloc( buffer_size );
+#if LIBAVFORMAT_VERSION_MAJOR >= 53
                        AVIOContext* io = avio_alloc_context( buffer, buffer_size, 1, properties, NULL, mlt_write, NULL );
-
+#else
+                       ByteIOContext* io = av_alloc_put_byte( buffer, buffer_size, 1, properties, NULL, mlt_write, NULL );
+#endif
                        if ( buffer && io )
                        {
                                oc->pb = io;
+#if LIBAVFORMAT_VERSION_MAJOR >= 53
                                oc->flags |= AVFMT_FLAG_CUSTOM_IO;
+#endif
                                mlt_properties_set_data( properties, "avio_buffer", buffer, buffer_size, av_free, NULL );
                                mlt_properties_set_data( properties, "avio_context", io, 0, av_free, NULL );
                                mlt_events_register( properties, "avformat-write", (mlt_transmitter) write_transmitter );
@@ -1303,10 +1305,8 @@ static void *consumer_thread( void *arg )
                                mlt_log_error( MLT_CONSUMER_SERVICE(consumer), "failed to setup output redirection\n" );
                        }
                }
-               else
-#endif
                // Open the output file, if needed
-               if ( !( fmt->flags & AVFMT_NOFILE ) ) 
+               else if ( !( fmt->flags & AVFMT_NOFILE ) )
                {
 #if LIBAVFORMAT_VERSION_MAJOR >= 53
                        if ( avio_open( &oc->pb, filename, AVIO_FLAG_WRITE ) < 0 )