[vlc-commits] demux: hls: better check for ID3 header

Francois Cartegnie git at videolan.org
Fri Apr 15 14:46:06 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Apr 15 13:59:12 2016 +0200| [dafc3a9d5dffcfae39186a69749442a7614ad17d] | committer: Francois Cartegnie

demux: hls: better check for ID3 header

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dafc3a9d5dffcfae39186a69749442a7614ad17d
---

 modules/demux/hls/HLSStreams.cpp |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index 11299e8..308d8f3 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -106,10 +106,18 @@ static uint32_t ReadID3Size(const uint8_t *p_buffer)
           (( (uint32_t)p_buffer[0] & 0x7F ) << 21);
 }
 
+static bool IsID3Tag(const uint8_t *p_buffer)
+{
+    return( memcmp(p_buffer, "ID3", 3) == 0 &&
+            p_buffer[3] < 0xFF &&
+            p_buffer[4] < 0xFF &&
+           ((GetDWBE(&p_buffer[6]) & 0x80808080) == 0) );
+}
+
 block_t * HLSStream::checkBlock(block_t *p_block, bool b_first)
 {
     if(b_first && p_block &&
-       p_block->i_buffer >= 10 && !memcmp(p_block->p_buffer, "ID3", 3))
+       p_block->i_buffer >= 10 && IsID3Tag(p_block->p_buffer))
     {
         uint32_t size = ReadID3Size(&p_block->p_buffer[6]);
         size = __MIN(p_block->i_buffer, size + 10);



More information about the vlc-commits mailing list