]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/mux.c
Remove message unused "queue" parameter
[vlc] / modules / codec / ffmpeg / mux.c
index fd3bae29abe30e8e0100d89e93e2b357815d968c..7ba7229d7477ceeb02bc5d503c9873e195d3c17c 100644 (file)
@@ -2,7 +2,7 @@
  * mux.c: muxer using ffmpeg (libavformat).
  *****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
- * $Id: demux.c 8444 2004-08-17 08:21:07Z gbazin $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_block.h>
 #include <vlc_sout.h>
 
 /* ffmpeg header */
-#ifdef HAVE_FFMPEG_AVFORMAT_H
+#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
+#   include <libavformat/avformat.h>
+#elif defined(HAVE_FFMPEG_AVFORMAT_H)
 #   include <ffmpeg/avformat.h>
 #elif defined(HAVE_LIBAVFORMAT_TREE)
 #   include <avformat.h>
@@ -41,7 +47,7 @@
 //#define AVFORMAT_DEBUG 1
 
 /* Version checking */
-#if defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)
+#if defined(HAVE_LIBAVFORMAT_AVFORMAT_H) || defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)
 
 static const char *ppsz_mux_options[] = {
     "mux", NULL
@@ -60,8 +66,8 @@ struct sout_mux_sys_t
     URLContext     url;
     URLProtocol    prot;
 
-    vlc_bool_t     b_write_header;
-    vlc_bool_t     b_error;
+    bool     b_write_header;
+    bool     b_error;
 
     int64_t        i_initial_dts;
 };
@@ -80,7 +86,7 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence );
 /*****************************************************************************
  * Open
  *****************************************************************************/
