* ps.c: MPEG PS (ISO/IEC 13818-1) / MPEG SYSTEM (ISO/IEC 1172-1)
* multiplexer module for vlc
*****************************************************************************
- * Copyright (C) 2001, 2002 the VideoLAN team
+ * Copyright (C) 2001, 2002 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
* Gildas Bazin <gbazin@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
-#include <vlc_codecs.h>
#include <vlc_block.h>
#include "bits.h"
set_category( CAT_SOUT )
set_subcategory( SUBCAT_SOUT_MUX )
set_capability( "sout mux", 50 )
- add_shortcut( "ps" )
- add_shortcut( "mpeg1" )
- add_shortcut( "dvd" )
+ add_shortcut( "ps", "mpeg1", "dvd" )
set_callbacks( Open, Close )
- add_integer( SOUT_CFG_PREFIX "dts-delay", 200, NULL, DTS_TEXT,
+ add_integer( SOUT_CFG_PREFIX "dts-delay", 200, DTS_TEXT,
DTS_LONGTEXT, true )
- add_integer( SOUT_CFG_PREFIX "pes-max-size", PES_PAYLOAD_SIZE_MAX, NULL,
+ add_integer( SOUT_CFG_PREFIX "pes-max-size", PES_PAYLOAD_SIZE_MAX,
PES_SIZE_TEXT, PES_SIZE_LONGTEXT, true )
vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int MuxGetStream ( sout_mux_t *, int *, mtime_t * );
static void MuxWritePackHeader ( sout_mux_t *, block_t **, mtime_t );
static void MuxWriteSystemHeader( sout_mux_t *, block_t **, mtime_t );
msg_Info( p_mux, "Close" );
- p_end = block_New( p_mux, 4 );
+ p_end = block_Alloc( 4 );
p_end->p_buffer[0] = 0x00; p_end->p_buffer[1] = 0x00;
p_end->p_buffer[2] = 0x01; p_end->p_buffer[3] = 0xb9;
switch( p_input->p_fmt->i_codec )
{
case VLC_CODEC_MPGV:
+ case VLC_CODEC_MP2V:
+ case VLC_CODEC_MP1V:
p_stream->i_stream_id =
StreamIdGet( p_sys->stream_id_mpgv, 0xe0, 0xef );
p_stream->i_stream_type = 0x02; /* ISO/IEC 13818 Video */
block_t *p_ps, *p_data;
mtime_t i_dts;
- int i_stream;
/* Choose which stream to mux */
- if( MuxGetStream( p_mux, &i_stream, &i_dts ) )
+ int i_stream = sout_MuxGetStream( p_mux, 1, &i_dts );
+ if( i_stream < 0 )
{
return VLC_SUCCESS;
}
/* Get and mux a packet */
p_data = block_FifoGet( p_input->p_fifo );
- EStoPES ( p_mux->p_sout, &p_data, p_data,
- p_input->p_fmt, p_stream->i_stream_id,
+ EStoPES ( &p_data, p_data, p_input->p_fmt, p_stream->i_stream_id,
p_sys->b_mpeg2, 0, 0, p_sys->i_pes_max_size );
block_ChainAppend( &p_ps, p_data );
i_scr = (i_dts - p_sys->i_dts_delay) * 9 / 100;
- p_hdr = block_New( p_mux, 18 );
+ p_hdr = block_Alloc( 18 );
p_hdr->i_pts = p_hdr->i_dts = i_dts;
bits_initwrite( &bits, 14, p_hdr->p_buffer );
bits_write( &bits, 32, 0x01ba );
i_nb_stream = p_mux->i_nb_inputs -
( i_nb_private > 0 ? i_nb_private - 1 : 0 );
- p_hdr = block_New( p_mux, 12 + i_nb_stream * 3 );
+ p_hdr = block_Alloc( 12 + i_nb_stream * 3 );
p_hdr->i_dts = p_hdr->i_pts = i_dts;
/* The spec specifies that the reported rate_bound must be upper limit */
i_psm_size += i_es_map_size;
- p_hdr = block_New( p_mux, i_psm_size );
+ p_hdr = block_Alloc( i_psm_size );
p_hdr->i_dts = p_hdr->i_pts = i_dts;
memset( p_hdr->p_buffer, 0, p_hdr->i_buffer );
block_ChainAppend( p_buf, p_hdr );
}
-
-/*
- * Find stream to be muxed.
- */
-static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
-{
- mtime_t i_dts;
- int i_stream, i;
-
- for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
- {
- sout_input_t *p_input = p_mux->pp_inputs[i];
- block_t *p_data;
-
- if( block_FifoCount( p_input->p_fifo ) <= 0 )
- {
- if( p_input->p_fmt->i_cat == AUDIO_ES ||
- p_input->p_fmt->i_cat == VIDEO_ES )
- {
- /* We need that audio+video fifo contain at least 1 packet */
- return VLC_EGENERIC;
- }
-
- /* SPU */
- continue;
- }
-
- p_data = block_FifoShow( p_input->p_fifo );
- if( i_stream == -1 || p_data->i_dts < i_dts )
- {
- i_stream = i;
- i_dts = p_data->i_dts;
- }
- }
-
- *pi_stream = i_stream;
- *pi_dts = i_dts;
-
- return VLC_SUCCESS;
-}