Commit 298f0e46 authored by Laurent Aimar's avatar Laurent Aimar

* access_output: sout_buffer_t -> block_t.

parent 1007fd93
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dummy.c * dummy.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: dummy.c,v 1.3 2003/03/03 14:21:08 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -26,32 +26,16 @@ ...@@ -26,32 +26,16 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
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 );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin(); vlc_module_begin();
set_description( _("Dummy stream ouput") ); set_description( _("Dummy stream ouput") );
set_capability( "sout access", 0 ); set_capability( "sout access", 0 );
...@@ -60,6 +44,12 @@ vlc_module_begin(); ...@@ -60,6 +44,12 @@ vlc_module_begin();
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Write( sout_access_out_t *, block_t * );
static int Seek ( sout_access_out_t *, off_t );
/***************************************************************************** /*****************************************************************************
* Open: open the file * Open: open the file
*****************************************************************************/ *****************************************************************************/
...@@ -71,7 +61,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -71,7 +61,7 @@ static int Open( vlc_object_t *p_this )
p_access->pf_write = Write; p_access->pf_write = Write;
p_access->pf_seek = Seek; p_access->pf_seek = Seek;
msg_Info( p_access, "dummy stream output access launched" ); msg_Dbg( p_access, "dummy stream output access opened" );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -81,28 +71,27 @@ static int Open( vlc_object_t *p_this ) ...@@ -81,28 +71,27 @@ static int Open( vlc_object_t *p_this )
static void Close( 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;
msg_Info( p_access, "Close" ); msg_Dbg( p_access, "dummy stream output access closed" );
} }
/***************************************************************************** /*****************************************************************************
* Read: standard read on a file descriptor. * Read: standard read on a file descriptor.
*****************************************************************************/ *****************************************************************************/
static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) static int Write( sout_access_out_t *p_access, block_t *p_buffer )
{ {
size_t i_write = 0; int64_t i_write = 0;
block_t *b = p_buffer;
do while( b )
{ {
sout_buffer_t *p_next; i_write += b->i_buffer;
i_write += p_buffer->i_size;
p_next = p_buffer->p_next; b = b->p_next;
sout_BufferDelete( p_access->p_sout, p_buffer ); }
p_buffer = p_next;
} while( p_buffer );
msg_Dbg( p_access, "Dummy Skipped: len:"I64Fd, (int64_t)i_write ); block_ChainRelease( p_buffer );
return( i_write ); return i_write;
} }
/***************************************************************************** /*****************************************************************************
...@@ -110,8 +99,7 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -110,8 +99,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 ) static int Seek( sout_access_out_t *p_access, off_t i_pos )
{ {
msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos ); return 0;
return( 0 );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* file.c * file.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: file.c,v 1.11 2004/01/23 17:56:14 gbazin Exp $ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -29,11 +29,10 @@ ...@@ -29,11 +29,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
...@@ -53,19 +52,12 @@ ...@@ -53,19 +52,12 @@
# define STDOUT_FILENO 1 # define STDOUT_FILENO 1
#endif #endif
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
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 * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin(); vlc_module_begin();
set_description( _("File stream ouput") ); set_description( _("File stream ouput") );
set_capability( "sout access", 50 ); set_capability( "sout access", 50 );
...@@ -73,10 +65,17 @@ vlc_module_begin(); ...@@ -73,10 +65,17 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Write( sout_access_out_t *, block_t * );
static int Seek ( sout_access_out_t *, off_t );
static int Read ( sout_access_out_t *, block_t * );
struct sout_access_out_sys_t struct sout_access_out_sys_t
{ {
int i_handle; int i_handle;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -125,7 +124,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -125,7 +124,7 @@ static int Open( vlc_object_t *p_this )
p_access->pf_read = Read; p_access->pf_read = Read;
p_access->pf_seek = Seek; p_access->pf_seek = Seek;
msg_Info( p_access, "Open: name:`%s'", p_access->psz_name ); msg_Dbg( p_access, "file access output opened (`%s')", p_access->psz_name );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -145,46 +144,43 @@ static void Close( vlc_object_t * p_this ) ...@@ -145,46 +144,43 @@ static void Close( vlc_object_t * p_this )
} }
free( p_access->p_sys ); free( p_access->p_sys );
msg_Info( p_access, "Close" ); msg_Dbg( p_access, "file access output closed" );
} }
/***************************************************************************** /*****************************************************************************
* Read: standard read on a file descriptor. * Read: standard read on a file descriptor.
*****************************************************************************/ *****************************************************************************/
static int Read( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) static int Read( sout_access_out_t *p_access, block_t *p_buffer )
{ {
if( strcmp( p_access->psz_name, "-" ) ) if( strcmp( p_access->psz_name, "-" ) )
{ {
return read( p_access->p_sys->i_handle, p_buffer->p_buffer, return read( p_access->p_sys->i_handle, p_buffer->p_buffer,
p_buffer->i_size ); p_buffer->i_buffer );
}
else
{
msg_Err( p_access, "cannot seek while using stdout" );
return VLC_EGENERIC;
} }
msg_Err( p_access, "cannot read while using stdout" );
return VLC_EGENERIC;
} }
/***************************************************************************** /*****************************************************************************
* Write: standard write on a file descriptor. * Write: standard write on a file descriptor.
*****************************************************************************/ *****************************************************************************/
static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) static int Write( sout_access_out_t *p_access, block_t *p_buffer )
{ {
size_t i_write = 0; size_t i_write = 0;
do while( p_buffer )
{ {
sout_buffer_t *p_next; block_t *p_next = p_buffer->p_next;;
i_write += write( p_access->p_sys->i_handle, p_buffer->p_buffer, i_write += write( p_access->p_sys->i_handle,
p_buffer->i_size ); p_buffer->p_buffer, p_buffer->i_buffer );
p_next = p_buffer->p_next; block_Release( p_buffer );
sout_BufferDelete( p_access->p_sout, p_buffer );
p_buffer = p_next;
} while( p_buffer ); p_buffer = p_next;
}
return( i_write ); return i_write;
} }
/***************************************************************************** /*****************************************************************************
...@@ -192,8 +188,6 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -192,8 +188,6 @@ 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 ) static int Seek( sout_access_out_t *p_access, off_t i_pos )
{ {
//msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos );
if( strcmp( p_access->psz_name, "-" ) ) if( strcmp( p_access->psz_name, "-" ) )
{ {
#if defined( WIN32 ) && !defined( UNDER_CE ) #if defined( WIN32 ) && !defined( UNDER_CE )
......
...@@ -25,11 +25,8 @@ ...@@ -25,11 +25,8 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#include "vlc_httpd.h" #include "vlc_httpd.h"
...@@ -38,18 +35,12 @@ ...@@ -38,18 +35,12 @@
#define DEFAULT_PORT 8080 #define DEFAULT_PORT 8080
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
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 );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin(); vlc_module_begin();
set_description( _("HTTP stream ouput") ); set_description( _("HTTP stream ouput") );
set_capability( "sout access", 0 ); set_capability( "sout access", 0 );
...@@ -58,6 +49,13 @@ vlc_module_begin(); ...@@ -58,6 +49,13 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Write( sout_access_out_t *, block_t * );
static int Seek ( sout_access_out_t *, off_t );
struct sout_access_out_sys_t struct sout_access_out_sys_t
{ {
/* host */ /* host */
...@@ -73,56 +71,6 @@ struct sout_access_out_sys_t ...@@ -73,56 +71,6 @@ struct sout_access_out_sys_t
vlc_bool_t b_header_complete; vlc_bool_t b_header_complete;
}; };
#if 0
static struct
{
char *psz_ext;
char *psz_mime;
} http_mime[] =
{
{ ".avi", "video/avi" },
{ ".asf", "video/x-ms-asf" },
{ ".m1a", "audio/mpeg" },
{ ".m2a", "audio/mpeg" },
{ ".m1v", "video/mpeg" },
{ ".m2v", "video/mpeg" },
{ ".mp2", "audio/mpeg" },
{ ".mp3", "audio/mpeg" },
{ ".mpa", "audio/mpeg" },
{ ".mpg", "video/mpeg" },
{ ".mpeg", "video/mpeg" },
{ ".mpe", "video/mpeg" },
{ ".mov", "video/quicktime" },
{ ".moov", "video/quicktime" },
{ ".ogg", "application/ogg" },
{ ".ogm", "application/ogg" },
{ ".wma", "audio/x-ms-wma" },
{ ".wmv", "video/x-ms-wmv" },
{ ".wav", "audio/wav" },
{ NULL, NULL }
};
static char *GetMime( char *psz_name )
{
char *psz_ext;
psz_ext = strrchr( psz_name, '.' );
if( psz_ext )
{
int i;
for( i = 0; http_mime[i].psz_ext != NULL ; i++ )
{
if( !strcmp( http_mime[i].psz_ext, psz_ext ) )
{
return( http_mime[i].psz_mime );
}
}
}
return( "application/octet-stream" );
}
#endif
/***************************************************************************** /*****************************************************************************
* Open: open the file * Open: open the file
*****************************************************************************/ *****************************************************************************/
...@@ -272,16 +220,16 @@ static void Close( vlc_object_t * p_this ) ...@@ -272,16 +220,16 @@ static void Close( vlc_object_t * p_this )
/***************************************************************************** /*****************************************************************************
* Write: * Write:
*****************************************************************************/ *****************************************************************************/
static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) static int Write( sout_access_out_t *p_access, block_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;
int i_err = 0; int i_err = 0;
while( p_buffer ) while( p_buffer )
{ {
sout_buffer_t *p_next; block_t *p_next;
if( p_buffer->i_flags & SOUT_BUFFER_FLAGS_HEADER ) if( p_buffer->i_flags & BLOCK_FLAG_HEADER )
{ {
/* gather header */ /* gather header */
if( p_sys->b_header_complete ) if( p_sys->b_header_complete )
...@@ -290,18 +238,18 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -290,18 +238,18 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
p_sys->i_header_size = 0; p_sys->i_header_size = 0;
p_sys->b_header_complete = VLC_FALSE; p_sys->b_header_complete = VLC_FALSE;
} }
if( (int)(p_buffer->i_size + p_sys->i_header_size) > if( (int)(p_buffer->i_buffer + p_sys->i_header_size) >
p_sys->i_header_allocated ) p_sys->i_header_allocated )
{ {
p_sys->i_header_allocated = p_sys->i_header_allocated =
p_buffer->i_size + p_sys->i_header_size + 1024; p_buffer->i_buffer + p_sys->i_header_size + 1024;
p_sys->p_header = p_sys->p_header =
realloc( p_sys->p_header, p_sys->i_header_allocated ); realloc( p_sys->p_header, p_sys->i_header_allocated );
} }
memcpy( &p_sys->p_header[p_sys->i_header_size], memcpy( &p_sys->p_header[p_sys->i_header_size],
p_buffer->p_buffer, p_buffer->p_buffer,
p_buffer->i_size ); p_buffer->i_buffer );
p_sys->i_header_size += p_buffer->i_size; p_sys->i_header_size += p_buffer->i_buffer;
} }
else if( !p_sys->b_header_complete ) else if( !p_sys->b_header_complete )
{ {
...@@ -313,10 +261,10 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -313,10 +261,10 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
/* send data */ /* send data */
i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer, i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer,
p_buffer->i_size ); p_buffer->i_buffer );
p_next = p_buffer->p_next; p_next = p_buffer->p_next;
sout_BufferDelete( p_access->p_sout, p_buffer ); block_Release( p_buffer );
p_buffer = p_next; p_buffer = p_next;
if( i_err < 0 ) if( i_err < 0 )
...@@ -327,13 +275,7 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -327,13 +275,7 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
if( i_err < 0 ) if( i_err < 0 )
{ {
sout_buffer_t *p_next; block_ChainRelease( p_buffer );
while( p_buffer )
{
p_next = p_buffer->p_next;
sout_BufferDelete( p_access->p_sout, p_buffer );
p_buffer = p_next;
}
} }
return( i_err < 0 ? VLC_EGENERIC : VLC_SUCCESS ); return( i_err < 0 ? VLC_EGENERIC : VLC_SUCCESS );
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/sout.h> #include <vlc/sout.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
...@@ -52,24 +51,13 @@ ...@@ -52,24 +51,13 @@
#include "network.h" #include "network.h"
#define DEFAULT_PORT 1234
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static int Write ( sout_access_out_t *, sout_buffer_t * );
static int WriteRaw( sout_access_out_t *, sout_buffer_t * );
static int Seek ( sout_access_out_t *, off_t );
static void ThreadWrite( vlc_object_t * );
static sout_buffer_t *NewUDPPacket( sout_access_out_t *, mtime_t );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
#define CACHING_TEXT N_("Caching value (ms)") #define CACHING_TEXT N_("Caching value (ms)")
#define CACHING_LONGTEXT N_( \ #define CACHING_LONGTEXT N_( \
"Allows you to modify the default caching value for udp streams. This " \ "Allows you to modify the default caching value for udp streams. This " \
...@@ -85,13 +73,25 @@ vlc_module_begin(); ...@@ -85,13 +73,25 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
static int Write ( sout_access_out_t *, block_t * );
static int WriteRaw( sout_access_out_t *, block_t * );
static int Seek ( sout_access_out_t *, off_t );
static void ThreadWrite( vlc_object_t * );
static block_t *NewUDPPacket( sout_access_out_t *, mtime_t );
typedef struct sout_access_thread_t typedef struct sout_access_thread_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
sout_instance_t *p_sout; sout_instance_t *p_sout;
sout_fifo_t *p_fifo; block_fifo_t *p_fifo;
int i_handle; int i_handle;
...@@ -109,12 +109,14 @@ struct sout_access_out_sys_t ...@@ -109,12 +109,14 @@ struct sout_access_out_sys_t
unsigned int i_mtu; unsigned int i_mtu;
sout_buffer_t *p_buffer; block_t *p_buffer;
sout_access_thread_t *p_thread; sout_access_thread_t *p_thread;
}; };
#define DEFAULT_PORT 1234
/***************************************************************************** /*****************************************************************************
* Open: open the file * Open: open the file
*****************************************************************************/ *****************************************************************************/
...@@ -191,7 +193,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -191,7 +193,7 @@ static int Open( vlc_object_t *p_this )
p_sys->p_thread->p_sout = p_access->p_sout; p_sys->p_thread->p_sout = p_access->p_sout;
p_sys->p_thread->b_die = 0; p_sys->p_thread->b_die = 0;
p_sys->p_thread->b_error= 0; p_sys->p_thread->b_error= 0;
p_sys->p_thread->p_fifo = sout_FifoCreate( p_access->p_sout ); p_sys->p_thread->p_fifo = block_FifoNew( p_access );
socket_desc.i_type = NETWORK_UDP; socket_desc.i_type = NETWORK_UDP;
socket_desc.psz_server_addr = psz_dst_addr; socket_desc.psz_server_addr = psz_dst_addr;
...@@ -266,7 +268,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -266,7 +268,7 @@ static int Open( vlc_object_t *p_this )
p_access->pf_seek = Seek; p_access->pf_seek = Seek;
msg_Info( p_access, "Open: addr:`%s' port:`%d'", psz_dst_addr, i_dst_port); msg_Dbg( p_access, "udp access output opened(%s:%d)", psz_dst_addr, i_dst_port );
free( psz_dst_addr ); free( psz_dst_addr );
...@@ -288,21 +290,19 @@ static void Close( vlc_object_t * p_this ) ...@@ -288,21 +290,19 @@ static void Close( vlc_object_t * p_this )
p_sys->p_thread->b_die = 1; p_sys->p_thread->b_die = 1;
for( i = 0; i < 10; i++ ) for( i = 0; i < 10; i++ )
{ {
sout_buffer_t *p_dummy; block_t *p_dummy = block_New( p_access, p_sys->i_mtu );
p_dummy = sout_BufferNew( p_access->p_sout, p_sys->i_mtu );
p_dummy->i_dts = 0; p_dummy->i_dts = 0;
p_dummy->i_pts = 0; p_dummy->i_pts = 0;
p_dummy->i_length = 0; p_dummy->i_length = 0;
sout_FifoPut( p_sys->p_thread->p_fifo, p_dummy ); block_FifoPut( p_sys->p_thread->p_fifo, p_dummy );
} }
vlc_thread_join( p_sys->p_thread ); vlc_thread_join( p_sys->p_thread );
sout_FifoDestroy( p_access->p_sout, p_sys->p_thread->p_fifo ); block_FifoRelease( p_sys->p_thread->p_fifo );
if( p_sys->p_buffer ) if( p_sys->p_buffer )
{ {
sout_BufferDelete( p_access->p_sout, p_sys->p_buffer ); block_Release( p_sys->p_buffer );
} }
net_Close( p_sys->p_thread->i_handle ); net_Close( p_sys->p_thread->i_handle );
...@@ -310,36 +310,36 @@ static void Close( vlc_object_t * p_this ) ...@@ -310,36 +310,36 @@ static void Close( vlc_object_t * p_this )
/* update p_sout->i_out_pace_nocontrol */ /* update p_sout->i_out_pace_nocontrol */
p_access->p_sout->i_out_pace_nocontrol--; p_access->p_sout->i_out_pace_nocontrol--;
msg_Dbg( p_access, "udp access output closed" );
free( p_sys ); free( p_sys );
msg_Info( p_access, "Close" );
} }
/***************************************************************************** /*****************************************************************************
* Write: standard write on a file descriptor. * Write: standard write on a file descriptor.
*****************************************************************************/ *****************************************************************************/
static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) static int Write( sout_access_out_t *p_access, block_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; unsigned int i_write;
while( p_buffer ) while( p_buffer )
{ {
sout_buffer_t *p_next; block_t *p_next;
if( p_buffer->i_size > p_sys->i_mtu ) if( p_buffer->i_buffer > p_sys->i_mtu )
{ {
msg_Warn( p_access, "arggggggggggggg packet size > mtu" ); msg_Warn( p_access, "arggggggggggggg packet size > mtu" );
i_write = p_sys->i_mtu; i_write = p_sys->i_mtu;
} }
else else
{ {
i_write = p_buffer->i_size; i_write = p_buffer->i_buffer;
} }
/* if we have enough data, enque the buffer */ /* if we have enough data, enque the buffer */
if( p_sys->p_buffer && if( p_sys->p_buffer &&
p_sys->p_buffer->i_size + i_write > p_sys->i_mtu ) p_sys->p_buffer->i_buffer + i_write > p_sys->i_mtu )
{ {
sout_FifoPut( p_sys->p_thread->p_fifo, p_sys->p_buffer ); block_FifoPut( p_sys->p_thread->p_fifo, p_sys->p_buffer );
p_sys->p_buffer = NULL; p_sys->p_buffer = NULL;
} }
...@@ -348,14 +348,14 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -348,14 +348,14 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
p_sys->p_buffer = NewUDPPacket( p_access, p_buffer->i_dts ); p_sys->p_buffer = NewUDPPacket( p_access, p_buffer->i_dts );
} }
if( p_buffer->i_size > 0 ) if( p_buffer->i_buffer > 0 )
{ {
memcpy( p_sys->p_buffer->p_buffer + p_sys->p_buffer->i_size, memcpy( p_sys->p_buffer->p_buffer + p_sys->p_buffer->i_buffer,
p_buffer->p_buffer, i_write ); p_buffer->p_buffer, i_write );
p_sys->p_buffer->i_size += i_write; p_sys->p_buffer->i_buffer += i_write;
} }
p_next = p_buffer->p_next; p_next = p_buffer->p_next;
sout_BufferDelete( p_access->p_sout, p_buffer ); block_Release( p_buffer );
p_buffer = p_next; p_buffer = p_next;
} }
...@@ -365,11 +365,11 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -365,11 +365,11 @@ static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
/***************************************************************************** /*****************************************************************************
* WriteRaw: write p_buffer without trying to fill mtu * WriteRaw: write p_buffer without trying to fill mtu
*****************************************************************************/ *****************************************************************************/
static int WriteRaw( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) static int WriteRaw( sout_access_out_t *p_access, block_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;
sout_FifoPut( p_sys->p_thread->p_fifo, p_buffer ); block_FifoPut( p_sys->p_thread->p_fifo, p_buffer );
return( p_sys->p_thread->b_error ? -1 : 0 ); return( p_sys->p_thread->b_error ? -1 : 0 );
} }
...@@ -380,20 +380,20 @@ static int WriteRaw( sout_access_out_t *p_access, sout_buffer_t *p_buffer ) ...@@ -380,20 +380,20 @@ 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 ) static int Seek( sout_access_out_t *p_access, off_t i_pos )
{ {
msg_Err( p_access, "UDP sout access cannot seek" ); msg_Err( p_access, "UDP sout access cannot seek" );
return( -1 ); return -1;
} }
/***************************************************************************** /*****************************************************************************
* NewUDPPacket: allocate a new UDP packet of size p_sys->i_mtu * NewUDPPacket: allocate a new UDP packet of size p_sys->i_mtu
*****************************************************************************/ *****************************************************************************/
static sout_buffer_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts) static block_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts)
{ {
sout_access_out_sys_t *p_sys = p_access->p_sys; sout_access_out_sys_t *p_sys = p_access->p_sys;
sout_buffer_t *p_buffer; block_t *p_buffer;
p_buffer = sout_BufferNew( p_access->p_sout, p_sys->i_mtu ); p_buffer = block_New( p_access->p_sout, p_sys->i_mtu );
p_buffer->i_dts = i_dts; p_buffer->i_dts = i_dts;
p_buffer->i_size = 0; p_buffer->i_buffer = 0;
if( p_sys->b_rtpts ) if( p_sys->b_rtpts )
{ {
...@@ -417,7 +417,7 @@ static sout_buffer_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts) ...@@ -417,7 +417,7 @@ static sout_buffer_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts)
p_buffer->p_buffer[10] = ( p_sys->i_ssrc >> 8 )&0xff; p_buffer->p_buffer[10] = ( p_sys->i_ssrc >> 8 )&0xff;
p_buffer->p_buffer[11] = p_sys->i_ssrc&0xff; p_buffer->p_buffer[11] = p_sys->i_ssrc&0xff;
p_buffer->i_size = 12; p_buffer->i_buffer = 12;
} }
return p_buffer; return p_buffer;
...@@ -429,17 +429,16 @@ static sout_buffer_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts) ...@@ -429,17 +429,16 @@ static sout_buffer_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts)
static void ThreadWrite( vlc_object_t *p_this ) static void ThreadWrite( vlc_object_t *p_this )
{ {
sout_access_thread_t *p_thread = (sout_access_thread_t*)p_this; sout_access_thread_t *p_thread = (sout_access_thread_t*)p_this;
sout_instance_t *p_sout = p_thread->p_sout;
mtime_t i_date_last = -1; mtime_t i_date_last = -1;
mtime_t i_to_send = p_thread->i_group; mtime_t i_to_send = p_thread->i_group;
int i_dropped_packets = 0; int i_dropped_packets = 0;
while( !p_thread->b_die ) while( !p_thread->b_die )
{ {
sout_buffer_t *p_pk; block_t *p_pk;
mtime_t i_date, i_sent; mtime_t i_date, i_sent;
p_pk = sout_FifoGet( p_thread->p_fifo ); p_pk = block_FifoGet( p_thread->p_fifo );
i_date = p_thread->i_caching + p_pk->i_dts; i_date = p_thread->i_caching + p_pk->i_dts;
if( i_date_last > 0 ) if( i_date_last > 0 )
...@@ -449,7 +448,7 @@ static void ThreadWrite( vlc_object_t *p_this ) ...@@ -449,7 +448,7 @@ static void ThreadWrite( vlc_object_t *p_this )
if( !i_dropped_packets ) if( !i_dropped_packets )
msg_Dbg( p_thread, "mmh, hole > 2s -> drop" ); msg_Dbg( p_thread, "mmh, hole > 2s -> drop" );
sout_BufferDelete( p_sout, p_pk ); block_Release( p_pk );
i_date_last = i_date; i_date_last = i_date;
i_dropped_packets++; i_dropped_packets++;
continue; continue;
...@@ -459,7 +458,7 @@ static void ThreadWrite( vlc_object_t *p_this ) ...@@ -459,7 +458,7 @@ static void ThreadWrite( vlc_object_t *p_this )
if( !i_dropped_packets ) if( !i_dropped_packets )
msg_Dbg( p_thread, "mmh, paquets in the past -> drop" ); msg_Dbg( p_thread, "mmh, paquets in the past -> drop" );
sout_BufferDelete( p_sout, p_pk ); block_Release( p_pk );
i_date_last = i_date; i_date_last = i_date;
i_dropped_packets++; i_dropped_packets++;
continue; continue;
...@@ -474,7 +473,7 @@ static void ThreadWrite( vlc_object_t *p_this ) ...@@ -474,7 +473,7 @@ static void ThreadWrite( vlc_object_t *p_this )
msg_Dbg( p_thread, "late packet to send (" I64Fd ") -> drop", msg_Dbg( p_thread, "late packet to send (" I64Fd ") -> drop",
i_sent - i_date ); i_sent - i_date );
} }
sout_BufferDelete( p_sout, p_pk ); block_Release( p_pk );
i_date_last = i_date; i_date_last = i_date;
i_dropped_packets++; i_dropped_packets++;
continue; continue;
...@@ -486,7 +485,7 @@ static void ThreadWrite( vlc_object_t *p_this ) ...@@ -486,7 +485,7 @@ static void ThreadWrite( vlc_object_t *p_this )
mwait( i_date ); mwait( i_date );
i_to_send = p_thread->i_group; i_to_send = p_thread->i_group;
} }
send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_size, 0 ); send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_buffer, 0 );
if( i_dropped_packets ) if( i_dropped_packets )
{ {
...@@ -503,7 +502,7 @@ static void ThreadWrite( vlc_object_t *p_this ) ...@@ -503,7 +502,7 @@ static void ThreadWrite( vlc_object_t *p_this )
} }
#endif #endif
sout_BufferDelete( p_sout, p_pk ); block_Release( p_pk );
i_date_last = i_date; i_date_last = i_date;
} }
} }
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