#include <vlc/input.h>
#include <vlc/sout.h>
-#include "codecs.h"
-
-/*****************************************************************************
- * Exported prototypes
- *****************************************************************************/
-static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
-
-static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
-static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
-
/*****************************************************************************
* Module descriptor
*****************************************************************************/
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
vlc_module_begin();
set_description( _("Display stream output") );
set_capability( "sout stream", 50 );
set_callbacks( Open, Close );
vlc_module_end();
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
+static int Del ( sout_stream_t *, sout_stream_id_t * );
+static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
+
struct sout_stream_sys_t
{
input_thread_t *p_input;
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
while( p_buffer )
{
- sout_buffer_t *p_next;
- block_t *p_block;
+ block_t *p_next = p_buffer->p_next;
+
+ p_buffer->p_next = NULL;
- if( id->p_es->p_dec && p_buffer->i_size > 0 &&
- (p_block = block_New( p_stream, p_buffer->i_size )) )
+ if( id->p_es->p_dec && p_buffer->i_buffer > 0 )
{
- p_block->i_dts = p_buffer->i_dts <= 0 ? 0 :
- p_buffer->i_dts + p_sys->i_delay;
- p_block->i_pts = p_buffer->i_pts <= 0 ? 0 :
- p_buffer->i_pts + p_sys->i_delay;
+ if( p_buffer->i_dts <= 0 )
+ p_buffer->i_dts= 0;
+ else
+ p_buffer->i_dts += p_sys->i_delay;
- p_stream->p_vlc->pf_memcpy( p_block->p_buffer,
- p_buffer->p_buffer, p_buffer->i_size );
+ if( p_buffer->i_pts <= 0 )
+ p_buffer->i_pts= 0;
+ else
+ p_buffer->i_pts += p_sys->i_delay;
- input_DecodeBlock( id->p_es->p_dec, p_block );
+ input_DecodeBlock( id->p_es->p_dec, p_buffer );
}
- /* *** go to next buffer *** */
- p_next = p_buffer->p_next;
- sout_BufferDelete( p_stream->p_sout, p_buffer );
p_buffer = p_next;
}
* dummy.c: dummy stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
- * $Id: dummy.c,v 1.4 2004/01/25 14:34:25 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
+static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
/*****************************************************************************
* Module descriptor
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
- sout_buffer_t *p_next;
-
- while( p_buffer )
- {
- p_next = p_buffer->p_next;
-
- sout_BufferDelete( p_stream->p_sout, p_buffer );
- p_buffer = p_next;
- }
-
+ block_ChainRelease( p_buffer );
return VLC_SUCCESS;
}
* duplicate.c: duplicate stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
- * $Id: duplicate.c,v 1.12 2004/01/25 14:34:25 gbazin Exp $
+ * $Id$
*
* Author: Laurent Aimar <fenrir@via.ecp.fr>
*
#include <vlc/sout.h>
/*****************************************************************************
- * Exported prototypes
+ * Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
-static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
-static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *,
- sout_buffer_t* );
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
vlc_module_begin();
set_description( _("Duplicate stream output") );
set_capability( "sout stream", 50 );
set_callbacks( Open, Close );
vlc_module_end();
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
+static int Del ( sout_stream_t *, sout_stream_id_t * );
+static int Send( sout_stream_t *, sout_stream_id_t *,
+ block_t* );
+
struct sout_stream_sys_t
{
int i_nb_streams;
* Send:
*****************************************************************************/
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_stream_t *p_dup_stream;
/* Loop through the linked list of buffers */
while( p_buffer )
{
- sout_buffer_t *p_next = p_buffer->p_next;
+ block_t *p_next = p_buffer->p_next;
p_buffer->p_next = NULL;
for( i_stream = 0; i_stream < p_sys->i_nb_streams - 1; i_stream++ )
{
- sout_buffer_t *p_dup;
+ block_t *p_dup;
p_dup_stream = p_sys->pp_streams[i_stream];
if( id->pp_ids[i_stream] )
{
- p_dup = sout_BufferDuplicate( p_stream->p_sout, p_buffer );
+ p_dup = block_Duplicate( p_buffer );
p_dup_stream->pf_send( p_dup_stream, id->pp_ids[i_stream],
p_dup );
}
else
{
- sout_BufferDelete( p_stream->p_sout, p_buffer );
+ block_Release( p_buffer );
}
p_buffer = p_next;
* es.c: Elementary stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
- * $Id: es.c,v 1.5 2004/01/25 14:34:25 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
+static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
/*****************************************************************************
* Module descriptor
return( NULL );
}
- /* XXX beurk */
- p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
-
id = malloc( sizeof( sout_stream_id_t ) );
id->p_mux = p_mux;
id->p_input = sout_MuxAddStream( p_mux, p_fmt );
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_MuxSendBuffer( id->p_mux, id->p_input, p_buffer );
* gather.c: gathering stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
- * $Id: gather.c,v 1.3 2004/01/25 14:34:25 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *,
- sout_buffer_t* );
+ block_t* );
struct sout_stream_id_t
{
* Send:
*****************************************************************************/
static int Send( sout_stream_t *p_stream,
- sout_stream_id_t *id, sout_buffer_t *p_buffer )
+ sout_stream_id_t *id, block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
static int Send( sout_stream_t *, sout_stream_id_t *,
- sout_buffer_t* );
+ block_t* );
struct sout_stream_sys_t
{
uint16_t i_sequence;
uint32_t i_timestamp_start;
uint8_t ssrc[4];
- sout_buffer_t *packet;
+ block_t *packet;
/* */
int i_es;
};
typedef int (*pf_rtp_packetizer_t)( sout_stream_t *, sout_stream_id_t *,
- sout_buffer_t * );
+ block_t * );
struct sout_stream_id_t
{
httpd_url_t *p_rtsp_url;
};
-static int AccessOutGrabberWrite( sout_access_out_t *, sout_buffer_t * );
+static int AccessOutGrabberWrite( sout_access_out_t *, block_t * );
static int HttpSetup( sout_stream_t *p_stream, vlc_url_t * );
static int RtspSetup( sout_stream_t *p_stream, vlc_url_t * );
free( p_sys );
return VLC_EGENERIC;
}
- p_sout->i_preheader = __MAX( p_sout->i_preheader,
- p_sys->p_mux->i_preheader );
/* create the SDP only once */
p_sys->psz_sdp =
sout_AccessOutDelete( p_sys->p_grab );
if( p_sys->packet )
{
- sout_BufferDelete( p_stream->p_sout, p_sys->packet );
+ block_Release( p_sys->packet );
}
}
/*****************************************************************************
*
*****************************************************************************/
-static int rtp_packetize_l16 ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
-static int rtp_packetize_l8 ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
-static int rtp_packetize_mpa ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
-static int rtp_packetize_mpv ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
-static int rtp_packetize_ac3 ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
-static int rtp_packetize_split( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
-static int rtp_packetize_mp4a ( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
+static int rtp_packetize_l16 ( sout_stream_t *, sout_stream_id_t *, block_t * );
+static int rtp_packetize_l8 ( sout_stream_t *, sout_stream_id_t *, block_t * );
+static int rtp_packetize_mpa ( sout_stream_t *, sout_stream_id_t *, block_t * );
+static int rtp_packetize_mpv ( sout_stream_t *, sout_stream_id_t *, block_t * );
+static int rtp_packetize_ac3 ( sout_stream_t *, sout_stream_id_t *, block_t * );
+static int rtp_packetize_split( sout_stream_t *, sout_stream_id_t *, block_t * );
+static int rtp_packetize_mp4a ( sout_stream_t *, sout_stream_id_t *, block_t * );
static void sprintf_hexa( char *s, uint8_t *p_data, int i_data )
{
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
- sout_buffer_t *p_next;
+ block_t *p_next;
if( p_stream->p_sys->p_mux )
{
{
break;
}
- sout_BufferDelete( p_stream->p_sout, p_buffer );
+ block_Release( p_buffer );
p_buffer = p_next;
}
}
static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
uint32_t i_timestamp = i_dts * 9 / 100;
uint8_t *p_data = p_buffer->p_buffer;
- unsigned int i_data = p_buffer->i_size;
+ unsigned int i_data = p_buffer->i_buffer;
unsigned int i_max = p_sys->i_mtu - 12;
- int i_packet = ( p_buffer->i_size + i_max - 1 ) / i_max;
+ int i_packet = ( p_buffer->i_buffer + i_max - 1 ) / i_max;
while( i_data > 0 )
{
/* output complete packet */
if( p_sys->packet &&
- p_sys->packet->i_size + i_data > i_max )
+ p_sys->packet->i_buffer + i_data > i_max )
{
sout_AccessOutWrite( p_sys->p_access, p_sys->packet );
p_sys->packet = NULL;
if( p_sys->packet == NULL )
{
/* allocate a new packet */
- p_sys->packet = sout_BufferNew( p_stream->p_sout, p_sys->i_mtu );
+ p_sys->packet = block_New( p_stream, p_sys->i_mtu );
p_sys->packet->p_buffer[ 0] = 0x80;
p_sys->packet->p_buffer[ 1] = p_sys->i_payload_type;
p_sys->packet->p_buffer[ 2] = ( p_sys->i_sequence >> 8)&0xff;
p_sys->packet->p_buffer[ 9] = p_sys->ssrc[1];
p_sys->packet->p_buffer[10] = p_sys->ssrc[2];
p_sys->packet->p_buffer[11] = p_sys->ssrc[3];
- p_sys->packet->i_size = 12;
+ p_sys->packet->i_buffer = 12;
p_sys->packet->i_dts = i_dts;
p_sys->packet->i_length = p_buffer->i_length / i_packet;
p_sys->i_sequence++;
}
- i_size = __MIN( i_data, p_sys->i_mtu - p_sys->packet->i_size );
+ i_size = __MIN( i_data, p_sys->i_mtu - p_sys->packet->i_buffer );
- memcpy( &p_sys->packet->p_buffer[p_sys->packet->i_size],
- p_data,
- i_size );
+ memcpy( &p_sys->packet->p_buffer[p_sys->packet->i_buffer],
+ p_data, i_size );
- p_sys->packet->i_size += i_size;
+ p_sys->packet->i_buffer += i_size;
p_data += i_size;
i_data -= i_size;
}
}
static int AccessOutGrabberWrite( sout_access_out_t *p_access,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_t *p_stream = (sout_stream_t*)p_access->p_sys;
- //fprintf( stderr, "received buffer size=%d\n", p_buffer->i_size );
+ //fprintf( stderr, "received buffer size=%d\n", p_buffer->i_buffer );
//
while( p_buffer )
{
- sout_buffer_t *p_next;
+ block_t *p_next;
AccessOutGrabberWriteBuffer( p_stream, p_buffer );
p_next = p_buffer->p_next;
- sout_BufferDelete( p_access->p_sout, p_buffer );
+ block_Release( p_buffer );
p_buffer = p_next;
}
/****************************************************************************
* rtp_packetize_*:
****************************************************************************/
-static void rtp_packetize_common( sout_stream_id_t *id, sout_buffer_t *out,
+static void rtp_packetize_common( sout_stream_id_t *id, block_t *out,
int b_marker, int64_t i_pts )
{
uint32_t i_timestamp = i_pts * (int64_t)id->i_clock_rate / I64C(1000000);
out->p_buffer[10] = id->ssrc[2];
out->p_buffer[11] = id->ssrc[3];
- out->i_size = 12;
+ out->i_buffer = 12;
id->i_sequence++;
}
static int rtp_packetize_mpa( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 12 - 4; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i;
for( i = 0; i < i_count; i++ )
{
int i_payload = __MIN( i_max, i_data );
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 16 + i_payload );
+ block_t *out = block_New( p_stream, 16 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts );
out->p_buffer[15] = ( (i*i_max) )&0xff;
memcpy( &out->p_buffer[16], p_data, i_payload );
- out->i_size = 16 + i_payload;
+ out->i_buffer = 16 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count;
/* rfc2250 */
static int rtp_packetize_mpv( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 12 - 4; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i;
int b_sequence_start = 0;
int i_temporal_ref = 0;
int b_start_slice = 0;
/* preparse this packet to get some info */
- if( in->i_size > 4 )
+ if( in->i_buffer > 4 )
{
uint8_t *p = p_data;
- int i_rest = in->i_size;
+ int i_rest = in->i_buffer;
for( ;; )
{
for( i = 0; i < i_count; i++ )
{
int i_payload = __MIN( i_max, i_data );
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout,
+ block_t *out = block_New( p_stream,
16 + i_payload );
uint32_t h = ( i_temporal_ref << 16 )|
( b_sequence_start << 13 )|
memcpy( &out->p_buffer[16], p_data, i_payload );
- out->i_size = 16 + i_payload;
+ out->i_buffer = 16 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count;
return VLC_SUCCESS;
}
static int rtp_packetize_ac3( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 12 - 2; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i;
for( i = 0; i < i_count; i++ )
{
int i_payload = __MIN( i_max, i_data );
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 14 + i_payload );
+ block_t *out = block_New( p_stream, 14 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, (i == i_count - 1)?1:0, in->i_pts );
/* data */
memcpy( &out->p_buffer[14], p_data, i_payload );
- out->i_size = 14 + i_payload;
+ out->i_buffer = 14 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count;
}
static int rtp_packetize_split( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 12; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i;
for( i = 0; i < i_count; i++ )
{
int i_payload = __MIN( i_max, i_data );
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 12 + i_payload );
+ block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, ((i == i_count - 1)?1:0),
(in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload );
- out->i_size = 12 + i_payload;
+ out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count;
}
static int rtp_packetize_l16( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 12; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i_packet = 0;
while( i_data > 0 )
{
int i_payload = (__MIN( i_max, i_data )/4)*4;
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 12 + i_payload );
+ block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, 0,
(in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload );
- out->i_size = 12 + i_payload;
+ out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i_packet * in->i_length / i_count;
out->i_length = in->i_length / i_count;
}
static int rtp_packetize_l8( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 12; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i_packet = 0;
while( i_data > 0 )
{
int i_payload = (__MIN( i_max, i_data )/2)*2;
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 12 + i_payload );
+ block_t *out = block_New( p_stream, 12 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, 0,
(in->i_pts > 0 ? in->i_pts : in->i_dts) );
memcpy( &out->p_buffer[12], p_data, i_payload );
- out->i_size = 12 + i_payload;
+ out->i_buffer = 12 + i_payload;
out->i_dts = in->i_dts + i_packet * in->i_length / i_count;
out->i_length = in->i_length / i_count;
return VLC_SUCCESS;
}
static int rtp_packetize_mp4a( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *in )
+ block_t *in )
{
int i_max = id->i_mtu - 16; /* payload max in one packet */
- int i_count = ( in->i_size + i_max - 1 ) / i_max;
+ int i_count = ( in->i_buffer + i_max - 1 ) / i_max;
uint8_t *p_data = in->p_buffer;
- int i_data = in->i_size;
+ int i_data = in->i_buffer;
int i;
for( i = 0; i < i_count; i++ )
{
int i_payload = __MIN( i_max, i_data );
- sout_buffer_t *out = sout_BufferNew( p_stream->p_sout, 16 + i_payload );
+ block_t *out = block_New( p_stream, 16 + i_payload );
/* rtp common header */
rtp_packetize_common( id, out, ((i == i_count - 1)?1:0),
out->p_buffer[12] = 0;
out->p_buffer[13] = 2*8;
/* for each AU length 13 bits + idx 3bits, */
- out->p_buffer[14] = ( in->i_size >> 5 )&0xff;
- out->p_buffer[15] = ( (in->i_size&0xff)<<3 )|0;
+ out->p_buffer[14] = ( in->i_buffer >> 5 )&0xff;
+ out->p_buffer[15] = ( (in->i_buffer&0xff)<<3 )|0;
memcpy( &out->p_buffer[16], p_data, i_payload );
- out->i_size = 16 + i_payload;
+ out->i_buffer = 16 + i_payload;
out->i_dts = in->i_dts + i * in->i_length / i_count;
out->i_length = in->i_length / i_count;
* standard.c: standard stream output module
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
- * $Id: standard.c,v 1.18 2004/01/25 14:34:25 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
+static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
/*****************************************************************************
* Module descriptor
}
#endif
- /* XXX beurk */
- p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
-
p_stream->pf_add = Add;
p_stream->pf_del = Del;
p_stream->pf_send = Send;
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout;
#endif
/*****************************************************************************
- * Exported prototypes
+ * Module descriptor
*****************************************************************************/
-static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
+static int Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
+
+vlc_module_begin();
+ set_description( _("Transcode stream output") );
+ set_capability( "sout stream", 50 );
+ add_shortcut( "transcode" );
+ set_callbacks( Open, Close );
+vlc_module_end();
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
+static int Send( sout_stream_t *, sout_stream_id_t *, block_t* );
static int transcode_audio_ffmpeg_new ( sout_stream_t *, sout_stream_id_t * );
static void transcode_audio_ffmpeg_close ( sout_stream_t *, sout_stream_id_t * );
-static int transcode_audio_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, sout_buffer_t *, sout_buffer_t ** );
+static int transcode_audio_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, block_t *, block_t ** );
static int transcode_video_ffmpeg_new ( sout_stream_t *, sout_stream_id_t * );
static void transcode_video_ffmpeg_close ( sout_stream_t *, sout_stream_id_t * );
-static int transcode_video_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, sout_buffer_t *, sout_buffer_t ** );
+static int transcode_video_ffmpeg_process( sout_stream_t *, sout_stream_id_t *, block_t *, block_t ** );
static int transcode_video_ffmpeg_getframebuf( struct AVCodecContext *, AVFrame *);
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
};
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-vlc_module_begin();
- set_description( _("Transcode stream output") );
- set_capability( "sout stream", 50 );
- add_shortcut( "transcode" );
- set_callbacks( Open, Close );
-vlc_module_end();
-
#define PICTURE_RING_SIZE 64
struct sout_stream_sys_t
sout_stream_t * p_out;
sout_stream_id_t * id_video;
- sout_buffer_t * p_buffers;
+ block_t * p_buffers;
vlc_mutex_t lock_out;
vlc_cond_t cond;
picture_t * pp_pics[PICTURE_RING_SIZE];
avcodec_init();
avcodec_register_all();
- /* ffmpeg needs some padding at the end of each buffer */
- p_stream->p_sout->i_padding += FF_INPUT_BUFFER_PADDING_SIZE;
-
return VLC_SUCCESS;
}
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
if( id->b_transcode )
{
- sout_buffer_t *p_buffer_out;
+ block_t *p_buffer_out;
+
+ /* Be sure to have padding */
+ p_buffer = block_Realloc( p_buffer, 0, p_buffer->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE );
+ if( p_buffer == NULL )
+ {
+ return VLC_EGENERIC;
+ }
+ p_buffer->i_buffer -= FF_INPUT_BUFFER_PADDING_SIZE;
+ memset( &p_buffer->p_buffer[p_buffer->i_buffer], 0, FF_INPUT_BUFFER_PADDING_SIZE );
+
if( id->f_src.i_cat == AUDIO_ES )
{
transcode_audio_ffmpeg_process( p_stream, id, p_buffer,
if( transcode_video_ffmpeg_process( p_stream, id, p_buffer,
&p_buffer_out ) != VLC_SUCCESS )
{
- sout_BufferDelete( p_stream->p_sout, p_buffer );
+ block_Release( p_buffer );
return VLC_EGENERIC;
}
}
- sout_BufferDelete( p_stream->p_sout, p_buffer );
+ block_Release( p_buffer );
if( p_buffer_out )
{
}
else
{
- sout_BufferDelete( p_stream->p_sout, p_buffer );
+ block_Release( p_buffer );
return VLC_EGENERIC;
}
}
static int transcode_audio_ffmpeg_process( sout_stream_t *p_stream,
sout_stream_id_t *id,
- sout_buffer_t *in,
- sout_buffer_t **out )
+ block_t *in,
+ block_t **out )
{
aout_buffer_t aout_buf;
block_t *p_block;
- int i_buffer = in->i_size;
+ int i_buffer = in->i_buffer;
char *p_buffer = in->p_buffer;
id->i_dts = in->i_dts;
*out = NULL;
p_block = id->p_encoder->pf_header( id->p_encoder );
while( p_block )
{
- sout_buffer_t *p_out;
+ block_t *p_out;
block_t *p_prev_block = p_block;
- p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
+ p_out = block_New( p_stream, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
p_out->i_dts = p_out->i_pts = in->i_dts;
p_out->i_length = 0;
- sout_BufferChain( out, p_out );
+ block_ChainAppend( out, p_out );
p_block = p_block->p_next;
block_Release( p_prev_block );
p_block = id->p_encoder->pf_encode_audio( id->p_encoder, &aout_buf );
while( p_block )
{
- sout_buffer_t *p_out;
+ block_t *p_out;
block_t *p_prev_block = p_block;
- p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
+ p_out = block_New( p_stream, p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
p_out->i_dts = p_block->i_dts;
p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length;
- sout_BufferChain( out, p_out );
+ block_ChainAppend( out, p_out );
p_block = p_block->p_next;
block_Release( p_prev_block );
msg_Err( p_stream, "cannot open decoder" );
return VLC_EGENERIC;
}
-#if 0
- if( i_ff_codec == CODEC_ID_MPEG4 && id->ff_dec_c->extradata_size > 0 )
- {
- int b_gotpicture;
- AVFrame frame;
- uint8_t *p_vol = malloc( id->ff_dec_c->extradata_size +
- FF_INPUT_BUFFER_PADDING_SIZE );
-
- memcpy( p_vol, id->ff_dec_c->extradata,
- id->ff_dec_c->extradata_size );
- memset( p_vol + id->ff_dec_c->extradata_size, 0,
- FF_INPUT_BUFFER_PADDING_SIZE );
-
- avcodec_decode_video( id->ff_dec_c, &frame, &b_gotpicture,
- id->ff_dec_c->extradata,
- id->ff_dec_c->extradata_size );
- free( p_vol );
- }
-#endif
}
/* Open encoder */
}
static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
- sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out )
+ sout_stream_id_t *id, block_t *in, block_t **out )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
int i_used;
*out = NULL;
- i_data = in->i_size;
+ i_data = in->i_buffer;
p_data = in->p_buffer;
for( ;; )
p_block = id->p_encoder->pf_header( id->p_encoder );
while( p_block )
{
- sout_buffer_t *p_out;
+ block_t *p_out;
block_t *p_prev_block = p_block;
- p_out = sout_BufferNew( p_stream->p_sout,
+ p_out = block_New( p_stream,
p_block->i_buffer );
memcpy( p_out->p_buffer, p_block->p_buffer,
p_block->i_buffer);
p_out->i_dts = p_out->i_pts = in->i_dts;
p_out->i_length = 0;
- sout_BufferChain( out, p_out );
+ block_ChainAppend( out, p_out );
p_block = p_block->p_next;
block_Release( p_prev_block );
{
block_t *p_block;
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
- while( p_block )
+ if( p_block )
{
- sout_buffer_t *p_out;
- block_t *p_prev_block = p_block;
-
- p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
- memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
- p_out->i_dts = p_block->i_dts;
- p_out->i_pts = p_block->i_pts;
- p_out->i_length = p_block->i_length;
- p_out->i_flags =
- (p_block->i_flags << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)
- & SOUT_BUFFER_FLAGS_BLOCK_MASK;
- sout_BufferChain( out, p_out );
-
- p_block = p_block->p_next;
- block_Release( p_prev_block );
+ block_ChainAppend( out, p_block );
}
free( p_pic );
}
static int EncoderThread( sout_stream_sys_t * p_sys )
{
- sout_stream_t * p_stream = p_sys->p_out;
sout_stream_id_t * id = p_sys->id_video;
picture_t * p_pic;
int i_plane;
- sout_buffer_t * p_buffer;
while ( !p_sys->b_die && !p_sys->b_error )
{
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
vlc_mutex_lock( &p_sys->lock_out );
- while( p_block )
+ if( p_block )
{
- sout_buffer_t *p_out;
- block_t *p_prev_block = p_block;
-
- p_out = sout_BufferNew( p_stream->p_sout, p_block->i_buffer );
- memcpy( p_out->p_buffer, p_block->p_buffer, p_block->i_buffer);
- p_out->i_dts = p_block->i_dts;
- p_out->i_pts = p_block->i_pts;
- p_out->i_length = p_block->i_length;
- p_out->i_flags =
- (p_block->i_flags << SOUT_BUFFER_FLAGS_BLOCK_SHIFT)
- & SOUT_BUFFER_FLAGS_BLOCK_MASK;
- sout_BufferChain( &p_sys->p_buffers, p_out );
-
- p_block = p_block->p_next;
- block_Release( p_prev_block );
+ block_ChainAppend( &p_sys->p_buffers, p_block );
}
vlc_mutex_unlock( &p_sys->lock_out );
free( p_pic );
}
- p_buffer = p_sys->p_buffers;
- while ( p_buffer != NULL )
- {
- sout_buffer_t * p_next = p_buffer->p_next;
- sout_BufferDelete( p_stream->p_sout, p_buffer );
- p_buffer = p_next;
- }
+ block_ChainRelease( p_sys->p_buffers );
return 0;
}
* Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- * $Id: frame.c,v 1.2 2004/03/03 11:39:06 massiot Exp $
+ * $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
}
void E_(process_frame)( sout_stream_t *p_stream,
- sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out )
+ sout_stream_id_t *id, block_t *in, block_t **out )
{
transrate_t *tr = &id->tr;
bs_transrate_t *bs = &tr->bs;
- sout_buffer_t *p_out;
+ block_t *p_out;
double next_fact_x = 1.0;
/* The output buffer can't be bigger than the input buffer. */
- p_out = sout_BufferNew( p_stream->p_sout, in->i_size );
+ p_out = block_New( p_stream, in->i_buffer );
p_out->i_length = in->i_length;
p_out->i_dts = in->i_dts;
p_out->i_pts = in->i_pts;
p_out->i_flags = in->i_flags;
- sout_BufferChain( out, p_out );
+ block_ChainAppend( out, p_out );
bs->p_rw = bs->p_ow = bs->p_w = p_out->p_buffer;
bs->p_c = bs->p_r = in->p_buffer;
- bs->p_r += in->i_size + 4;
- bs->p_rw += in->i_size;
- *(in->p_buffer + in->i_size) = 0;
- *(in->p_buffer + in->i_size + 1) = 0;
- *(in->p_buffer + in->i_size + 2) = 1;
- *(in->p_buffer + in->i_size + 3) = 0;
+ bs->p_r += in->i_buffer + 4;
+ bs->p_rw += in->i_buffer;
+ *(in->p_buffer + in->i_buffer) = 0;
+ *(in->p_buffer + in->i_buffer + 1) = 0;
+ *(in->p_buffer + in->i_buffer + 2) = 1;
+ *(in->p_buffer + in->i_buffer + 3) = 0;
/* Calculate how late we are */
tr->quant_corr = 0.0 + B_HANDICAP;
tr->level_i = 0;
tr->level_p = 0;
- bs->i_byte_in = in->i_size;
+ bs->i_byte_in = in->i_buffer;
bs->i_byte_out = 0;
- if (tr->i_current_gop_size - in->i_size > 100)
+ if (tr->i_current_gop_size - in->i_buffer > 100)
{
- if (tr->i_wanted_gop_size == in->i_size)
+ if (tr->i_wanted_gop_size == in->i_buffer)
{
next_fact_x = 1.0;
}
- else if ( tr->i_wanted_gop_size < in->i_size )
+ else if ( tr->i_wanted_gop_size < in->i_buffer )
{
/* We're really late */
next_fact_x = 10.0;
}
else
{
- next_fact_x = ((double)(tr->i_current_gop_size - in->i_size)) /
- (tr->i_wanted_gop_size - in->i_size);
+ next_fact_x = ((double)(tr->i_current_gop_size - in->i_buffer)) /
+ (tr->i_wanted_gop_size - in->i_buffer);
}
if (next_fact_x > QUANT_I)
for ( ; ; )
{
- uint8_t *p_end = &in->p_buffer[in->i_size];
+ uint8_t *p_end = &in->p_buffer[in->i_buffer];
/* Search next start code */
for( ;; )
}
bs->i_byte_out += bs->p_w - bs->p_ow;
- p_out->i_size = bs->p_w - bs->p_ow;
- tr->i_current_gop_size -= in->i_size;
- tr->i_wanted_gop_size -= p_out->i_size;
+ p_out->i_buffer = bs->p_w - bs->p_ow;
+ tr->i_current_gop_size -= in->i_buffer;
+ tr->i_wanted_gop_size -= p_out->i_buffer;
tr->i_new_gop_size += bs->i_byte_out;
#if 0
msg_Dbg( p_stream, "%d: %d -> %d (r: %f, n:%f, corr:%f)",
- tr->picture_coding_type, in->i_size, p_out->i_size,
- (float)in->i_size / p_out->i_size,
+ tr->picture_coding_type, in->i_buffer, p_out->i_size,
+ (float)in->i_buffer / p_out->i_size,
next_fact_x, tr->quant_corr);
#endif
}
* transrate.c: MPEG2 video transrating module
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: transrate.c,v 1.7 2004/03/03 11:20:52 massiot Exp $
+ * $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t * );
+static int Send( sout_stream_t *, sout_stream_id_t *, block_t * );
-static int transrate_video_process( sout_stream_t *, sout_stream_id_t *, sout_buffer_t *, sout_buffer_t ** );
+static int transrate_video_process( sout_stream_t *, sout_stream_id_t *, block_t *, block_t ** );
void E_(process_frame)( sout_stream_t *p_stream,
- sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out );
+ sout_stream_id_t *id, block_t *in, block_t **out );
/*****************************************************************************
* Module descriptor
p_stream->p_sys = p_sys;
- p_stream->p_sout->i_padding += 200;
-
return VLC_SUCCESS;
}
}
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
- sout_buffer_t *p_buffer )
+ block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
if( id->b_transrate )
{
- sout_buffer_t *p_buffer_out;
+ block_t *p_buffer_out;
+ /* be sure to have at least 8 bytes of padding (maybe only 4) */
+ p_buffer = block_Realloc( p_buffer, 0, p_buffer->i_buffer + 8 );
+ p_buffer->i_buffer -= 8;
+ memset( &p_buffer->p_buffer[p_buffer->i_buffer], 0, 8 );
+
transrate_video_process( p_stream, id, p_buffer, &p_buffer_out );
if( p_buffer_out )
}
else
{
- sout_BufferDelete( p_stream->p_sout, p_buffer );
+ block_Release( p_buffer );
return VLC_EGENERIC;
}
}
static int transrate_video_process( sout_stream_t *p_stream,
- sout_stream_id_t *id, sout_buffer_t *in, sout_buffer_t **out )
+ sout_stream_id_t *id, block_t *in, block_t **out )
{
transrate_t *tr = &id->tr;
bs_transrate_t *bs = &tr->bs;
while ( in != NULL )
{
- sout_buffer_t * p_next = in->p_next;
+ block_t * p_next = in->p_next;
int i_flags = in->i_flags;
in->p_next = NULL;
- sout_BufferChain( &id->p_next_gop, in );
+ block_ChainAppend( &id->p_next_gop, in );
id->i_next_gop_duration += in->i_length;
- id->i_next_gop_size += in->i_size;
+ id->i_next_gop_size += in->i_buffer;
in = p_next;
- if( ((i_flags & (BLOCK_FLAG_TYPE_I << SOUT_BUFFER_FLAGS_BLOCK_SHIFT))
+ if( ((i_flags & BLOCK_FLAG_TYPE_I )
&& id->i_next_gop_duration >= 300000)
|| (id->i_next_gop_duration > p_stream->p_sys->i_shaping_delay) )
{
while ( id->p_current_buffer != NULL )
{
- sout_buffer_t * p_next = id->p_current_buffer->p_next;
+ block_t * p_next = id->p_current_buffer->p_next;
if ( tr->fact_x == 1.0 )
{
- bs->i_byte_out += id->p_current_buffer->i_size;
+ bs->i_byte_out += id->p_current_buffer->i_buffer;
id->p_current_buffer->p_next = NULL;
- sout_BufferChain( out, id->p_current_buffer );
+ block_ChainAppend( out, id->p_current_buffer );
}
else
{
E_(process_frame)( p_stream, id, id->p_current_buffer, out );
- sout_BufferDelete(p_stream->p_sout, id->p_current_buffer);
+ block_Release( id->p_current_buffer);
}
id->p_current_buffer = p_next;
}
* Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- * $Id: transrate.h,v 1.1 2004/03/03 11:20:52 massiot Exp $
+ * $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
void *id;
vlc_bool_t b_transrate;
- sout_buffer_t *p_current_buffer;
- sout_buffer_t *p_next_gop;
+ block_t *p_current_buffer;
+ block_t *p_next_gop;
mtime_t i_next_gop_duration;
size_t i_next_gop_size;