Commit 8d5c85f2 authored by Christophe Massiot's avatar Christophe Massiot

* Fixed a variable overflow bug in the audio output.

* Prepared for some advances in the aout3 clock management.
* Added the first stone of the forthcoming stream output.
parent a39d9077
......@@ -23,6 +23,7 @@ PLAYLIST := playlist
INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock input_info
VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
AUDIO_OUTPUT := audio_output filters input mixer output
STREAM_OUTPUT := stream_output
MISC := mtime modules threads cpu configuration netutils iso_lang messages objects extras
LIBVLC_OBJ := $(LIBVLC:%=src/%.o) \
......@@ -31,6 +32,7 @@ LIBVLC_OBJ := $(LIBVLC:%=src/%.o) \
$(INPUT:%=src/input/%.o) \
$(VIDEO_OUTPUT:%=src/video_output/%.o) \
$(AUDIO_OUTPUT:%=src/audio_output/%.o) \
$(STREAM_OUTPUT:%=src/stream_output/%.o) \
$(MISC:%=src/misc/%.o)
VLC_OBJ := $(VLC:%=src/%.o)
......
......@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: aout_internal.h,v 1.2 2002/08/08 00:35:10 sam Exp $
* $Id: aout_internal.h,v 1.3 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -45,27 +45,32 @@ typedef struct aout_alloc_t
if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK ) \
{ \
(p_new_buffer) = alloca( (u64)(p_alloc)->i_bytes_per_sec \
* i_nb_usec \
* (i_nb_usec) \
/ 1000000 + 1 + sizeof(aout_buffer_t) ); \
} \
else \
{ \
(p_new_buffer) = malloc( (u64)(p_alloc)->i_bytes_per_sec \
* i_nb_usec \
* (i_nb_usec) \
/ 1000000 + 1 + sizeof(aout_buffer_t) ); \
} \
(p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type; \
(p_new_buffer)->i_size = (u64)(p_alloc)->i_bytes_per_sec \
* i_nb_usec / 1000000 + 1; \
(p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer) \
+ sizeof(aout_buffer_t); \
if ( (p_previous_buffer) != NULL ) \
if ( p_new_buffer != NULL ) \
{ \
(p_new_buffer)->start_date = \
((aout_buffer_t *)p_previous_buffer)->start_date; \
(p_new_buffer)->end_date = \
((aout_buffer_t *)p_previous_buffer)->end_date; \
(p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type; \
(p_new_buffer)->i_size = (u64)(p_alloc)->i_bytes_per_sec \
* (i_nb_usec) / 1000000 + 1; \
(p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer) \
+ sizeof(aout_buffer_t); \
if ( (p_previous_buffer) != NULL ) \
{ \
(p_new_buffer)->start_date = \
((aout_buffer_t *)p_previous_buffer)->start_date;\
(p_new_buffer)->end_date = \
((aout_buffer_t *)p_previous_buffer)->end_date; \
} \
} \
/* we'll keep that for a while --Meuuh */ \
/* else printf("%s:%d\n", __FILE__, __LINE__); */ \
}
#define aout_BufferFree( p_buffer ) \
......@@ -184,6 +189,7 @@ struct aout_input_t
aout_fifo_t fifo;
mtime_t next_packet_date;
byte_t * p_first_byte_to_mix;
};
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_ext-dec.h,v 1.68 2002/08/08 00:35:10 sam Exp $
* $Id: input_ext-dec.h,v 1.69 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -118,6 +118,7 @@ struct decoder_fifo_t
vlc_fourcc_t i_fourcc;
es_sys_t * p_demux_data;
stream_ctrl_t * p_stream_ctrl;
sout_instance_t * p_sout;
/* Module properties */
module_t * p_module;
......
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.75 2002/08/07 00:29:36 sam Exp $
* $Id: input_ext-intf.h,v 1.76 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -233,6 +233,9 @@ struct stream_descriptor_t
/* Stream control */
stream_ctrl_t control;
/* Optional stream output */
sout_instance_t * p_sout;
/* Input info */
input_info_category_t * p_info;
......
/*****************************************************************************
* stream_output.h : stream output module
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: stream_output.h,v 1.1 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* 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
* (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.
*
* 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.
*****************************************************************************/
/*****************************************************************************
* sout_instance_t: stream output thread descriptor
*****************************************************************************/
struct sout_instance_t
{
VLC_COMMON_MEMBERS
char * psz_dest;
char * psz_access;
char * psz_mux;
char * psz_name;
module_t * p_access;
module_t * p_mux;
};
/*****************************************************************************
* Prototypes
*****************************************************************************/
#define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
VLC_EXPORT( sout_instance_t *, __sout_NewInstance, ( vlc_object_t *, char * ) );
VLC_EXPORT( void, sout_DeleteInstance, ( sout_instance_t * ) );
sout_fifo_t * sout_CreateFifo ( void );
void sout_DestroyFifo ( sout_fifo_t * );
void sout_FreeFifo ( sout_fifo_t * );
/*****************************************************************************
* sout.h: video output header for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: sout.h,v 1.1 2002/08/12 22:12:50 massiot Exp $
*
* 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
* (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.
*
* 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.
*****************************************************************************/
#ifndef _VLC_SOUT_H
#define _VLC_SOUT_H 1
# ifdef __cplusplus
extern "C" {
# endif
/*****************************************************************************
* Required public headers
*****************************************************************************/
#include <vlc/vlc.h>
/*****************************************************************************
* Required internal headers
*****************************************************************************/
#include "stream_output.h"
# ifdef __cplusplus
}
# endif
#endif /* <vlc/sout.h> */
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.18 2002/08/12 09:34:15 sam Exp $
* $Id: vlc_common.h,v 1.19 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -190,6 +190,10 @@ typedef struct picture_heap_t picture_heap_t;
typedef struct subpicture_t subpicture_t;
typedef struct subpicture_sys_t subpicture_sys_t;
/* Stream output */
typedef struct sout_instance_t sout_instance_t;
typedef struct sout_fifo_t sout_fifo_t;
/* Decoders */
typedef struct decoder_fifo_t decoder_fifo_t;
......
......@@ -2,7 +2,7 @@
* vlc_objects.h: vlc_object_t definition.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlc_objects.h,v 1.6 2002/08/12 09:34:15 sam Exp $
* $Id: vlc_objects.h,v 1.7 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -31,6 +31,7 @@
#define VLC_OBJECT_DECODER (-7)
#define VLC_OBJECT_VOUT (-8)
#define VLC_OBJECT_AOUT (-9)
#define VLC_OBJECT_SOUT (-10)
#define VLC_OBJECT_GENERIC (-666)
/* Object search mode */
......
......@@ -60,6 +60,7 @@ struct module_symbols_t
pgrm_descriptor_t * (* input_AddProgram_inner) ( input_thread_t *, u16, size_t ) ;
pgrm_descriptor_t * (* input_FindProgram_inner) ( input_thread_t *, u16 ) ;
picture_t * (* vout_CreatePicture_inner) ( vout_thread_t *, vlc_bool_t, vlc_bool_t, vlc_bool_t ) ;
sout_instance_t * (* __sout_NewInstance_inner) ( vlc_object_t *, char * ) ;
ssize_t (* input_FDNetworkRead_inner) ( input_thread_t *, byte_t *, size_t ) ;
ssize_t (* input_FDRead_inner) ( input_thread_t *, byte_t *, size_t ) ;
ssize_t (* input_FillBuffer_inner) ( input_thread_t * ) ;
......@@ -124,6 +125,7 @@ struct module_symbols_t
void (* msleep_inner) ( mtime_t delay ) ;
void (* mwait_inner) ( mtime_t date ) ;
void (* playlist_Command_inner) ( playlist_t *, int, int ) ;
void (* sout_DeleteInstance_inner) ( sout_instance_t * ) ;
void (* vout_AllocatePicture_inner) ( vout_thread_t *, picture_t *, int, int, u32 ) ;
void (* vout_DatePicture_inner) ( vout_thread_t *, picture_t *, mtime_t ) ;
void (* vout_DestroyPicture_inner) ( vout_thread_t *, picture_t * ) ;
......@@ -181,6 +183,7 @@ struct module_symbols_t
# define __msg_Warn p_symbols->__msg_Warn_inner
# define __network_ChannelCreate p_symbols->__network_ChannelCreate_inner
# define __network_ChannelJoin p_symbols->__network_ChannelJoin_inner
# define __sout_NewInstance p_symbols->__sout_NewInstance_inner
# define __vlc_cond_destroy p_symbols->__vlc_cond_destroy_inner
# define __vlc_cond_init p_symbols->__vlc_cond_init_inner
# define __vlc_dumpstructure p_symbols->__vlc_dumpstructure_inner
......@@ -262,6 +265,7 @@ struct module_symbols_t
# define playlist_Add p_symbols->playlist_Add_inner
# define playlist_Command p_symbols->playlist_Command_inner
# define playlist_Delete p_symbols->playlist_Delete_inner
# define sout_DeleteInstance p_symbols->sout_DeleteInstance_inner
# define vout_AllocatePicture p_symbols->vout_AllocatePicture_inner
# define vout_ChromaCmp p_symbols->vout_ChromaCmp_inner
# define vout_CreatePicture p_symbols->vout_CreatePicture_inner
......
......@@ -2,7 +2,7 @@
* trivial.c : trivial resampler (skips samples or pads with zeroes)
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: trivial.c,v 1.2 2002/08/10 20:01:00 massiot Exp $
* $Id: trivial.c,v 1.3 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -50,7 +50,7 @@ vlc_module_begin();
vlc_module_end();
/*****************************************************************************
* Create: allocate trivial mixer
* Create: allocate trivial resampler
*****************************************************************************
* This function allocates and initializes a Crop vout method.
*****************************************************************************/
......
......@@ -2,7 +2,7 @@
* trivial.c : trivial mixer plug-in (1 input, no downmixing)
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: trivial.c,v 1.3 2002/08/11 22:36:35 massiot Exp $
* $Id: trivial.c,v 1.4 2002/08/12 22:12:50 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -146,7 +146,6 @@ static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
(u32 *)p_input->p_first_byte_to_mix;
u32 * p_out = (u32 *)p_buffer->p_buffer;
if ( p_input->input.i_channels < p_aout->mixer.output.i_channels )
{
/* Zero out the destination buffer, to avoid static on unavailable
......
......@@ -2,7 +2,7 @@
* file.c : audio output which writes the samples to a file
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: file.c,v 1.3 2002/08/09 23:47:23 massiot Exp $
* $Id: file.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -33,6 +33,8 @@
#include "aout_internal.h"
#define FRAME_SIZE 2048
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
......@@ -126,7 +128,7 @@ static int SetFormat( aout_instance_t * p_aout )
}
p_aout->output.output.i_format = format_int[i];
p_aout->output.i_nb_samples = 2048;
p_aout->output.i_nb_samples = FRAME_SIZE;
return 0;
}
......
......@@ -2,7 +2,7 @@
* spdif.c: A52 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001-2002 VideoLAN
* $Id: spdif.c,v 1.3 2002/08/11 23:26:28 massiot Exp $
* $Id: spdif.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
......@@ -217,8 +217,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
p_buffer->end_date = last_date;
/* Get the whole frame. */
memcpy( p_buffer->p_buffer + sizeof(u16), p_header, 7 );
GetChunk( &p_dec->bit_stream, p_buffer->p_buffer + 7 + sizeof(u16),
memcpy( p_buffer->p_buffer, p_header, 7 );
GetChunk( &p_dec->bit_stream, p_buffer->p_buffer + 7,
i_frame_size - 7 );
if( p_dec->p_fifo->b_die ) break;
......
......@@ -2,7 +2,7 @@
* aout_dummy.c : dummy audio output plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: aout.c,v 1.2 2002/08/07 21:36:56 massiot Exp $
* $Id: aout.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -32,6 +32,8 @@
#include "aout_internal.h"
#define FRAME_SIZE 2048
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
......@@ -56,7 +58,7 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
*****************************************************************************/
static int SetFormat( aout_instance_t * p_aout )
{
p_aout->output.i_nb_samples = 2048;
p_aout->output.i_nb_samples = FRAME_SIZE;
return 0;
}
......
......@@ -2,7 +2,7 @@
* aout_sdl.c : audio sdl functions library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: aout.c,v 1.3 2002/08/12 09:34:15 sam Exp $
* $Id: aout.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -38,7 +38,7 @@
#include SDL_INCLUDE_FILE
#define DEFAULT_FRAME_SIZE 2048
#define FRAME_SIZE 2048
/*****************************************************************************
* Local prototypes
......@@ -94,9 +94,9 @@ static int SetFormat( aout_instance_t *p_aout )
desired.channels = p_aout->output.output.i_channels;
desired.callback = SDLCallback;
desired.userdata = p_aout;
desired.samples = DEFAULT_FRAME_SIZE;
desired.samples = FRAME_SIZE;
/* Open the sound device - FIXME : get the "natural" paramaters */
/* Open the sound device - FIXME : get the "natural" parameters */
if( SDL_OpenAudio( &desired, NULL ) < 0 )
{
return -1;
......@@ -143,7 +143,7 @@ static void SDLCallback( void * _p_aout, byte_t * p_stream, int i_len )
/* FIXME : take into account SDL latency instead of mdate() */
aout_buffer_t * p_buffer = aout_OutputNextBuffer( p_aout, mdate() );
if ( i_len != DEFAULT_FRAME_SIZE * sizeof(s16)
if ( i_len != FRAME_SIZE * sizeof(s16)
* p_aout->output.output.i_channels )
{
msg_Err( p_aout, "SDL doesn't know its buffer size (%d)", i_len );
......
......@@ -2,7 +2,7 @@
* input.c : internal management of input streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: input.c,v 1.2 2002/08/09 23:47:23 massiot Exp $
* $Id: input.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -68,6 +68,7 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
/* Prepare FIFO. */
aout_FifoInit( p_aout, &p_input->fifo );
p_input->p_first_byte_to_mix = NULL;
p_input->next_packet_date = 0;
/* Create filters. */
if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
......
......@@ -2,7 +2,7 @@
* mixer.c : audio output mixing operations
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: mixer.c,v 1.2 2002/08/11 22:36:35 massiot Exp $
* $Id: mixer.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -110,7 +110,7 @@ void aout_MixerRun( aout_instance_t * p_aout )
/* Run the mixer. */
aout_BufferAlloc( &p_aout->mixer.output_alloc,
(u64)(p_aout->output.i_nb_samples * 1000000)
((u64)p_aout->output.i_nb_samples * 1000000)
/ p_aout->output.output.i_rate,
/* This is a bit kludgy, but is actually only used
* for the S/PDIF dummy mixer : */
......
......@@ -2,7 +2,7 @@
* output.c : internal management of output streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: output.c,v 1.3 2002/08/11 22:36:35 massiot Exp $
* $Id: output.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -155,9 +155,14 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
/*****************************************************************************
* aout_OutputNextBuffer : give the audio output plug-in the right buffer
*****************************************************************************
* If b_can_sleek is 1, the aout core functions won't try to resample
* new buffers to catch up - that is we suppose that the output plug-in can
* do it by itself. S/PDIF outputs should always set b_can_sleek = 1.
*****************************************************************************/
aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
mtime_t start_date )
mtime_t start_date /*,
vlc_bool_t b_can_sleek */ )
{
aout_buffer_t * p_buffer;
......@@ -180,9 +185,10 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
return NULL;
}
/* Here we suppose that all buffers have the same duration - this is
* generally true, and anyway if it's wrong it won't be a disaster. */
if ( p_buffer->start_date > start_date
+ (mtime_t)p_aout->output.i_nb_samples
* 1000000 / p_aout->output.output.i_rate )
+ (p_buffer->end_date - p_buffer->start_date) )
{
vlc_mutex_unlock( &p_aout->output.fifo.lock );
msg_Dbg( p_aout, "audio output is starving (%lld)",
......@@ -190,8 +196,22 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
return NULL;
}
/* FIXME : there we should handle the case where start_date is not
* completely equal to p_buffer->start_date. */
#if 0
if ( !b_can_sleek )
{
/* Try to compensate the drift by doing some resampling. */
int i;
/* Take the mixer lock because no input can be removed when the
* the mixer lock is taken. */
vlc_mutex_lock( &p_aout->mixer_lock );
for ( i = 0; i < p_input->i_nb_inputs; i++ )
{
aout_input_t * p_input = p_aout->pp_inputs[i];
}
vlc_mutex_lock( &p_aout->mixer_lock );
}
#endif
p_aout->output.fifo.p_first = p_buffer->p_next;
if ( p_buffer->p_next == NULL )
......
......@@ -3,8 +3,8 @@
* Read an MPEG2 stream, demultiplex and parse it before sending it to
* decoders.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input.c,v 1.209 2002/07/31 20:56:52 sam Exp $
* Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.210 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -48,6 +48,8 @@
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
#include "stream_output.h"
#include "interface.h"
/*****************************************************************************
......@@ -114,6 +116,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
p_input->stream.b_new_mute = MUTE_NO_CHANGE;
p_input->stream.i_mux_rate = 0;
p_input->stream.b_seekable = 0;
p_input->stream.p_sout = NULL;
/* no stream, no program, no area, no es */
p_input->stream.p_new_program = NULL;
......@@ -497,6 +500,23 @@ static int InitThread( input_thread_t * p_input )
return -1;
}
/* Initialize optional stream output. */
psz_parser = config_GetPsz( p_input, "sout" );
if ( psz_parser != NULL )
{
if ( (p_input->stream.p_sout = sout_NewInstance( p_input, psz_parser ))
== NULL )
{
msg_Err( p_input, "cannot start stream output instance, aborting" );
free( psz_parser );
module_Unneed( p_input, p_input->p_access );
module_Unneed( p_input, p_input->p_demux );
return -1;
}
free( psz_parser );
}
return 0;
}
......@@ -539,6 +559,12 @@ static void EndThread( input_thread_t * p_input )
/* Free all ES and destroy all decoder threads */
input_EndStream( p_input );
/* Close optional stream output instance */
if ( p_input->stream.p_sout != NULL )
{
sout_DeleteInstance( p_input->stream.p_sout );
}
/* Free demultiplexer's data */
module_Unneed( p_input, p_input->p_demux );
......
......@@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_dec.c,v 1.44 2002/08/12 09:34:15 sam Exp $
* $Id: input_dec.c,v 1.45 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -228,6 +228,7 @@ static decoder_fifo_t * CreateDecoderFifo( input_thread_t * p_input,
p_fifo->p_demux_data = p_es->p_demux_data;
p_fifo->p_stream_ctrl = &p_input->stream.control;
p_fifo->p_sout = p_input->stream.p_sout;
p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first;
......
......@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.12 2002/08/08 00:35:11 sam Exp $
* $Id: libvlc.h,v 1.13 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -234,6 +234,10 @@
"'any' at the end of the list to make sure there is a fallback for the " \
"types you didn't specify.")
#define SOUT_TEXT N_("choose a stream output")
#define SOUT_LONGTEXT N_( \
"Empty if no stream output.")
#define MMX_TEXT N_("enable CPU MMX support")
#define MMX_LONGTEXT N_( \
"If your processor supports the MMX instructions set, vlc can take " \
......@@ -426,6 +430,7 @@ vlc_module_begin();
add_module( "memcpy", "memcpy", NULL, NULL, MEMCPY_TEXT, MEMCPY_LONGTEXT );
add_module( "access", "access", NULL, NULL, ACCESS_TEXT, ACCESS_LONGTEXT );
add_module( "demux", "demux", NULL, NULL, DEMUX_TEXT, DEMUX_LONGTEXT );
add_string( "sout", NULL, NULL, SOUT_TEXT, SOUT_LONGTEXT );
#if defined(WIN32)
add_bool( "fast-mutex", 0, NULL, FAST_MUTEX_TEXT, FAST_MUTEX_LONGTEXT );
......
......@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.83 2002/08/12 09:34:15 sam Exp $
* $Id: modules.c,v 1.84 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -71,6 +71,8 @@
#include "audio_output.h"
#include "stream_output.h"
#include "iso_lang.h"
#ifdef HAVE_DYNAMIC_PLUGINS
......
......@@ -273,6 +273,8 @@ static const char * module_error( char *psz_buffer )
(p_symbols)->msleep_inner = msleep; \
(p_symbols)->__network_ChannelJoin_inner = __network_ChannelJoin; \
(p_symbols)->__network_ChannelCreate_inner = __network_ChannelCreate; \
(p_symbols)->__sout_NewInstance_inner = __sout_NewInstance; \
(p_symbols)->sout_DeleteInstance_inner = sout_DeleteInstance; \
(p_symbols)->__vout_CreateThread_inner = __vout_CreateThread; \
(p_symbols)->vout_DestroyThread_inner = vout_DestroyThread; \
(p_symbols)->vout_ChromaCmp_inner = vout_ChromaCmp; \
......
/*****************************************************************************
* stream_output.c : stream output module
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: stream_output.c,v 1.1 2002/08/12 22:12:51 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* 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
* (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.
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
#include <vlc/vlc.h>
#include <vlc/sout.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int InitInstance ( sout_instance_t * );
/*****************************************************************************
* sout_NewInstance: creates a new stream output instance
*****************************************************************************/
sout_instance_t * __sout_NewInstance ( vlc_object_t *p_parent,
char * psz_dest )
{
sout_instance_t * p_sout;
/* Allocate descriptor */
p_sout = vlc_object_create( p_parent, VLC_OBJECT_SOUT );
if( p_sout == NULL )
{
msg_Err( p_parent, "out of memory" );
return NULL;
}
p_sout->psz_dest = psz_dest;
if ( InitInstance( p_sout ) == -1 )
{
vlc_object_destroy( p_sout );
return NULL;
}
return p_sout;
}
/*****************************************************************************
* InitInstance: opens appropriate modules
*****************************************************************************/
static int InitInstance( sout_instance_t * p_sout )
{
/* Parse dest string. Syntax : [[<access>][/<mux>]:][<dest>] */
/* This code is identical to input.c:InitThread. FIXME : factorize it ? */
char * psz_parser = p_sout->psz_dest;
/* Skip the plug-in names */
while( *psz_parser && *psz_parser != ':' )
{
psz_parser++;
}
#ifdef WIN32
if( psz_parser - psz_dest == 1 )
{
msg_Warn( p_sout, "drive letter %c: found in source string",
p_sout->psz_dest ) ;
psz_parser = "";
}
#endif
if( !*psz_parser )
{
p_sout->psz_access = p_sout->psz_mux = "";
p_sout->psz_name = p_sout->psz_dest;
}
else
{
*psz_parser++ = '\0';
/* let's skip '//' */
if( psz_parser[0] == '/' && psz_parser[1] == '/' )
{
psz_parser += 2 ;
}
p_sout->psz_name = psz_parser ;
/* Come back to parse the access and mux plug-ins */
psz_parser = p_sout->psz_dest;
if( !*psz_parser )
{
/* No access */
p_sout->psz_access = "";
}
else if( *psz_parser == '/' )
{
/* No access */
p_sout->psz_access = "";
psz_parser++;
}
else
{
p_sout->psz_access = psz_parser;
while( *psz_parser && *psz_parser != '/' )
{
psz_parser++;
}
if( *psz_parser == '/' )
{
*psz_parser++ = '\0';
}
}
if( !*psz_parser )
{
/* No mux */
p_sout->psz_mux = "";
}
else
{
p_sout->psz_mux = psz_parser;
}
}
msg_Dbg( p_sout, "access `%s', mux `%s', name `%s'",
p_sout->psz_access, p_sout->psz_mux, p_sout->psz_name );
/* Find and open appropriate access module */
p_sout->p_access =
module_Need( p_sout, "sout access", p_sout->psz_access );
if( p_sout->p_access == NULL )
{
msg_Err( p_sout, "no suitable sout access module for `%s/%s://%s'",
p_sout->psz_access, p_sout->psz_mux, p_sout->psz_name );
return -1;
}
/* Find and open appropriate mux module */
p_sout->p_mux =
module_Need( p_sout, "sout mux", p_sout->psz_mux );
if( p_sout->p_mux == NULL )
{
msg_Err( p_sout, "no suitable mux module for `%s/%s://%s'",
p_sout->psz_access, p_sout->psz_mux, p_sout->psz_name );
module_Unneed( p_sout, p_sout->p_access );
return -1;
}
}
/*****************************************************************************
* sout_DeleteInstance: delete a previously allocated instance
*****************************************************************************/
void sout_DeleteInstance( sout_instance_t * p_sout )
{
/* Unlink object */
vlc_object_detach( p_sout );
/* Free structure */
vlc_object_destroy( p_sout );
}
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