Commit 1c332603 authored by Laurent Aimar's avatar Laurent Aimar

* mpeg4audio.c: new packetizer (but for now it don't support adts aac)

 * mpeg4video.c: I 've rewritten it
parent 8c45a841
...@@ -3,3 +3,4 @@ SOURCES_packetizer_a52 = modules/packetizer/a52.c ...@@ -3,3 +3,4 @@ SOURCES_packetizer_a52 = modules/packetizer/a52.c
SOURCES_packetizer_mpegaudio = modules/packetizer/mpegaudio.c SOURCES_packetizer_mpegaudio = modules/packetizer/mpegaudio.c
SOURCES_packetizer_mpegvideo = modules/packetizer/mpegvideo.c SOURCES_packetizer_mpegvideo = modules/packetizer/mpegvideo.c
SOURCES_packetizer_mpeg4video = modules/packetizer/mpeg4video.c SOURCES_packetizer_mpeg4video = modules/packetizer/mpeg4video.c
SOURCES_packetizer_mpeg4audio = modules/packetizer/mpeg4audio.c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* copy.c * copy.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: copy.c,v 1.1 2002/12/14 21:32:41 fenrir Exp $ * $Id: copy.c,v 1.2 2003/01/08 10:26:49 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -46,6 +46,8 @@ typedef struct packetizer_thread_s ...@@ -46,6 +46,8 @@ typedef struct packetizer_thread_s
sout_input_t *p_sout_input; sout_input_t *p_sout_input;
sout_packet_format_t output_format; sout_packet_format_t output_format;
mtime_t i_pts_start;
} packetizer_thread_t; } packetizer_thread_t;
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
...@@ -55,6 +57,9 @@ static int InitThread ( packetizer_thread_t * ); ...@@ -55,6 +57,9 @@ static int InitThread ( packetizer_thread_t * );
static void PacketizeThread ( packetizer_thread_t * ); static void PacketizeThread ( packetizer_thread_t * );
static void EndThread ( packetizer_thread_t * ); static void EndThread ( packetizer_thread_t * );
static void input_ShowPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -141,20 +146,44 @@ static int Run( decoder_fifo_t *p_fifo ) ...@@ -141,20 +146,44 @@ static int Run( decoder_fifo_t *p_fifo )
static int InitThread( packetizer_thread_t *p_pack ) static int InitThread( packetizer_thread_t *p_pack )
{ {
// p_pack->output_format.i_cat = p_pack->p_fifo->i_cat; switch( p_pack->p_fifo->i_fourcc )
p_pack->output_format.i_fourcc = p_pack->p_fifo->i_fourcc; {
case VLC_FOURCC( 'm', 'p', '4', 'v'):
case VLC_FOURCC( 'D', 'I', 'V', 'X'):
case VLC_FOURCC( 'd', 'i', 'v', 'x'):
case VLC_FOURCC( 'X', 'V', 'I', 'D'):
case VLC_FOURCC( 'X', 'v', 'i', 'D'):
case VLC_FOURCC( 'x', 'v', 'i', 'd'):
case VLC_FOURCC( 'D', 'X', '5', '0'):
p_pack->output_format.i_fourcc = VLC_FOURCC( 'm', 'p', '4', 'v');
p_pack->output_format.i_cat = VIDEO_ES;
break;
case VLC_FOURCC( 'm', 'p', 'g', 'v' ):
case VLC_FOURCC( 'm', 'p', 'g', '1' ):
case VLC_FOURCC( 'm', 'p', 'g', '2' ):
p_pack->output_format.i_fourcc = VLC_FOURCC( 'm', 'p', 'g', 'v' );
p_pack->output_format.i_cat = VIDEO_ES;
break;
case VLC_FOURCC( 'm', 'p', 'g', 'a' ):
p_pack->output_format.i_fourcc = VLC_FOURCC( 'm', 'p', 'g', 'a' );
p_pack->output_format.i_cat = AUDIO_ES;
break;
default:
p_pack->output_format.i_fourcc = p_pack->p_fifo->i_fourcc;
p_pack->output_format.i_cat = UNKNOWN_ES;
break;
}
p_pack->p_sout_input = p_pack->p_sout_input =
sout_InputNew( p_pack->p_fifo, sout_InputNew( p_pack->p_fifo,
&p_pack->output_format ); &p_pack->output_format );
if( !p_pack->p_sout_input ) if( !p_pack->p_sout_input )
{ {
msg_Err( p_pack->p_fifo, msg_Err( p_pack->p_fifo, "cannot add a new stream" );
"cannot add a new stream" );
return( -1 ); return( -1 );
} }
p_pack->i_pts_start = -1;
return( 0 ); return( 0 );
} }
...@@ -174,10 +203,15 @@ static void PacketizeThread( packetizer_thread_t *p_pack ) ...@@ -174,10 +203,15 @@ static void PacketizeThread( packetizer_thread_t *p_pack )
p_pack->p_fifo->b_error = 1; p_pack->p_fifo->b_error = 1;
return; return;
} }
if( p_pack->i_pts_start < 0 && p_pes->i_pts > 0 )
{
p_pack->i_pts_start = p_pes->i_pts;
}
i_size = p_pes->i_pes_size; i_size = p_pes->i_pes_size;
// msg_Dbg( p_pack->p_fifo, "pes size:%d", i_size );
if( i_size > 0 ) if( i_size > 0 )
{ {
pes_packet_t *p_pes_next;
data_packet_t *p_data; data_packet_t *p_data;
size_t i_buffer; size_t i_buffer;
...@@ -205,7 +239,16 @@ static void PacketizeThread( packetizer_thread_t *p_pack ) ...@@ -205,7 +239,16 @@ static void PacketizeThread( packetizer_thread_t *p_pack )
} }
i_buffer += i_copy; i_buffer += i_copy;
} }
p_sout_buffer->i_length = 0;
p_sout_buffer->i_dts = p_pes->i_pts - p_pack->i_pts_start;
p_sout_buffer->i_pts = p_pes->i_pts - p_pack->i_pts_start;
p_sout_buffer->i_bitrate = 0;
input_ShowPES( p_pack->p_fifo, &p_pes_next );
if( p_pes_next )
{
p_sout_buffer->i_length = p_pes_next->i_pts - p_pes->i_pts;
}
sout_InputSendBuffer( p_pack->p_sout_input, sout_InputSendBuffer( p_pack->p_sout_input,
p_sout_buffer ); p_sout_buffer );
} }
...@@ -225,3 +268,35 @@ static void EndThread ( packetizer_thread_t *p_pack) ...@@ -225,3 +268,35 @@ static void EndThread ( packetizer_thread_t *p_pack)
} }
} }
static void input_ShowPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes )
{
pes_packet_t *p_pes;
vlc_mutex_lock( &p_fifo->data_lock );
if( p_fifo->p_first == NULL )
{
if( p_fifo->b_die )
{
vlc_mutex_unlock( &p_fifo->data_lock );
if( pp_pes ) *pp_pes = NULL;
return;
}
/* Signal the input thread we're waiting. This is only
* needed in case of slave clock (ES plug-in) but it won't
* harm. */
vlc_cond_signal( &p_fifo->data_wait );
/* Wait for the input to tell us when we received a packet. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
p_pes = p_fifo->p_first;
vlc_mutex_unlock( &p_fifo->data_lock );
if( pp_pes )
{
*pp_pes = p_pes;
}
}
This diff is collapsed.
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpegvideo.c * mpegvideo.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: mpegvideo.c,v 1.1 2002/12/14 21:32:41 fenrir Exp $ * $Id: mpegvideo.c,v 1.2 2003/01/08 10:26:49 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org> * Eric Petit <titer@videolan.org>
...@@ -83,7 +83,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -83,7 +83,9 @@ static int Open( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
if( p_fifo->i_fourcc != VLC_FOURCC( 'm', 'p', 'g', 'v') ) if( p_fifo->i_fourcc != VLC_FOURCC( 'm', 'p', 'g', 'v') &&
p_fifo->i_fourcc != VLC_FOURCC( 'm', 'p', 'g', '1') &&
p_fifo->i_fourcc != VLC_FOURCC( 'm', 'p', 'g', '2') )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -152,7 +154,7 @@ static int InitThread( packetizer_t *p_pack ) ...@@ -152,7 +154,7 @@ static int InitThread( packetizer_t *p_pack )
{ {
p_pack->output_format.i_cat = VIDEO_ES; p_pack->output_format.i_cat = VIDEO_ES;
p_pack->output_format.i_fourcc = p_pack->p_fifo->i_fourcc; p_pack->output_format.i_fourcc = VLC_FOURCC( 'm', 'p', 'g', 'v');
p_pack->p_sout_input = NULL; p_pack->p_sout_input = NULL;
......
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