* 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>
//#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
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;
};
/*****************************************************************************
* 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;
/* 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 );
#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;
/*****************************************************************************
* 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;
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 );
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;
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;
{
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;
}
#else
put_flush_packet( &p_sys->oc->pb );
#endif
- p_sys->b_write_header = VLC_FALSE;
+ p_sys->b_write_header = false;
}
for( ;; )
*****************************************************************************/
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:
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 )
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 */