[vlc-commits] demux: hls: add support for stream metadata
Francois Cartegnie
git at videolan.org
Sat Oct 15 23:16:13 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Oct 15 12:46:29 2016 +0200| [65d21dd5fa50f061b3e43ab92544109ee2010a3d] | committer: Francois Cartegnie
demux: hls: add support for stream metadata
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=65d21dd5fa50f061b3e43ab92544109ee2010a3d
---
modules/demux/Makefile.am | 3 ++-
modules/demux/hls/HLSStreams.cpp | 35 +++++++++++++++++++++++++++--------
modules/demux/hls/HLSStreams.hpp | 7 ++++++-
3 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index b9eb51c..22a2051 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -416,7 +416,8 @@ libadaptive_hls_SOURCES = \
demux/hls/HLSManager.cpp \
demux/hls/HLSStreams.hpp \
demux/hls/HLSStreams.cpp
-libadaptive_hls_SOURCES += meta_engine/ID3Tag.h
+libadaptive_hls_SOURCES += meta_engine/ID3Tag.h \
+ meta_engine/ID3Meta.h
libadaptive_smooth_SOURCES = \
demux/smooth/mp4/IndexReader.cpp \
diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index 1d065f4..aaea520 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -23,10 +23,12 @@
#include "HLSStreams.hpp"
#include <vlc_demux.h>
+#include <vlc_meta.h>
extern "C"
{
#include "../meta_engine/ID3Tag.h"
+ #include "../meta_engine/ID3Meta.h"
}
using namespace hls;
@@ -35,6 +37,14 @@ HLSStream::HLSStream(demux_t *demux)
: AbstractStream(demux)
{
b_id3_timestamps_offset_set = false;
+ p_meta = vlc_meta_New();
+ b_meta_updated = false;
+}
+
+HLSStream::~HLSStream()
+{
+ if(p_meta)
+ vlc_meta_Delete(p_meta);
}
void HLSStream::setTimeOffset(mtime_t i_offset)
@@ -92,7 +102,7 @@ AbstractDemuxer * HLSStream::createDemux(const StreamFormat &format)
return ret;
}
-int HLSStream::ID3PrivTagHandler(const uint8_t *p_payload, size_t i_payload)
+int HLSStream::ParseID3PrivTag(const uint8_t *p_payload, size_t i_payload)
{
if(i_payload == 53 &&
!memcmp( p_payload, "com.apple.streaming.transportStreamTimestamp", 45))
@@ -103,21 +113,22 @@ int HLSStream::ID3PrivTagHandler(const uint8_t *p_payload, size_t i_payload)
setTimeOffset(i_aac_offset);
b_id3_timestamps_offset_set = true;
}
- return VLC_EGENERIC; /* stop parsing */
}
return VLC_SUCCESS;
}
-static int ID3TAG_Parse_Handler(uint32_t i_tag, const uint8_t *p_payload, size_t i_payload, void *p_priv)
+int HLSStream::ParseID3Tag(uint32_t i_tag, const uint8_t *p_payload, size_t i_payload)
{
- HLSStream *hlsstream = static_cast<HLSStream *>(p_priv);
-
- if(i_tag == VLC_FOURCC('P', 'R', 'I', 'V'))
- return hlsstream->ID3PrivTagHandler(p_payload, i_payload);
-
+ (void) ID3HandleTag(p_payload, i_payload, i_tag, p_meta, &b_meta_updated);
return VLC_SUCCESS;
}
+int HLSStream::ID3TAG_Parse_Handler(uint32_t i_tag, const uint8_t *p_payload, size_t i_payload, void *p_priv)
+{
+ HLSStream *hlsstream = static_cast<HLSStream *>(p_priv);
+ return hlsstream->ParseID3Tag(i_tag, p_payload, i_payload);
+}
+
block_t * HLSStream::checkBlock(block_t *p_block, bool b_first)
{
if(b_first && p_block &&
@@ -135,6 +146,14 @@ block_t * HLSStream::checkBlock(block_t *p_block, bool b_first)
}
}
+ if( b_meta_updated )
+ {
+ b_meta_updated = false;
+ AbstractCommand *command = commandsqueue->factory()->createEsOutMetaCommand( -1, p_meta );
+ if( command )
+ commandsqueue->Schedule( command );
+ }
+
return p_block;
}
diff --git a/modules/demux/hls/HLSStreams.hpp b/modules/demux/hls/HLSStreams.hpp
index a74d989..ab067f7 100644
--- a/modules/demux/hls/HLSStreams.hpp
+++ b/modules/demux/hls/HLSStreams.hpp
@@ -30,7 +30,7 @@ namespace hls
{
public:
HLSStream(demux_t *);
- int ID3PrivTagHandler( const uint8_t *, size_t );
+ virtual ~HLSStream();
protected:
virtual AbstractDemuxer * createDemux(const StreamFormat &); /* reimpl */
@@ -38,7 +38,12 @@ namespace hls
virtual block_t *checkBlock(block_t *, bool); /* reimpl */
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);
bool b_id3_timestamps_offset_set;
+ vlc_meta_t *p_meta;
+ bool b_meta_updated;
};
class HLSStreamFactory : public AbstractStreamFactory
More information about the vlc-commits
mailing list