Commit eff1a4ce authored by Christophe Courtaut's avatar Christophe Courtaut Committed by Jean-Baptiste Kempf

Move Data Context from sys to stream id struct

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent eeae8ac6
......@@ -134,6 +134,8 @@ static int SendAudio( sout_stream_t *p_stream, sout_stream_id_t *id,
struct sout_stream_id_t
{
es_format_t* format;
void *p_audio_data;
void *p_video_data;
};
struct sout_stream_sys_t
......@@ -143,8 +145,6 @@ struct sout_stream_sys_t
void ( *pf_audio_prerender_callback ) ( void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size );
void ( *pf_video_postrender_callback ) ( void* p_video_data, uint8_t* p_pixel_buffer, int width, int height, int pixel_pitch, int size, int pts );
void ( *pf_audio_postrender_callback ) ( void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int pts );
void *p_audio_data;
void *p_video_data;
bool time_sync;
};
......@@ -180,14 +180,6 @@ static int Open( vlc_object_t *p_this )
p_sys->pf_audio_postrender_callback = (void (*) (void*, uint8_t*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int))(intptr_t)atoll( psz_tmp );
free( psz_tmp );
psz_tmp = var_CreateGetString( p_stream, SOUT_PREFIX_VIDEO "data" );
p_sys->p_video_data = (void *)( intptr_t )atoll( psz_tmp );
free( psz_tmp );
psz_tmp = var_CreateGetString( p_stream, SOUT_PREFIX_AUDIO "data" );
p_sys->p_audio_data = (void *)( intptr_t )atoll( psz_tmp );
free( psz_tmp );
/* Setting stream out module callbacks */
p_stream->pf_add = Add;
p_stream->pf_del = Del;
......@@ -224,6 +216,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
{
char* psz_tmp;
sout_stream_id_t *id;
int i_bits_per_pixel;
......@@ -258,6 +251,10 @@ static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
if( !id )
return NULL;
psz_tmp = var_CreateGetString( p_stream, SOUT_PREFIX_VIDEO "data" );
id->p_video_data = (void *)( intptr_t )atoll( psz_tmp );
free( psz_tmp );
id->format = p_fmt;
id->format->video.i_bits_per_pixel = i_bits_per_pixel;
return id;
......@@ -265,6 +262,7 @@ static sout_stream_id_t *AddVideo( sout_stream_t *p_stream, es_format_t *p_fmt )
static sout_stream_id_t *AddAudio( sout_stream_t *p_stream, es_format_t *p_fmt )
{
char* psz_tmp;
sout_stream_id_t* id;
int i_bits_per_sample;
......@@ -304,6 +302,10 @@ static sout_stream_id_t *AddAudio( sout_stream_t *p_stream, es_format_t *p_fmt )
if( !id )
return NULL;
psz_tmp = var_CreateGetString( p_stream, SOUT_PREFIX_AUDIO "data" );
id->p_audio_data = (void *)( intptr_t )atoll( psz_tmp );
free( psz_tmp );
id->format = p_fmt;
id->format->audio.i_bitspersample = i_bits_per_sample;
return id;
......@@ -339,12 +341,12 @@ static int SendVideo( sout_stream_t *p_stream, sout_stream_id_t *id,
i_line_size = i_pixel_pitch * id->format->video.i_width;
i_size = i_line * i_line_size;
/* Calling the prerender callback to get user buffer */
p_sys->pf_video_prerender_callback( p_sys->p_video_data, &p_pixels , i_size );
p_sys->pf_video_prerender_callback( id->p_video_data, &p_pixels , i_size );
/* Copying data into user buffer */
for ( int line = 0; line < i_line; line++, p_pixels += i_line_size )
vlc_memcpy( p_pixels, p_buffer->p_buffer + i_line_size * line , i_line_size );
/* Calling the postrender callback to tell the user his buffer is ready */
p_sys->pf_video_postrender_callback( p_sys->p_video_data, p_pixels,
p_sys->pf_video_postrender_callback( id->p_video_data, p_pixels,
id->format->video.i_width, id->format->video.i_height,
id->format->video.i_bits_per_pixel, i_size, p_buffer->i_pts );
block_ChainRelease( p_buffer );
......@@ -362,11 +364,11 @@ static int SendAudio( sout_stream_t *p_stream, sout_stream_id_t *id,
i_size = p_buffer->i_buffer;
i_samples = i_size / ( ( id->format->audio.i_bitspersample / 8 ) * id->format->audio.i_channels );
/* Calling the prerender callback to get user buffer */
p_sys->pf_audio_prerender_callback( p_sys->p_audio_data, &p_pcm_buffer, i_size );
p_sys->pf_audio_prerender_callback( id->p_audio_data, &p_pcm_buffer, i_size );
/* Copying data into user buffer */
vlc_memcpy( p_pcm_buffer, p_buffer->p_buffer, i_size );
/* Calling the postrender callback to tell the user his buffer is ready */
p_sys->pf_audio_postrender_callback( p_sys->p_audio_data, p_pcm_buffer,
p_sys->pf_audio_postrender_callback( id->p_audio_data, p_pcm_buffer,
id->format->audio.i_channels, id->format->audio.i_rate, p_buffer->i_samples,
id->format->audio.i_bitspersample, i_size, p_buffer->i_pts );
block_ChainRelease( p_buffer );
......
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