[vlc-commits] demux: hls: set ID3 time offset

Francois Cartegnie git at videolan.org
Mon Mar 30 16:16:04 CEST 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun 26 22:08:33 2019 +0200| [2fe34e60b80d30ba626d61c9d9c8eda7ff90bad6] | committer: Francois Cartegnie

demux: hls: set ID3 time offset

callback lost or disabled ?

(cherry picked from commit cc646df5fd14e4201dbfa2e829528fbef8c34ae5)

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

 modules/demux/hls/HLSStreams.cpp | 35 ++++++++++++++++++-----------------
 modules/demux/hls/HLSStreams.hpp |  3 ++-
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index 2bec05c619..8c44ef18ca 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -47,24 +47,27 @@ HLSStream::~HLSStream()
         vlc_meta_Delete(p_meta);
 }
 
-void HLSStream::setTimeOffset(mtime_t i_offset)
+void HLSStream::setMetadataTimeOffset(mtime_t i_offset)
 {
     if(i_offset >= 0)
     {
-        if((unsigned)format == StreamFormat::PACKEDAAC)
-        {
-            if(!b_id3_timestamps_offset_set)
-            {
-                fakeEsOut()->setAssociatedTimestamp(i_offset);
-            }
-            return;
-        }
+        if(!b_id3_timestamps_offset_set)
+            fakeEsOut()->setAssociatedTimestamp(i_offset);
+        b_id3_timestamps_offset_set = true;
     }
     else
     {
+        fakeEsOut()->setAssociatedTimestamp(-1);
         b_id3_timestamps_offset_set = false;
     }
-    AbstractStream::setTimeOffset(i_offset);
+}
+
+bool HLSStream::setPosition(mtime_t ts , bool b)
+{
+    bool ok = AbstractStream::setPosition(ts ,b);
+    if(b && ok)
+        b_id3_timestamps_offset_set = false;
+    return ok;
 }
 
 int HLSStream::ParseID3PrivTag(const uint8_t *p_payload, size_t i_payload)
@@ -72,19 +75,17 @@ int HLSStream::ParseID3PrivTag(const uint8_t *p_payload, size_t i_payload)
     if(i_payload == 53 &&
        !memcmp( p_payload, "com.apple.streaming.transportStreamTimestamp", 45))
     {
-        if(!b_id3_timestamps_offset_set)
-        {
-            const mtime_t i_aac_offset = GetQWBE(&p_payload[45]) * 100 / 9;
-            setTimeOffset(i_aac_offset);
-            b_id3_timestamps_offset_set = true;
-        }
+        setMetadataTimeOffset(GetQWBE(&p_payload[45]) * 100 / 9);
     }
     return VLC_SUCCESS;
 }
 
 int HLSStream::ParseID3Tag(uint32_t i_tag, const uint8_t *p_payload, size_t i_payload)
 {
-    (void) ID3HandleTag(p_payload, i_payload, i_tag, p_meta, &b_meta_updated);
+    if(i_tag == VLC_FOURCC('P','R','I','V'))
+        (void) ParseID3PrivTag(p_payload, i_payload);
+    else
+        (void) ID3HandleTag(p_payload, i_payload, i_tag, p_meta, &b_meta_updated);
     return VLC_SUCCESS;
 }
 
diff --git a/modules/demux/hls/HLSStreams.hpp b/modules/demux/hls/HLSStreams.hpp
index 669c54cdfe..f80e76a089 100644
--- a/modules/demux/hls/HLSStreams.hpp
+++ b/modules/demux/hls/HLSStreams.hpp
@@ -33,15 +33,16 @@ namespace hls
             virtual ~HLSStream();
 
         protected:
-            virtual void setTimeOffset(mtime_t); /* reimpl */
             virtual block_t *checkBlock(block_t *, bool); /* reimpl */
             virtual AbstractDemuxer * newDemux(demux_t *, const StreamFormat &,
                                                es_out_t *, AbstractSourceStream *) const; /* reimpl */
+            virtual bool setPosition(mtime_t, bool);
 
         private:
             static int ID3TAG_Parse_Handler(uint32_t, const uint8_t *, size_t, void *);
             int ParseID3Tag(uint32_t, const uint8_t *, size_t);
             int ParseID3PrivTag(const uint8_t *, size_t);
+            void setMetadataTimeOffset(mtime_t);
             bool b_id3_timestamps_offset_set;
             vlc_meta_t *p_meta;
             bool b_meta_updated;



More information about the vlc-commits mailing list