* dummy.c
*****************************************************************************
* 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>
* Eric Petit <titer@videolan.org>
* Preamble
*****************************************************************************/
#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/input.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
*****************************************************************************/
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
vlc_module_begin();
set_description( _("Dummy stream ouput") );
set_capability( "sout access", 0 );
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
*****************************************************************************/
p_access->pf_write = Write;
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;
}
static void Close( vlc_object_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.
*****************************************************************************/
-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 += p_buffer->i_size;
- p_next = p_buffer->p_next;
- sout_BufferDelete( p_access->p_sout, p_buffer );
- p_buffer = p_next;
- } while( p_buffer );
+ i_write += b->i_buffer;
+
+ b = b->p_next;
+ }
- msg_Dbg( p_access, "Dummy Skipped: len:"I64Fd, (int64_t)i_write );
+ block_ChainRelease( p_buffer );
- return( i_write );
+ return i_write;
}
/*****************************************************************************
*****************************************************************************/
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;
}
* file.c
*****************************************************************************
* 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>
* Eric Petit <titer@videolan.org>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
-#include <errno.h>
#include <fcntl.h>
+#include <errno.h>
#include <vlc/vlc.h>
-#include <vlc/input.h>
#include <vlc/sout.h>
#ifdef HAVE_UNISTD_H
# define STDOUT_FILENO 1
#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
*****************************************************************************/
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
vlc_module_begin();
set_description( _("File stream ouput") );
set_capability( "sout access", 50 );
set_callbacks( Open, Close );
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
{
int i_handle;
-
};
/*****************************************************************************
p_access->pf_read = Read;
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;
}
}
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.
*****************************************************************************/
-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, "-" ) )
{
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;
+ p_buffer->i_buffer );
}
+
+ msg_Err( p_access, "cannot read 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 )
+static int Write( sout_access_out_t *p_access, block_t *p_buffer )
{
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,
- p_buffer->i_size );
- p_next = p_buffer->p_next;
- sout_BufferDelete( p_access->p_sout, p_buffer );
- p_buffer = p_next;
+ i_write += write( p_access->p_sys->i_handle,
+ p_buffer->p_buffer, p_buffer->i_buffer );
+ block_Release( p_buffer );
- } while( p_buffer );
+ p_buffer = p_next;
+ }
- return( i_write );
+ return i_write;
}
/*****************************************************************************
*****************************************************************************/
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 defined( WIN32 ) && !defined( UNDER_CE )
* Preamble
*****************************************************************************/
#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
#include <vlc/vlc.h>
-#include <vlc/input.h>
#include <vlc/sout.h>
#include "vlc_httpd.h"
#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
*****************************************************************************/
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
vlc_module_begin();
set_description( _("HTTP stream ouput") );
set_capability( "sout access", 0 );
set_callbacks( Open, Close );
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
{
/* host */
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
*****************************************************************************/
/*****************************************************************************
* 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;
int i_err = 0;
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 */
if( p_sys->b_header_complete )
p_sys->i_header_size = 0;
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_buffer->i_size + p_sys->i_header_size + 1024;
+ p_buffer->i_buffer + p_sys->i_header_size + 1024;
p_sys->p_header =
realloc( p_sys->p_header, p_sys->i_header_allocated );
}
memcpy( &p_sys->p_header[p_sys->i_header_size],
p_buffer->p_buffer,
- p_buffer->i_size );
- p_sys->i_header_size += p_buffer->i_size;
+ p_buffer->i_buffer );
+ p_sys->i_header_size += p_buffer->i_buffer;
}
else if( !p_sys->b_header_complete )
{
/* send data */
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;
- sout_BufferDelete( p_access->p_sout, p_buffer );
+ block_Release( p_buffer );
p_buffer = p_next;
if( i_err < 0 )
if( i_err < 0 )
{
- sout_buffer_t *p_next;
- while( p_buffer )
- {
- p_next = p_buffer->p_next;
- sout_BufferDelete( p_access->p_sout, p_buffer );
- p_buffer = p_next;
- }
+ block_ChainRelease( p_buffer );
}
return( i_err < 0 ? VLC_EGENERIC : VLC_SUCCESS );
#include <fcntl.h>
#include <vlc/vlc.h>
-#include <vlc/input.h>
#include <vlc/sout.h>
#ifdef HAVE_UNISTD_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
*****************************************************************************/
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
#define CACHING_TEXT N_("Caching value (ms)")
#define CACHING_LONGTEXT N_( \
"Allows you to modify the default caching value for udp streams. This " \
set_callbacks( Open, Close );
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
{
VLC_COMMON_MEMBERS
sout_instance_t *p_sout;
- sout_fifo_t *p_fifo;
+ block_fifo_t *p_fifo;
int i_handle;
unsigned int i_mtu;
- sout_buffer_t *p_buffer;
+ block_t *p_buffer;
sout_access_thread_t *p_thread;
};
+#define DEFAULT_PORT 1234
+
/*****************************************************************************
* Open: open the file
*****************************************************************************/
p_sys->p_thread->p_sout = p_access->p_sout;
p_sys->p_thread->b_die = 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.psz_server_addr = psz_dst_addr;
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 );
p_sys->p_thread->b_die = 1;
for( i = 0; i < 10; i++ )
{
- sout_buffer_t *p_dummy;
-
- p_dummy = sout_BufferNew( p_access->p_sout, p_sys->i_mtu );
+ block_t *p_dummy = block_New( p_access, p_sys->i_mtu );
p_dummy->i_dts = 0;
p_dummy->i_pts = 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 );
- 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 )
{
- sout_BufferDelete( p_access->p_sout, p_sys->p_buffer );
+ block_Release( p_sys->p_buffer );
}
net_Close( p_sys->p_thread->i_handle );
/* update 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 );
- msg_Info( p_access, "Close" );
}
/*****************************************************************************
* 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;
unsigned int i_write;
while( p_buffer )
{
- sout_buffer_t *p_next;
- if( p_buffer->i_size > p_sys->i_mtu )
+ block_t *p_next;
+ if( p_buffer->i_buffer > p_sys->i_mtu )
{
msg_Warn( p_access, "arggggggggggggg packet size > mtu" );
i_write = p_sys->i_mtu;
}
else
{
- i_write = p_buffer->i_size;
+ i_write = p_buffer->i_buffer;
}
/* if we have enough data, enque the 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 = 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_sys->p_buffer->i_size += i_write;
+ p_sys->p_buffer->i_buffer += i_write;
}
p_next = p_buffer->p_next;
- sout_BufferDelete( p_access->p_sout, p_buffer );
+ block_Release( p_buffer );
p_buffer = p_next;
}
/*****************************************************************************
* 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_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 );
}
static int Seek( sout_access_out_t *p_access, off_t i_pos )
{
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
*****************************************************************************/
-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_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_size = 0;
+ p_buffer->i_buffer = 0;
if( p_sys->b_rtpts )
{
p_buffer->p_buffer[10] = ( p_sys->i_ssrc >> 8 )&0xff;
p_buffer->p_buffer[11] = p_sys->i_ssrc&0xff;
- p_buffer->i_size = 12;
+ p_buffer->i_buffer = 12;
}
return p_buffer;
static void ThreadWrite( vlc_object_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_to_send = p_thread->i_group;
int i_dropped_packets = 0;
while( !p_thread->b_die )
{
- sout_buffer_t *p_pk;
+ block_t *p_pk;
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;
if( i_date_last > 0 )
if( !i_dropped_packets )
msg_Dbg( p_thread, "mmh, hole > 2s -> drop" );
- sout_BufferDelete( p_sout, p_pk );
+ block_Release( p_pk );
i_date_last = i_date;
i_dropped_packets++;
continue;
if( !i_dropped_packets )
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_dropped_packets++;
continue;
msg_Dbg( p_thread, "late packet to send (" I64Fd ") -> drop",
i_sent - i_date );
}
- sout_BufferDelete( p_sout, p_pk );
+ block_Release( p_pk );
i_date_last = i_date;
i_dropped_packets++;
continue;
mwait( i_date );
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 )
{
}
#endif
- sout_BufferDelete( p_sout, p_pk );
+ block_Release( p_pk );
i_date_last = i_date;
}
}