Commit 949a4ce2 authored by Laurent Aimar's avatar Laurent Aimar

* all: reworked stream output. Now it handles mutliples outputs from

one input, just type --sout "<first url>#<second url>#..." (Yes it
is awfull, but I need suggestion).
   udp: correctly update sequence number in rtp.
parent 4befbe94
......@@ -2,7 +2,7 @@
* stream_output.h : stream output module
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: stream_output.h,v 1.8 2003/02/25 17:17:43 fenrir Exp $
* $Id: stream_output.h,v 1.9 2003/03/11 19:02:30 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
......@@ -63,7 +63,6 @@ struct sout_packet_format_t
vlc_fourcc_t i_fourcc;
void *p_format; // WAVEFORMATEX or BITMAPINFOHEADER
};
struct sout_fifo_t
......@@ -76,23 +75,39 @@ struct sout_fifo_t
sout_buffer_t **pp_last;
};
/* for mux */
struct sout_input_t
{
vlc_mutex_t lock;
// vlc_mutex_t lock;
sout_instance_t *p_sout;
sout_packet_format_t input_format;
sout_fifo_t *p_fifo;
void *p_mux_data;
void *p_sys;
};
/* for packetizr */
struct sout_packetizer_input_t
{
sout_instance_t *p_sout;
sout_packet_format_t input_format;
// vlc_mutex_t lock;
int i_nb_inputs;
sout_input_t **pp_inputs;
int i_nb_mux; // not really used, just usefull with TAB_*
sout_mux_t **pp_mux;
};
#define SOUT_METHOD_NONE 0x00
#define SOUT_METHOD_FILE 0x10
#define SOUT_METHOD_NETWORK 0x20
struct sout_access_out_t
{
VLC_COMMON_MEMBERS
......@@ -123,38 +138,72 @@ struct sout_access_out_t
#define SOUT_MUX_CAP_ERR_UNKNOWN 0x01
#define SOUT_MUX_CAP_ERR_UNIMPLEMENTED 0x02
typedef struct sout_instance_sys_t sout_instance_sys_t;
struct sout_instance_t
typedef struct sout_mux_sys_t sout_mux_sys_t;
struct sout_mux_t
{
VLC_COMMON_MEMBERS
module_t *p_module;
sout_instance_t *p_sout;
char * psz_dest;
char * psz_access;
char * psz_mux;
char * psz_name;
int i_method;
char *psz_mux;
sout_access_out_t *p_access;
module_t *p_mux;
void *p_mux_data;
int i_mux_preheader;
int (* pf_mux_capacity) ( sout_instance_t *,
int i_preheader;
int (* pf_capacity) ( sout_mux_t *,
int, void *, void *);
int (* pf_mux_addstream )( sout_instance_t *,
int (* pf_addstream )( sout_mux_t *,
sout_input_t * );
int (* pf_mux_delstream )( sout_instance_t *,
int (* pf_delstream )( sout_mux_t *,
sout_input_t * );
int (* pf_mux ) ( sout_instance_t * );
int (* pf_mux ) ( sout_mux_t * );
vlc_mutex_t lock;
/* here are all inputs accepted by muxer */
int i_nb_inputs;
sout_input_t **pp_inputs;
/* mux private */
sout_mux_sys_t *p_sys;
// /* creater private */
// void *p_sys_owner;
/* XXX private to stream_output.c */
/* if muxer doesn't support adding stream at any time then we first wait
* for stream then we refuse all stream and start muxing */
vlc_bool_t b_add_stream_any_time;
vlc_bool_t b_waiting_stream;
/* we wait one second after first stream added */
mtime_t i_add_stream_start;
};
typedef struct sout_instance_sys_t sout_instance_sys_t;
struct sout_instance_t
{
VLC_COMMON_MEMBERS
/* complete sout string like udp/ts:239.255.12.42#file/ps://essai.ps */
char * psz_sout;
/* here are stored the parsed psz_sout */
int i_nb_dest;
char **ppsz_dest;
/* muxer data */
int i_preheader; /* max over all muxer */
int i_nb_mux;
sout_mux_t **pp_mux;
/* here are all packetizer inputs accepted by at least one muxer */
vlc_mutex_t lock;
int i_nb_inputs;
sout_packetizer_input_t **pp_inputs;
/* sout private */
sout_instance_sys_t *p_sys;
};
......@@ -178,9 +227,9 @@ VLC_EXPORT( sout_buffer_t *, sout_FifoShow, ( sout_fifo_t * ) );
#define sout_InputNew( a, b ) __sout_InputNew( VLC_OBJECT(a), b )
VLC_EXPORT( sout_input_t *, __sout_InputNew, ( vlc_object_t *, sout_packet_format_t * ) );
VLC_EXPORT( int, sout_InputDelete, ( sout_input_t * ) );
VLC_EXPORT( int, sout_InputSendBuffer, ( sout_input_t *, sout_buffer_t* ) );
VLC_EXPORT( sout_packetizer_input_t *, __sout_InputNew, ( vlc_object_t *, sout_packet_format_t * ) );
VLC_EXPORT( int, sout_InputDelete, ( sout_packetizer_input_t * ) );
VLC_EXPORT( int, sout_InputSendBuffer, ( sout_packetizer_input_t *, sout_buffer_t* ) );
VLC_EXPORT( sout_buffer_t*, sout_BufferNew, ( sout_instance_t *, size_t ) );
VLC_EXPORT( int, sout_BufferRealloc,( sout_instance_t *, sout_buffer_t*, size_t ) );
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.57 2003/03/04 21:12:04 gbazin Exp $
* $Id: vlc_common.h,v 1.58 2003/03/11 19:02:30 fenrir Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -247,9 +247,11 @@ typedef struct subpicture_sys_t subpicture_sys_t;
typedef struct sout_instance_t sout_instance_t;
typedef struct sout_fifo_t sout_fifo_t;
typedef struct sout_input_t sout_input_t;
typedef struct sout_packetizer_input_t sout_packetizer_input_t;
typedef struct sout_buffer_t sout_buffer_t;
typedef struct sout_packet_format_t sout_packet_format_t;
typedef struct sout_access_out_t sout_access_out_t;
typedef struct sout_mux_t sout_mux_t;
typedef struct sout_access_out_sys_t sout_access_out_sys_t;
/* Decoders */
......
......@@ -2,7 +2,7 @@
* udp.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.5 2003/03/03 14:21:08 gbazin Exp $
* $Id: udp.c,v 1.6 2003/03/11 19:02:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -125,18 +125,11 @@ static int Open( vlc_object_t *p_this )
return( VLC_EGENERIC );
}
if( p_access->psz_access != NULL &&
!strcmp( p_access->psz_access, "rtp" ) )
{
if( p_access->p_sout->psz_mux != NULL &&
*p_access->p_sout->psz_mux &&
strcmp( p_access->p_sout->psz_mux, "ts" ) &&
strcmp( p_access->p_sout->psz_mux, "ts_dvbpsi" ) )
{
msg_Err( p_access, "rtp ouput work only with ts payload" );
free( p_sys );
return( VLC_EGENERIC );
}
msg_Warn( p_access, "becarefull that rtp ouput work only with ts payload(not an error)" );
p_sys->b_rtpts = 1;
}
else
......@@ -203,9 +196,10 @@ static int Open( vlc_object_t *p_this )
return( VLC_EGENERIC );
}
srand( (uint32_t)mdate());
p_sys->p_buffer = NULL;
p_sys->i_sequence_number = 12; // FIXME should be random, used by rtp
p_sys->i_ssrc = 4212; // FIXME " " " " " "
p_sys->i_sequence_number = rand()&0xffff;
p_sys->i_ssrc = rand()&0xffffffff;
p_access->pf_write = Write;
p_access->pf_seek = Seek;
......@@ -300,10 +294,12 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
/* add rtp/ts header */
p_sys->p_buffer->p_buffer[0] = 0x80;
p_sys->p_buffer->p_buffer[1] = 0x21; // mpeg2-ts
p_sys->p_buffer->p_buffer[2] =
( p_sys->i_sequence_number >> 8 )&0xff;
p_sys->p_buffer->p_buffer[3] =
p_sys->i_sequence_number&0xff;
p_sys->i_sequence_number++;
p_sys->p_buffer->p_buffer[4] = ( i_timestamp >> 24 )&0xff;
p_sys->p_buffer->p_buffer[5] = ( i_timestamp >> 16 )&0xff;
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* dummy.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: dummy.c,v 1.6 2003/03/03 14:21:08 gbazin Exp $
* $Id: dummy.c,v 1.7 2003/03/11 19:02:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -48,10 +48,10 @@
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static int Capability(sout_instance_t *, int, void *, void * );
static int AddStream( sout_instance_t *, sout_input_t * );
static int DelStream( sout_instance_t *, sout_input_t * );
static int Mux ( sout_instance_t * );
static int Capability(sout_mux_t *, int, void *, void * );
static int AddStream( sout_mux_t *, sout_input_t * );
static int DelStream( sout_mux_t *, sout_input_t * );
static int Mux ( sout_mux_t * );
/*****************************************************************************
* Module descriptor
......@@ -60,6 +60,7 @@ vlc_module_begin();
set_description( _("Dummy muxer") );
set_capability( "sout mux", 5 );
add_shortcut( "dummy" );
add_shortcut( "es" );
set_callbacks( Open, Close );
vlc_module_end();
......@@ -68,14 +69,14 @@ vlc_module_end();
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
sout_instance_t *p_sout = (sout_instance_t*)p_this;
sout_mux_t *p_mux = (sout_mux_t*)p_this;
msg_Info( p_sout, "Open" );
msg_Info( p_mux, "Open" );
p_sout->pf_mux_capacity = Capability;
p_sout->pf_mux_addstream = AddStream;
p_sout->pf_mux_delstream = DelStream;
p_sout->pf_mux = Mux;
p_mux->pf_capacity = Capability;
p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux;
return VLC_SUCCESS;
}
......@@ -86,11 +87,12 @@ static int Open( vlc_object_t *p_this )
static void Close( vlc_object_t * p_this )
{
sout_instance_t *p_sout = (sout_instance_t*)p_this;
msg_Info( p_sout, "Close" );
sout_mux_t *p_mux = (sout_mux_t*)p_this;
msg_Info( p_mux, "Close" );
}
static int Capability( sout_instance_t *p_sout, int i_query, void *p_args, void *p_answer )
static int Capability( sout_mux_t *p_mux, int i_query, void *p_args, void *p_answer )
{
switch( i_query )
{
......@@ -102,28 +104,28 @@ static int Capability( sout_instance_t *p_sout, int i_query, void *p_args, void
}
}
static int AddStream( sout_instance_t *p_sout, sout_input_t *p_input )
static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
msg_Dbg( p_sout, "adding input" );
msg_Dbg( p_mux, "adding input" );
return( 0 );
}
static int DelStream( sout_instance_t *p_sout, sout_input_t *p_input )
static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
{
msg_Dbg( p_sout, "removing input" );
msg_Dbg( p_mux, "removing input" );
return( 0 );
}
static int Mux ( sout_instance_t *p_sout )
static int Mux ( sout_mux_t *p_mux )
{
int i;
for( i = 0; i < p_sout->i_nb_inputs; i++ )
for( i = 0; i < p_mux->i_nb_inputs; i++ )
{
int i_count;
sout_fifo_t *p_fifo;
p_fifo = p_sout->pp_inputs[i]->p_fifo;
p_fifo = p_mux->pp_inputs[i]->p_fifo;
i_count = p_fifo->i_depth;
while( i_count > 0 )
{
......@@ -131,7 +133,7 @@ static int Mux ( sout_instance_t *p_sout )
p_data = sout_FifoGet( p_fifo );
sout_AccessOutWrite( p_sout->p_access, p_data );
sout_AccessOutWrite( p_mux->p_access, p_data );
i_count--;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
* a52.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: a52.c,v 1.1 2002/12/14 21:32:41 fenrir Exp $
* $Id: a52.c,v 1.2 2003/03/11 19:02:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -44,7 +44,7 @@ typedef struct packetizer_s
bit_stream_t bit_stream;
/* Output properties */
sout_input_t *p_sout_input;
sout_packetizer_input_t *p_sout_input;
sout_packet_format_t output_format;
uint64_t i_samplescount;
......
......@@ -2,7 +2,7 @@
* copy.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: copy.c,v 1.4 2003/01/23 15:52:04 sam Exp $
* $Id: copy.c,v 1.5 2003/03/11 19:02:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -44,7 +44,7 @@ typedef struct packetizer_thread_s
decoder_fifo_t *p_fifo;
/* Output properties */
sout_input_t *p_sout_input;
sout_packetizer_input_t *p_sout_input;
sout_packet_format_t output_format;
mtime_t i_pts_start;
......
......@@ -2,7 +2,7 @@
* mpeg4audio.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: mpeg4audio.c,v 1.2 2003/01/23 15:52:04 sam Exp $
* $Id: mpeg4audio.c,v 1.3 2003/03/11 19:02:31 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -59,7 +59,7 @@ typedef struct packetizer_thread_s
bit_stream_t bit_stream;
/* Output properties */
sout_input_t *p_sout_input;
sout_packetizer_input_t *p_sout_input;
sout_packet_format_t output_format;
mtime_t i_pts_start;
......
......@@ -2,7 +2,7 @@
* mpeg4video.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: mpeg4video.c,v 1.7 2003/01/23 15:52:04 sam Exp $
* $Id: mpeg4video.c,v 1.8 2003/03/11 19:02:31 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -45,7 +45,7 @@ typedef struct packetizer_thread_s
decoder_fifo_t *p_fifo;
/* Output properties */
sout_input_t *p_sout_input;
sout_packetizer_input_t *p_sout_input;
sout_packet_format_t output_format;
mtime_t i_pts_start;
......
......@@ -2,7 +2,7 @@
* mpegaudio.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: mpegaudio.c,v 1.3 2003/02/18 00:51:40 fenrir Exp $
* $Id: mpegaudio.c,v 1.4 2003/03/11 19:02:31 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -44,7 +44,7 @@ typedef struct packetizer_s
bit_stream_t bit_stream;
/* Output properties */
sout_input_t *p_sout_input;
sout_packetizer_input_t *p_sout_input;
sout_packet_format_t output_format;
uint64_t i_samplescount;
......
......@@ -2,7 +2,7 @@
* mpegvideo.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: mpegvideo.c,v 1.9 2003/02/26 13:51:36 gbazin Exp $
* $Id: mpegvideo.c,v 1.10 2003/03/11 19:02:31 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -44,7 +44,7 @@ typedef struct packetizer_s
bit_stream_t bit_stream;
/* Output properties */
sout_input_t *p_sout_input;
sout_packetizer_input_t *p_sout_input;
sout_packet_format_t output_format;
mtime_t i_last_dts;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment