Browse Source

demux: ts: convert mpeg4-sl handler to stream processor

pull/58/head
Francois Cartegnie 9 years ago
parent
commit
91f5a46bf2
  1. 9
      modules/demux/mpeg/ts.c
  2. 15
      modules/demux/mpeg/ts_psi.c
  3. 75
      modules/demux/mpeg/ts_sl.c
  4. 2
      modules/demux/mpeg/ts_sl.h
  5. 2
      modules/demux/mpeg/ts_streams.c
  6. 7
      modules/demux/mpeg/ts_streams_private.h

9
modules/demux/mpeg/ts.c

@ -1783,13 +1783,8 @@ static inline void FlushESBuffer( ts_stream_t *p_pes )
p_pes->gather.pp_last = &p_pes->gather.p_data;
p_pes->gather.i_saved = 0;
}
if( p_pes->sl.p_data )
{
block_ChainRelease( p_pes->sl.p_data );
p_pes->sl.p_data = NULL;
p_pes->sl.pp_last = &p_pes->sl.p_data;
}
if( p_pes->p_proc )
ts_stream_processor_Reset( p_pes->p_proc );
}
static void ReadyQueuesPostSeek( demux_t *p_demux )

15
modules/demux/mpeg/ts_psi.c

@ -445,9 +445,18 @@ static void SetupISO14496Descriptors( demux_t *p_demux, ts_stream_t *p_pes,
{
p_es->i_sl_es_id = ( p_dr->p_data[0] << 8 ) | p_dr->p_data[1];
msg_Dbg( p_demux, " - found SL_descriptor mapping es_id=%"PRIu16, p_es->i_sl_es_id );
ts_sections_processor_Add( p_demux,
&p_pes->p_sections_proc, 0x05, 0x00,
SLPackets_Section_Handler, p_pes );
if( p_dvbpsies->i_type == 0x12 ) /* SL AU pes stream */
{
if( !p_pes->p_proc )
p_pes->p_proc = SL_stream_processor_New( p_pes );
}
else if( p_dvbpsies->i_type == 0x13 ) /* IOD / SL sections */
{
ts_sections_processor_Add( p_demux,
&p_pes->p_sections_proc, 0x05, 0x00,
SLPackets_Section_Handler, p_pes );
}
p_pes->b_always_receive = true;
}
break;

75
modules/demux/mpeg/ts_sl.c

@ -205,9 +205,42 @@ void SLPackets_Section_Handler( demux_t *p_demux,
}
}
block_t * SLProcessPacketized( ts_stream_t *p_pes, ts_es_t *p_es, block_t *p_block )
typedef struct
{
block_t *p_au;
block_t **pp_au_last;
ts_stream_t *p_stream;
} SL_stream_processor_context_t;
static void SL_stream_processor_Delete( ts_stream_processor_t *h )
{
SL_stream_processor_context_t *ctx = (SL_stream_processor_context_t *) h->priv;
block_ChainRelease( ctx->p_au );
free( ctx );
free( h );
}
static void SL_stream_processor_Reset( ts_stream_processor_t *h )
{
SL_stream_processor_context_t *ctx = (SL_stream_processor_context_t *) h->priv;
block_ChainRelease( ctx->p_au );
ctx->p_au = NULL;
ctx->pp_au_last = &ctx->p_au;
}
static block_t * SL_stream_processor_Push( ts_stream_processor_t *h, uint8_t i_stream_id, block_t *p_block )
{
SL_stream_processor_context_t *ctx = (SL_stream_processor_context_t *) h->priv;
ts_es_t *p_es = ctx->p_stream->p_es;
ts_pmt_t *p_pmt = p_es->p_program;
if( ((i_stream_id & 0xFE) != 0xFA) /* 0xFA || 0xFB */ )
{
block_Release( p_block );
return NULL;
}
const es_mpeg4_descriptor_t *p_desc = GetMPEG4DescByEsId( p_pmt, p_es->i_sl_es_id );
if(!p_desc)
{
@ -224,21 +257,45 @@ block_t * SLProcessPacketized( ts_stream_t *p_pes, ts_es_t *p_es, block_t *p_blo
p_block->i_pts = header.i_pts ? header.i_pts : p_block->i_pts;
/* Assemble access units */
if( header.b_au_start && p_pes->sl.p_data )
if( header.b_au_start && ctx->p_au )
{
block_ChainRelease( p_pes->sl.p_data );
p_pes->sl.p_data = NULL;
p_pes->sl.pp_last = &p_pes->sl.p_data;
block_ChainRelease( ctx->p_au );
ctx->p_au = NULL;
ctx->pp_au_last = &ctx->p_au;
}
block_ChainLastAppend( &p_pes->sl.pp_last, p_block );
block_ChainLastAppend( &ctx->pp_au_last, p_block );
p_block = NULL;
if( header.b_au_end )
{
p_block = block_ChainGather( p_pes->sl.p_data );
p_pes->sl.p_data = NULL;
p_pes->sl.pp_last = &p_pes->sl.p_data;
p_block = block_ChainGather( ctx->p_au );
ctx->p_au = NULL;
ctx->pp_au_last = &ctx->p_au;
}
}
return p_block;
}
ts_stream_processor_t *SL_stream_processor_New( ts_stream_t *p_stream )
{
ts_stream_processor_t *h = malloc(sizeof(*h));
if(!h)
return NULL;
SL_stream_processor_context_t *ctx = malloc( sizeof(SL_stream_processor_context_t) );
if(!ctx)
{
free(h);
return NULL;
}
ctx->p_au = NULL;
ctx->pp_au_last = &ctx->p_au;
ctx->p_stream = p_stream;
h->priv = ctx;
h->pf_delete = SL_stream_processor_Delete;
h->pf_push = SL_stream_processor_Push;
h->pf_reset = SL_stream_processor_Reset;
return h;
}

2
modules/demux/mpeg/ts_sl.h

@ -30,6 +30,6 @@ void SLPackets_Section_Handler( demux_t *p_demux,
bool SetupISO14496LogicalStream( demux_t *, const decoder_config_descriptor_t *,
es_format_t * );
block_t * SLProcessPacketized( ts_stream_t *, ts_es_t *, block_t * );
ts_stream_processor_t *SL_stream_processor_New( ts_stream_t * );
#endif

2
modules/demux/mpeg/ts_streams.c

@ -286,8 +286,6 @@ ts_stream_t *ts_stream_New( demux_t *p_demux, ts_pmt_t *p_program )
pes->p_proc = NULL;
pes->prepcr.p_head = NULL;
pes->prepcr.pp_last = &pes->prepcr.p_head;
pes->sl.p_data = NULL;
pes->sl.pp_last = &pes->sl.p_data;
return pes;
}

7
modules/demux/mpeg/ts_streams_private.h

@ -130,13 +130,6 @@ struct ts_stream_t
block_t *p_head;
block_t **pp_last;
} prepcr;
/* SL AU */
struct
{
block_t *p_data;
block_t **pp_last;
} sl;
};
typedef struct ts_si_context_t ts_si_context_t;

Loading…
Cancel
Save