Skip to content

Commit

Permalink
demux: ts: add stream_processor
Browse files Browse the repository at this point in the history
  • Loading branch information
fcartegnie committed Jun 21, 2017
1 parent 4e52f70 commit 1934536
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
18 changes: 10 additions & 8 deletions modules/demux/mpeg/ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,20 +1562,21 @@ static void ParsePESDataChain( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
p_block->i_pts += FROM_SCALE_NZ(p_pmt->pcr.i_pcroffset);
}

/*** From here, block can become a chain again though conversion below ***/

if( pid->u.p_stream->p_proc )
{
if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
ts_stream_processor_Reset( pid->u.p_stream->p_proc );
p_block = ts_stream_processor_Push( pid->u.p_stream->p_proc, i_stream_id, p_block );
}
/* METADATA in PES */
if( pid->u.p_stream->i_stream_type == 0x15 && i_stream_id == 0xbd )
else if( pid->u.p_stream->i_stream_type == 0x15 && i_stream_id == 0xbd )
{
ProcessMetadata( p_demux->out, p_es->metadata.i_format, p_pmt->i_number,
p_block->p_buffer, p_block->i_buffer );
}
else
/* SL in PES */
if( pid->u.p_stream->i_stream_type == 0x12 &&
((i_stream_id & 0xFE) == 0xFA) /* 0xFA || 0xFB */ )
{
p_block = SLProcessPacketized( pid->u.p_stream, p_es, p_block );
}
else
/* Some codecs might need xform or AU splitting */
{
p_block = ConvertPESBlock( p_demux, p_es, i_pes_size, i_stream_id, p_block );
Expand Down Expand Up @@ -1820,6 +1821,7 @@ static void ReadyQueuesPostSeek( demux_t *p_demux )
}

ts_sections_processor_Reset( pid->u.p_stream->p_sections_proc );
ts_stream_processor_Reset( pid->u.p_stream->p_proc );

FlushESBuffer( pid->u.p_stream );
}
Expand Down
4 changes: 4 additions & 0 deletions modules/demux/mpeg/ts_streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ ts_stream_t *ts_stream_New( demux_t *p_demux, ts_pmt_t *p_program )
pes->b_broken_PUSI_conformance = false;
pes->b_always_receive = false;
pes->p_sections_proc = NULL;
pes->p_proc = NULL;
pes->prepcr.p_head = NULL;
pes->prepcr.pp_last = &pes->prepcr.p_head;
pes->sl.p_data = NULL;
Expand All @@ -301,6 +302,9 @@ void ts_stream_Del( demux_t *p_demux, ts_stream_t *pes )
if( pes->p_sections_proc )
ts_sections_processor_ChainDelete( pes->p_sections_proc );

if( pes->p_proc )
ts_stream_processor_Delete( pes->p_proc );

if( pes->prepcr.p_head )
block_ChainRelease( pes->prepcr.p_head );

Expand Down
26 changes: 26 additions & 0 deletions modules/demux/mpeg/ts_streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ typedef struct ts_stream_t ts_stream_t;
typedef struct ts_si_t ts_si_t;
typedef struct ts_psip_t ts_psip_t;

typedef struct ts_stream_processor_t ts_stream_processor_t;
struct ts_stream_processor_t
{
void *priv;
void (*pf_delete)(ts_stream_processor_t *);
void (*pf_reset) (ts_stream_processor_t *);
block_t * (*pf_push) (ts_stream_processor_t *, uint8_t, block_t * );
};

static inline void ts_stream_processor_Delete( ts_stream_processor_t *sp )
{
if( sp )
sp->pf_delete( sp );
}

static inline void ts_stream_processor_Reset( ts_stream_processor_t *sp )
{
if( sp && sp->pf_reset )
sp->pf_reset( sp );
}

static inline block_t * ts_stream_processor_Push( ts_stream_processor_t *sp, uint8_t i_stream_id, block_t *b )
{
return (sp) ? sp->pf_push( sp, i_stream_id, b ) : b;
}

/* Structs */
ts_pat_t *ts_pat_New( demux_t * );
void ts_pat_Del( demux_t *, ts_pat_t * );
Expand Down
1 change: 1 addition & 0 deletions modules/demux/mpeg/ts_streams_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ struct ts_stream_t
bool b_always_receive;
bool b_broken_PUSI_conformance;
ts_sections_processor_t *p_sections_proc;
ts_stream_processor_t *p_proc;

struct
{
Expand Down

0 comments on commit 1934536

Please sign in to comment.