/*****************************************************************************
* switcher.c: MPEG2 video switcher module
*****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004 the VideoLAN team
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#include <vlc/sout.h>
#include <vlc/vout.h>
-#include "network.h"
+#include <charset.h>
+#include <network.h>
#define HAVE_MMX
#ifdef HAVE_FFMPEG_AVCODEC_H
#endif
#define SOUT_CFG_PREFIX "sout-switcher-"
-#define MAX_PICTURES 12
-#define MAX_AUDIO 12
+#define MAX_PICTURES 10
+#define MAX_AUDIO 30
#define AVCODEC_MAX_VIDEO_FRAME_SIZE (3*1024*1024)
#define MAX_THRESHOLD 99999999
#define QSCALE_TEXT N_("Quantizer scale")
#define QSCALE_LONGTEXT N_( \
"Fixed quantizer scale to use." )
+#define AUDIO_TEXT N_("Mute audio")
+#define AUDIO_LONGTEXT N_( \
+ "Mute audio when command is not 0." )
vlc_module_begin();
set_description( _("MPEG2 video switcher stream output") );
GOP_TEXT, GOP_LONGTEXT, VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "qscale", 5, NULL,
QSCALE_TEXT, QSCALE_LONGTEXT, VLC_TRUE );
+ add_bool( SOUT_CFG_PREFIX "mute-audio", 1, NULL,
+ AUDIO_TEXT, AUDIO_LONGTEXT, VLC_TRUE );
vlc_module_end();
static const char *ppsz_sout_options[] = {
- "files", "sizes", "aspect-ratio", "port", "command", "gop", "qscale", NULL
+ "files", "sizes", "aspect-ratio", "port", "command", "gop", "qscale",
+ "mute-audio", NULL
};
struct sout_stream_sys_t
int i_qscale;
int i_aspect;
sout_stream_id_t *pp_audio_ids[MAX_AUDIO];
+ vlc_bool_t b_audio;
/* Pictures */
picture_t p_pictures[MAX_PICTURES];
var_Get( p_stream, SOUT_CFG_PREFIX "qscale", &val );
p_sys->i_qscale = val.i_int;
+ var_Get( p_stream, SOUT_CFG_PREFIX "mute-audio", &val );
+ p_sys->b_audio = val.b_bool;
+
p_stream->pf_add = Add;
p_stream->pf_del = Del;
p_stream->pf_send = Send;
id->b_switcher_video = VLC_TRUE;
p_fmt->i_codec = VLC_FOURCC('m', 'p', 'g', 'v');
msg_Dbg( p_stream,
- "creating video switcher for fcc=`%4.4s'",
- (char*)&p_fmt->i_codec );
+ "creating video switcher for fcc=`%4.4s' cmd:%d",
+ (char*)&p_fmt->i_codec, p_sys->i_cmd );
}
else if ( p_fmt->i_cat == AUDIO_ES
- && p_fmt->i_codec == VLC_FOURCC('m', 'p', 'g', 'a') )
+ && p_fmt->i_codec == VLC_FOURCC('m', 'p', 'g', 'a')
+ && p_sys->b_audio )
{
int i_ff_codec = CODEC_ID_MP2;
int i;
id->b_switcher_audio = VLC_TRUE;
msg_Dbg( p_stream,
- "creating audio switcher for fcc=`%4.4s'",
- (char*)&p_fmt->i_codec );
+ "creating audio switcher for fcc=`%4.4s' cmd:%d",
+ (char*)&p_fmt->i_codec, p_sys->i_cmd );
/* Allocate the encoder right now. */
if( i_ff_codec == 0 )
}
if ( i == MAX_AUDIO )
{
- msg_Err( p_stream, "too many audio streams !" );
+ msg_Err( p_stream, "too many audio streams!" );
free( id );
return NULL;
}
picture_t *p_pic )
{
int i, j;
- FILE *p_file = fopen( psz_file, "r" );
+ FILE *p_file = utf8_fopen( psz_file, "r" );
if ( p_file == NULL )
{
uint8_t *p_u = &p_pic->p[1].p_pixels[i/2 * p_pic->p[1].i_pitch];
uint8_t *p_v = &p_pic->p[2].p_pixels[i/2 * p_pic->p[2].i_pitch];
- if ( fread( p_buffer, 2, i_width, p_file ) != i_width )
+ if ( fread( p_buffer, 2, i_width, p_file ) != (size_t)i_width )
{
msg_Err( p_stream, "premature end of file %s", psz_file );
fclose( p_file );
}
p_sys->i_cmd = i_cmd;
+
+ msg_Dbg( p_stream, "new command: %d old:%d", p_sys->i_cmd,
+ p_sys->i_old_cmd );
}
}
| CODEC_FLAG_LOW_DELAY;
id->ff_enc_c->mb_decision = FF_MB_DECISION_SIMPLE;
+ id->ff_enc_c->pix_fmt = PIX_FMT_YUV420P;
if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
{
p_out->i_length = p_buffer->i_length;
p_out->i_pts = p_buffer->i_dts;
p_out->i_dts = p_buffer->i_dts;
+ p_out->i_rate = p_buffer->i_rate;
switch ( id->ff_enc_c->coded_frame->pict_type )
{
p_out->i_length = p_buffer->i_length;
p_out->i_pts = p_buffer->i_dts;
p_out->i_dts = p_buffer->i_dts;
+ p_out->i_rate = p_buffer->i_rate;
block_Release( p_buffer );