[vlc-commits] demux: hls: move probing to manager
Francois Cartegnie
git at videolan.org
Fri Jul 24 15:09:28 CEST 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jul 23 17:06:01 2015 +0200| [d63b800e35262312737d33e96202785bd57638fa] | committer: Francois Cartegnie
demux: hls: move probing to manager
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d63b800e35262312737d33e96202785bd57638fa
---
modules/demux/hls/HLSManager.cpp | 56 ++++++++++++++++++++++++++++++++++++
modules/demux/hls/HLSManager.hpp | 2 ++
modules/demux/hls/hls.cpp | 58 +-------------------------------------
3 files changed, 59 insertions(+), 57 deletions(-)
diff --git a/modules/demux/hls/HLSManager.cpp b/modules/demux/hls/HLSManager.cpp
index 507a73b..21b432a 100644
--- a/modules/demux/hls/HLSManager.cpp
+++ b/modules/demux/hls/HLSManager.cpp
@@ -46,6 +46,62 @@ HLSManager::~HLSManager()
{
}
+bool HLSManager::isHTTPLiveStreaming(stream_t *s)
+{
+ const uint8_t *peek;
+
+ int size = stream_Peek(s, &peek, 7);
+ if (size < 7 || memcmp(peek, "#EXTM3U", 7))
+ return false;
+
+ size = stream_Peek(s, &peek, 512);
+ if (size < 7)
+ return false;
+
+ peek += 7;
+ size -= 7;
+
+ /* Parse stream and search for
+ * EXT-X-TARGETDURATION or EXT-X-STREAM-INF tag, see
+ * http://tools.ietf.org/html/draft-pantos-http-live-streaming-04#page-8 */
+ while (size--)
+ {
+ static const char *const ext[] = {
+ "TARGETDURATION",
+ "MEDIA-SEQUENCE",
+ "KEY",
+ "ALLOW-CACHE",
+ "ENDLIST",
+ "STREAM-INF",
+ "DISCONTINUITY",
+ "VERSION"
+ };
+
+ if (*peek++ != '#')
+ continue;
+
+ if (size < 6)
+ continue;
+
+ if (memcmp(peek, "EXT-X-", 6))
+ continue;
+
+ peek += 6;
+ size -= 6;
+
+ for (size_t i = 0; i < ARRAY_SIZE(ext); i++)
+ {
+ size_t len = strlen(ext[i]);
+ if (size < 0 || (size_t)size < len)
+ continue;
+ if (!memcmp(peek, ext[i], len))
+ return true;
+ }
+ }
+
+ return false;
+}
+
AbstractAdaptationLogic *HLSManager::createLogic(AbstractAdaptationLogic::LogicType type)
{
switch(type)
diff --git a/modules/demux/hls/HLSManager.hpp b/modules/demux/hls/HLSManager.hpp
index 917abc6..de8dfea 100644
--- a/modules/demux/hls/HLSManager.hpp
+++ b/modules/demux/hls/HLSManager.hpp
@@ -37,6 +37,8 @@ namespace hls
virtual ~HLSManager();
virtual AbstractAdaptationLogic *createLogic(AbstractAdaptationLogic::LogicType);
virtual bool updatePlaylist();
+
+ static bool isHTTPLiveStreaming(stream_t *);
};
}
diff --git a/modules/demux/hls/hls.cpp b/modules/demux/hls/hls.cpp
index d134f01..f8d3899 100644
--- a/modules/demux/hls/hls.cpp
+++ b/modules/demux/hls/hls.cpp
@@ -94,67 +94,11 @@ vlc_module_end ()
/*****************************************************************************
* Open:
*****************************************************************************/
-static bool isHTTPLiveStreaming(stream_t *s)
-{
- const uint8_t *peek;
-
- int size = stream_Peek(s, &peek, 7);
- if (size < 7 || memcmp(peek, "#EXTM3U", 7))
- return false;
-
- size = stream_Peek(s, &peek, 512);
- if (size < 7)
- return false;
-
- peek += 7;
- size -= 7;
-
- /* Parse stream and search for
- * EXT-X-TARGETDURATION or EXT-X-STREAM-INF tag, see
- * http://tools.ietf.org/html/draft-pantos-http-live-streaming-04#page-8 */
- while (size--)
- {
- static const char *const ext[] = {
- "TARGETDURATION",
- "MEDIA-SEQUENCE",
- "KEY",
- "ALLOW-CACHE",
- "ENDLIST",
- "STREAM-INF",
- "DISCONTINUITY",
- "VERSION"
- };
-
- if (*peek++ != '#')
- continue;
-
- if (size < 6)
- continue;
-
- if (memcmp(peek, "EXT-X-", 6))
- continue;
-
- peek += 6;
- size -= 6;
-
- for (size_t i = 0; i < ARRAY_SIZE(ext); i++)
- {
- size_t len = strlen(ext[i]);
- if (size < 0 || (size_t)size < len)
- continue;
- if (!memcmp(peek, ext[i], len))
- return true;
- }
- }
-
- return false;
-}
-
static int Open(vlc_object_t *p_obj)
{
demux_t *p_demux = (demux_t*) p_obj;
- if(!isHTTPLiveStreaming(p_demux->s))
+ if(!HLSManager::isHTTPLiveStreaming(p_demux->s))
return VLC_EGENERIC;
Parser parser(p_demux->s);
More information about the vlc-commits
mailing list