[vlc-commits] [Git][videolan/vlc][master] 3 commits: demux: ts: pass metadata blocks to handler pre PCR

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Apr 25 06:07:28 UTC 2022



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
4b4f7953 by Francois Cartegnie at 2022-04-25T05:52:52+00:00
demux: ts: pass metadata blocks to handler pre PCR

- - - - -
031c0ce8 by Francois Cartegnie at 2022-04-25T05:52:52+00:00
demux: ts: fully parse metadata descriptor

- - - - -
26a7249a by Francois Cartegnie at 2022-04-25T05:52:52+00:00
demux: ts: late reject unknown metadata packetizations

- - - - -


6 changed files:

- modules/demux/mpeg/ts.c
- modules/demux/mpeg/ts_metadata.c
- modules/demux/mpeg/ts_metadata.h
- modules/demux/mpeg/ts_psi.c
- modules/demux/mpeg/ts_streams.c
- modules/demux/mpeg/ts_streams_private.h


Changes:

=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -1742,7 +1742,15 @@ static void ParsePESDataChain( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes,
                 if( !p_pmt->pcr.b_fix_done ) /* Not seen yet */
                     PCRFixHandle( p_demux, p_pmt, p_block );
 
-                block_ChainLastAppend( &pid->u.p_stream->prepcr.pp_last, p_block );
+                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 );
+                }
+
+                if( p_block )
+                    block_ChainLastAppend( &pid->u.p_stream->prepcr.pp_last, p_block );
 
                 /* PCR Seen and no es->id, cleanup current and prepcr blocks */
                 if( p_pmt->pcr.i_current > -1)


=====================================
modules/demux/mpeg/ts_metadata.c
=====================================
@@ -62,13 +62,8 @@ static block_t * Metadata_stream_processor_Push( ts_stream_processor_t *h, uint8
     Metadata_stream_processor_context_t *ctx = (Metadata_stream_processor_context_t *) h->priv;
     ts_es_t *p_es = ctx->p_stream->p_es;
 
-    if( i_stream_id != 0xbd )
-    {
-        block_Release( p_block );
-        return NULL;
-    }
-
-    if( p_es->metadata.i_format == VLC_FOURCC('I', 'D', '3', ' ') )
+    if( i_stream_id == 0xbd && /* Transport in PES packets, 2.12.3 */
+        p_es->metadata.i_format_identifier == METADATA_IDENTIFIER_ID3 )
     {
         vlc_meta_t *p_meta = vlc_meta_New();
         if( p_meta )


=====================================
modules/demux/mpeg/ts_metadata.h
=====================================
@@ -19,6 +19,8 @@
 #ifndef VLC_TS_METADATA_H
 #define VLC_TS_METADATA_H
 
+#define METADATA_IDENTIFIER_ID3  VLC_FOURCC('I','D','3',' ')
+
 ts_stream_processor_t *Metadata_stream_processor_New( ts_stream_t *, es_out_t * );
 
 #endif


=====================================
modules/demux/mpeg/ts_psi.c
=====================================
@@ -632,22 +632,48 @@ static void SetupISO14496Descriptors( demux_t *p_demux, ts_stream_t *p_pes,
 static void SetupMetadataDescriptors( demux_t *p_demux, ts_stream_t *p_stream, const dvbpsi_pmt_es_t *p_dvbpsies )
 {
     ts_es_t *p_es = p_stream->p_es;
-    const dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x26 );
-    if( p_dr && p_dr->i_length >= 13 )
+    for( const dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x26 );
+                                   p_dr; p_dr = p_dr->p_next )
     {
-        /* app format 0xFFFF
-         * metadata_application_format_identifier ID3\x20
-         * i_metadata_format 0xFF
+        if( p_dr->i_tag != 0x26 || p_dr->i_length < 5 )
+            continue;
+
+        const uint8_t *p_data = p_dr->p_data;
+        size_t i_data = p_dr->i_length;
+
+        if( GetWBE(p_data) == 0xFFFF ) /* metadata_application_format */
+        {
+            if( i_data < 9 )
+                return;
+            p_es->metadata.i_application_format_identifier = VLC_FOURCC(p_data[2], p_data[3], p_data[4], p_data[5]);
+            p_data += 4; i_data -= 4;
+        }
+        p_data += 2; i_data -= 2;
+
+        if(p_data[0] == 0xFF) /* metadata_format */
+        {
+            if( i_data < 7 )
+                return;
+            p_es->metadata.i_format_identifier = VLC_FOURCC(p_data[1], p_data[2], p_data[3], p_data[4]);
+            p_data += 4; i_data -= 4;
+        }
+        p_data += 1; i_data -= 1;
+
+        p_es->metadata.i_service_id = p_data[0];
+        const uint8_t flags = p_data[1];
+        p_data += 2; i_data -= 2;
+
+        /* metadata_application_format_identifier ID3\x20
          * metadata_format_identifier ID3\x20 */
-        if( !memcmp( p_dr->p_data, "\xFF\xFFID3 \xFFID3 ", 11 ) &&
-            (p_dr->p_data[12] & 0xF0) == 0x00 )
+        if( p_es->metadata.i_application_format_identifier == METADATA_IDENTIFIER_ID3 &&
+            p_es->metadata.i_format_identifier == METADATA_IDENTIFIER_ID3 &&
+            (flags & 0xF0) == 0x00 )
         {
-            p_es->metadata.i_format = VLC_FOURCC('I', 'D', '3', ' ');
-            p_es->metadata.i_service_id = p_dr->p_data[11];
             msg_Dbg( p_demux, "     - found Metadata_descriptor type ID3 with service_id=0x%"PRIx8,
-                     p_dr->p_data[11] );
+                     p_es->metadata.i_service_id );
             if( !p_stream->p_proc )
                 p_stream->p_proc = Metadata_stream_processor_New( p_stream, p_demux->out );
+            break;
         }
     }
 }


=====================================
modules/demux/mpeg/ts_streams.c
=====================================
@@ -181,7 +181,8 @@ ts_es_t * ts_es_New( ts_pmt_t *p_program )
         p_es->b_interlaced = false;
         es_format_Init( &p_es->fmt, UNKNOWN_ES, 0 );
         p_es->fmt.i_group = p_program->i_number;
-        p_es->metadata.i_format = 0;
+        p_es->metadata.i_application_format_identifier = 0;
+        p_es->metadata.i_format_identifier = 0;
         p_es->metadata.i_service_id = 0;
     }
     return p_es;


=====================================
modules/demux/mpeg/ts_streams_private.h
=====================================
@@ -99,7 +99,8 @@ struct ts_es_t
     struct
     {
         uint8_t i_service_id;
-        uint32_t i_format;
+        uint32_t i_application_format_identifier;
+        uint32_t i_format_identifier;
     } metadata;
 };
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3ee0fd64f00bdc5b2cd5d5422989407d0665f73d...26a7249a5c7e1fa7a3247f40e149b2c89433a695

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3ee0fd64f00bdc5b2cd5d5422989407d0665f73d...26a7249a5c7e1fa7a3247f40e149b2c89433a695
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list