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 );
......
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