-int E_(OpenMux)( vlc_object_t *p_this )
+int OpenMux( vlc_object_t *p_this )
 {
     AVOutputFormat *file_oformat;
     sout_mux_t *p_mux = (sout_mux_t*)p_this;
@@ -90,7 +96,7 @@ int E_(OpenMux)( vlc_object_t *p_this )
 
     /* Should we call it only once ? */
     av_register_all();
-    av_log_set_callback( E_(LibavcodecCallback) );
+    av_log_set_callback( LibavcodecCallback );
 
     config_ChainParse( p_mux, "ffmpeg-", ppsz_mux_options, p_mux->p_cfg );
 
@@ -155,8 +161,8 @@ int E_(OpenMux)( vlc_object_t *p_this )
 #endif
     p_sys->oc->nb_streams = 0;
 
-    p_sys->b_write_header = VLC_TRUE;
-    p_sys->b_error = VLC_FALSE;
+    p_sys->b_write_header = true;
+    p_sys->b_error = false;
     p_sys->i_initial_dts = 0;
 
     return VLC_SUCCESS;
@@ -165,7 +171,7 @@ int E_(OpenMux)( vlc_object_t *p_this )
 /*****************************************************************************
  * Close
  *****************************************************************************/
-void E_(CloseMux)( vlc_object_t *p_this )
+void CloseMux( vlc_object_t *p_this )
 {
     sout_mux_t *p_mux = (sout_mux_t*)p_this;
     sout_mux_sys_t *p_sys = p_mux->p_sys;
@@ -201,7 +207,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
 
     msg_Dbg( p_mux, "adding input" );
 
-    if( !E_(GetFfmpegCodec)( p_input->p_fmt->i_codec, 0, &i_codec_id, 0 ) )
+    if( !GetFfmpegCodec( p_input->p_fmt->i_codec, 0, &i_codec_id, 0 ) )
     {
         msg_Dbg( p_mux, "couldn't find codec for fourcc '%4.4s'",
                  (char *)&p_input->p_fmt->i_codec );
@@ -252,6 +258,9 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         codec->time_base.den = p_input->p_fmt->video.i_frame_rate;
         codec->time_base.num = p_input->p_fmt->video.i_frame_rate_base;
         break;
+
+    default:
+        msg_Warn( p_mux, "Unhandled ES category" );
     }
 
     codec->bit_rate = p_input->p_fmt->i_bitrate;
@@ -354,18 +363,19 @@ static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
 
     if( p_data->i_pts > 0 )
         pkt.pts = p_data->i_pts * p_stream->time_base.den /
-            I64C(1000000) / p_stream->time_base.num;
+            INT64_C(1000000) / p_stream->time_base.num;
     if( p_data->i_dts > 0 )
         pkt.dts = p_data->i_dts * p_stream->time_base.den /
-            I64C(1000000) / p_stream->time_base.num;
+            INT64_C(1000000) / p_stream->time_base.num;
 
     /* this is another hack to prevent libavformat from triggering the "non monotone timestamps" check in avformat/utils.c */
-    p_stream->cur_dts = AV_NOPTS_VALUE;
+    p_stream->cur_dts = ( p_data->i_dts * p_stream->time_base.den /
+            INT64_C(1000000) / p_stream->time_base.num ) - 1;
 
     if( av_write_frame( p_sys->oc, &pkt ) < 0 )
     {
-        msg_Err( p_mux, "could not write frame (pts: "I64Fd", dts: "I64Fd") "
-                 "(pkt pts: "I64Fd", dts: "I64Fd")",
+        msg_Err( p_mux, "could not write frame (pts: %"PRId64", dts: %"PRId64") "
+                 "(pkt pts: %"PRId64", dts: %"PRId64")",
                  p_data->i_pts, p_data->i_dts, pkt.pts, pkt.dts );
         block_Release( p_data );
         return VLC_EGENERIC;
@@ -389,12 +399,11 @@ static int Mux( sout_mux_t *p_mux )
     {
         msg_Dbg( p_mux, "writing header" );
 
-
         if( av_write_header( p_sys->oc ) < 0 )
         {
             msg_Err( p_mux, "could not write header" );
-            p_sys->b_write_header = VLC_FALSE;
-            p_sys->b_error = VLC_TRUE;
+            p_sys->b_write_header = false;
+            p_sys->b_error = true;
             return VLC_EGENERIC;
         }
 
@@ -403,7 +412,7 @@ static int Mux( sout_mux_t *p_mux )
 #else
         put_flush_packet( &p_sys->oc->pb );
 #endif
-        p_sys->b_write_header = VLC_FALSE;
+        p_sys->b_write_header = false;
     }
 
     for( ;; )
@@ -420,18 +429,18 @@ static int Mux( sout_mux_t *p_mux )
  *****************************************************************************/
 static int Control( sout_mux_t *p_mux, int i_query, va_list args )
 {
-    vlc_bool_t *pb_bool;
+    bool *pb_bool;
 
     switch( i_query )
     {
     case MUX_CAN_ADD_STREAM_WHILE_MUXING:
-        pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
-        *pb_bool = VLC_FALSE;
+        pb_bool = (bool*)va_arg( args, bool * );
+        *pb_bool = false;
         return VLC_SUCCESS;
 
     case MUX_GET_ADD_STREAM_WAIT:
-        pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
-        *pb_bool = VLC_TRUE;
+        pb_bool = (bool*)va_arg( args, bool * );
+        *pb_bool = true;
         return VLC_SUCCESS;
 
     case MUX_GET_MIME:
@@ -476,7 +485,7 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence )
     int64_t i_absolute;
 
 #ifdef AVFORMAT_DEBUG
-    msg_Dbg( p_mux, "IOSeek offset: "I64Fd", whence: %i", offset, whence );
+    msg_Dbg( p_mux, "IOSeek offset: %"PRId64", whence: %i", offset, whence );
 #endif
 
     switch( whence )
@@ -498,15 +507,4 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence )
     return 0;
 }
 
-#else /* HAVE_FFMPEG_AVFORMAT_H */
-
-int E_(OpenMux)( vlc_object_t *p_this )
-{
-    return VLC_EGENERIC;
-}
-
-void E_(CloseMux)( vlc_object_t *p_this )
-{
-}
-
 #endif /* HAVE_FFMPEG_AVFORMAT_H */