Commit 5c2cf083 authored by Gildas Bazin's avatar Gildas Bazin

* src/stream_output/stream_output.c, include/stream_output.h: new sout_AccessOutRead() funcion.
* modules/access_output/file.c: implemented sout_AccessOutRead().
* modules/access_output/udp.c: coding style cleanup.
* modules/mux/mp4.c: Added support for generating "fast start" files (ie. with the moov header at the beginning of the file).
   Started some code cleanup.
parent 83fb2ffc
......@@ -2,7 +2,7 @@
* stream_output.h : stream output module
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: stream_output.h,v 1.18 2003/12/07 17:09:33 gbazin Exp $
* $Id: stream_output.h,v 1.19 2004/01/23 17:56:14 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
......@@ -121,6 +121,8 @@ struct sout_access_out_t
sout_access_out_sys_t *p_sys;
int (* pf_seek )( sout_access_out_t *,
off_t );
int (* pf_read )( sout_access_out_t *,
sout_buffer_t * );
int (* pf_write )( sout_access_out_t *,
sout_buffer_t * );
};
......@@ -295,6 +297,7 @@ VLC_EXPORT( void, sout_BufferChain, ( sout_buffer_t **, sout_buffer_t
VLC_EXPORT( sout_access_out_t *, sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
VLC_EXPORT( void, sout_AccessOutDelete, ( sout_access_out_t * ) );
VLC_EXPORT( int, sout_AccessOutSeek, ( sout_access_out_t *, off_t ) );
VLC_EXPORT( int, sout_AccessOutRead, ( sout_access_out_t *, sout_buffer_t * ) );
VLC_EXPORT( int, sout_AccessOutWrite, ( sout_access_out_t *, sout_buffer_t * ) );
VLC_EXPORT( sout_mux_t *, sout_MuxNew, ( sout_instance_t*, char *, sout_access_out_t * ) );
......
......@@ -2,7 +2,7 @@
* file.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: file.c,v 1.10 2003/12/04 12:33:43 gbazin Exp $
* $Id: file.c,v 1.11 2004/01/23 17:56:14 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -61,6 +61,7 @@ static void Close ( vlc_object_t * );
static int Write( sout_access_out_t *, sout_buffer_t * );
static int Seek ( sout_access_out_t *, off_t );
static int Read ( sout_access_out_t *, sout_buffer_t * );
/*****************************************************************************
* Module descriptor
......@@ -97,7 +98,7 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_access, "no file name specified" );
return VLC_EGENERIC;
}
i_flags = O_WRONLY|O_CREAT;
i_flags = O_RDWR|O_CREAT;
if( sout_cfg_find_value( p_access->p_cfg, "append" ) )
{
i_flags |= O_APPEND;
......@@ -120,8 +121,9 @@ static int Open( vlc_object_t *p_this )
return( VLC_EGENERIC );
}
p_access->pf_write = Write;
p_access->pf_seek = Seek;
p_access->pf_write = Write;
p_access->pf_read = Read;
p_access->pf_seek = Seek;
msg_Info( p_access, "Open: name:`%s'", p_access->psz_name );
return VLC_SUCCESS;
......@@ -132,7 +134,7 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
static void Close( vlc_object_t * p_this )
{
sout_access_out_t *p_access = (sout_access_out_t*)p_this;
sout_access_out_t *p_access = (sout_access_out_t*)p_this;
if( strcmp( p_access->psz_name, "-" ) )
{
......@@ -149,6 +151,23 @@ static void Close( vlc_object_t * p_this )
/*****************************************************************************
* Read: standard read on a file descriptor.
*****************************************************************************/
static int Read( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{
if( strcmp( p_access->psz_name, "-" ) )
{
return read( p_access->p_sys->i_handle, p_buffer->p_buffer,
p_buffer->i_size );
}
else
{
msg_Err( p_access, "cannot seek while using stdout" );
return VLC_EGENERIC;
}
}
/*****************************************************************************
* Write: standard write on a file descriptor.
*****************************************************************************/
static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{
size_t i_write = 0;
......@@ -173,7 +192,7 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
*****************************************************************************/
static int Seek( sout_access_out_t *p_access, off_t i_pos )
{
msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos );
//msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos );
if( strcmp( p_access->psz_name, "-" ) )
{
......
......@@ -2,7 +2,7 @@
* udp.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.16 2003/11/17 14:46:37 massiot Exp $
* $Id: udp.c,v 1.17 2004/01/23 17:56:14 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -53,8 +53,6 @@
#include "network.h"
#define DEFAULT_PORT 1234
#define LATENCY 100000
#define MAX_ERROR 500000
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
......@@ -130,13 +128,14 @@ static int Open( vlc_object_t *p_this )
module_t *p_network;
network_socket_t socket_desc;
char *val;
vlc_value_t val;
char *psz_val;
if( !( p_sys = p_access->p_sys =
malloc( sizeof( sout_access_out_sys_t ) ) ) )
{
msg_Err( p_access, "Not enough memory" );
return( VLC_EGENERIC );
return VLC_EGENERIC;
}
......@@ -184,7 +183,7 @@ static int Open( vlc_object_t *p_this )
if( !p_sys->p_thread )
{
msg_Err( p_access, "out of memory" );
return( VLC_EGENERIC );
return VLC_EGENERIC;
}
p_sys->p_thread->p_sout = p_access->p_sout;
......@@ -198,34 +197,37 @@ static int Open( vlc_object_t *p_this )
socket_desc.psz_bind_addr = "";
socket_desc.i_bind_port = 0;
socket_desc.i_ttl = 0;
if( ( val = sout_cfg_find_value( p_access->p_cfg, "ttl" ) ) )
if( ( psz_val = sout_cfg_find_value( p_access->p_cfg, "ttl" ) ) )
{
socket_desc.i_ttl = atoi( val );
socket_desc.i_ttl = atoi( psz_val );
}
p_sys->p_thread->p_private = (void*)&socket_desc;
if( !( p_network = module_Need( p_sys->p_thread,
"network", "" ) ) )
if( !( p_network = module_Need( p_sys->p_thread, "network", "" ) ) )
{
msg_Err( p_access, "failed to open a connection (udp)" );
return( VLC_EGENERIC );
return VLC_EGENERIC;
}
module_Unneed( p_sys->p_thread, p_network );
p_sys->p_thread->i_handle = socket_desc.i_handle;
p_sys->p_thread->i_caching = config_GetInt( p_this, "udp-sout-caching" ) * 1000;
if( ( val = sout_cfg_find_value( p_access->p_cfg, "caching" ) ) )
var_Create( p_this, "udp-sout-caching",
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_this, "udp-sout-caching", &val );
p_sys->p_thread->i_caching = val.i_int * 1000;
if( ( psz_val = sout_cfg_find_value( p_access->p_cfg, "caching" ) ) )
{
p_sys->p_thread->i_caching = atoll( val ) * 1000;
p_sys->p_thread->i_caching = atoll( psz_val ) * 1000;
}
p_sys->i_mtu = socket_desc.i_mtu;
p_sys->i_mtu = socket_desc.i_mtu;
if( vlc_thread_create( p_sys->p_thread, "sout write thread", ThreadWrite,
VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
{
msg_Err( p_access->p_sout, "cannot spawn sout access thread" );
vlc_object_destroy( p_sys->p_thread );
return( VLC_EGENERIC );
return VLC_EGENERIC;
}
srand( (uint32_t)mdate());
......@@ -235,16 +237,16 @@ static int Open( vlc_object_t *p_this )
if( sout_cfg_find( p_access->p_cfg, "raw" ) )
{
p_access->pf_write = WriteRaw;
p_access->pf_write = WriteRaw;
}
else
{
p_access->pf_write = Write;
p_access->pf_write = Write;
}
p_access->pf_seek = Seek;
msg_Info( p_access, "Open: addr:`%s' port:`%d'",
psz_dst_addr, i_dst_port );
p_access->pf_seek = Seek;
msg_Info( p_access, "Open: addr:`%s' port:`%d'", psz_dst_addr, i_dst_port);
free( psz_dst_addr );
return VLC_SUCCESS;
......@@ -255,14 +257,14 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
static void Close( vlc_object_t * p_this )
{
sout_access_out_t *p_access = (sout_access_out_t*)p_this;
sout_access_out_sys_t *p_sys = p_access->p_sys;
int i;
sout_access_out_t *p_access = (sout_access_out_t*)p_this;
sout_access_out_sys_t *p_sys = p_access->p_sys;
int i;
p_sys->p_thread->b_die = 1;
for( i = 0; i < 10; i++ )
{
sout_buffer_t *p_dummy;
sout_buffer_t *p_dummy;
p_dummy = sout_BufferNew( p_access->p_sout, p_sys->i_mtu );
p_dummy->i_dts = 0;
......@@ -296,7 +298,7 @@ static void Close( vlc_object_t * p_this )
*****************************************************************************/
static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{
sout_access_out_sys_t *p_sys = p_access->p_sys;
sout_access_out_sys_t *p_sys = p_access->p_sys;
unsigned int i_write;
while( p_buffer )
......@@ -356,7 +358,6 @@ static int WriteRaw( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
*****************************************************************************/
static int Seek( sout_access_out_t *p_access, off_t i_pos )
{
msg_Err( p_access, "udp sout access cannot seek" );
return( -1 );
}
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* stream_output.c : stream output module
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
* $Id: stream_output.c,v 1.37 2004/01/06 12:02:06 zorglub Exp $
* $Id: stream_output.c,v 1.38 2004/01/23 17:56:14 gbazin Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
......@@ -238,7 +238,8 @@ int sout_InputDelete( sout_packetizer_input_t *p_input )
}
int sout_InputSendBuffer( sout_packetizer_input_t *p_input, sout_buffer_t *p_buffer )
int sout_InputSendBuffer( sout_packetizer_input_t *p_input,
sout_buffer_t *p_buffer )
{
sout_instance_t *p_sout = p_input->p_sout;
int i_ret;
......@@ -272,7 +273,8 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
return NULL;
}
psz_next = sout_cfg_parser( &p_access->psz_access, &p_access->p_cfg, psz_access );
psz_next = sout_cfg_parser( &p_access->psz_access, &p_access->p_cfg,
psz_access );
if( psz_next )
{
free( psz_next );
......@@ -281,6 +283,7 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
p_access->p_sout = p_sout;
p_access->p_sys = NULL;
p_access->pf_seek = NULL;
p_access->pf_read = NULL;
p_access->pf_write = NULL;
p_access->p_module =
......@@ -317,19 +320,27 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
/*****************************************************************************
* sout_AccessSeek:
*****************************************************************************/
int sout_AccessOutSeek( sout_access_out_t *p_access, off_t i_pos )
int sout_AccessOutSeek( sout_access_out_t *p_access, off_t i_pos )
{
return( p_access->pf_seek( p_access, i_pos ) );
return p_access->pf_seek( p_access, i_pos );
}
/*****************************************************************************
* sout_AccessWrite:
* sout_AccessRead:
*****************************************************************************/
int sout_AccessOutWrite( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
int sout_AccessOutRead( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{
return( p_access->pf_write( p_access, p_buffer ) );
return ( p_access->pf_read ?
p_access->pf_read( p_access, p_buffer ) : VLC_EGENERIC );
}
/*****************************************************************************
* sout_AccessWrite:
*****************************************************************************/
int sout_AccessOutWrite( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
{
return p_access->pf_write( p_access, p_buffer );
}
/*****************************************************************************
* MuxNew: allocate a new mux
......
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