[vlc-commits] demux: ts: convert mpeg4-sl handler to stream processor
Francois Cartegnie
git at videolan.org
Wed Jun 21 21:34:12 CEST 2017
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jun 20 11:00:32 2017 +0200| [91f5a46bf29013f52f42c937d36d3c1a7f0362f1] | committer: Francois Cartegnie
demux: ts: convert mpeg4-sl handler to stream processor
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91f5a46bf29013f52f42c937d36d3c1a7f0362f1
---
modules/demux/mpeg/ts.c | 9 +---
modules/demux/mpeg/ts_psi.c | 15 +++++--
modules/demux/mpeg/ts_sl.c | 75 +++++++++++++++++++++++++++++----
modules/demux/mpeg/ts_sl.h | 2 +-
modules/demux/mpeg/ts_streams.c | 2 -
modules/demux/mpeg/ts_streams_private.h | 7 ---
6 files changed, 81 insertions(+), 29 deletions(-)
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index 30a20c803d..de8d18a823 100644
--- a/modules/demux/mpeg/ts.c
+++ b/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 )
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index 3516482b49..290d678059 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/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;
diff --git a/modules/demux/mpeg/ts_sl.c b/modules/demux/mpeg/ts_sl.c
index 9ed958259a..a9fcc558c6 100644
--- a/modules/demux/mpeg/ts_sl.c
+++ b/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;
+}
diff --git a/modules/demux/mpeg/ts_sl.h b/modules/demux/mpeg/ts_sl.h
index 0d45b92c32..aa375f6e64 100644
--- a/modules/demux/mpeg/ts_sl.h
+++ b/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
diff --git a/modules/demux/mpeg/ts_streams.c b/modules/demux/mpeg/ts_streams.c
index d057d2842a..3b86e7e7e7 100644
--- a/modules/demux/mpeg/ts_streams.c
+++ b/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;
}
diff --git a/modules/demux/mpeg/ts_streams_private.h b/modules/demux/mpeg/ts_streams_private.h
index e9dac45672..29642531af 100644
--- a/modules/demux/mpeg/ts_streams_private.h
+++ b/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;
More information about the vlc-commits
mailing list