[vlc-commits] demux: hls: refactor parsing of encryption
Francois Cartegnie
git at videolan.org
Fri May 10 11:13:26 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Apr 19 11:34:24 2019 +0200| [17b33eea06c3604ed06613ba35b2a713a52a5652] | committer: Francois Cartegnie
demux: hls: refactor parsing of encryption
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=17b33eea06c3604ed06613ba35b2a713a52a5652
---
modules/demux/hls/playlist/Parser.cpp | 68 +++++++++++++++++++----------------
1 file changed, 37 insertions(+), 31 deletions(-)
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 109ca08a91..941f8f30ba 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -193,6 +193,41 @@ bool M3U8Parser::appendSegmentsFromPlaylistURI(vlc_object_t *p_obj, Representati
return false;
}
+static bool parseEncryption(const AttributesTag *keytag, const Url &playlistUrl,
+ CommonEncryption &encryption)
+{
+ if( keytag->getAttributeByName("METHOD") &&
+ keytag->getAttributeByName("METHOD")->value == "AES-128" &&
+ keytag->getAttributeByName("URI") )
+ {
+ encryption.method = CommonEncryption::Method::AES_128;
+ encryption.uri.clear();
+
+ Url keyurl(keytag->getAttributeByName("URI")->quotedString());
+ if(!keyurl.hasScheme())
+ {
+ keyurl.prepend(Helper::getDirectoryPath(playlistUrl.toString()).append("/"));
+ }
+
+ encryption.uri = keyurl.toString();
+
+ if(keytag->getAttributeByName("IV"))
+ {
+ encryption.iv.clear();
+ encryption.iv = keytag->getAttributeByName("IV")->hexSequence();
+ }
+ return true;
+ }
+ else
+ {
+ /* unsupported or invalid */
+ encryption.method = CommonEncryption::Method::NONE;
+ encryption.uri.clear();
+ encryption.iv.clear();
+ return false;
+ }
+}
+
void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::list<Tag *> &tagslist)
{
SegmentList *segmentList = new (std::nothrow) SegmentList(rep);
@@ -309,37 +344,8 @@ void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::l
break;
case AttributesTag::EXTXKEY:
- {
- const AttributesTag *keytag = static_cast<const AttributesTag *>(tag);
- if( keytag->getAttributeByName("METHOD") &&
- keytag->getAttributeByName("METHOD")->value == "AES-128" &&
- keytag->getAttributeByName("URI") )
- {
- encryption.method = CommonEncryption::Method::AES_128;
- encryption.uri.clear();
-
- Url keyurl(keytag->getAttributeByName("URI")->quotedString());
- if(!keyurl.hasScheme())
- {
- keyurl.prepend(Helper::getDirectoryPath(rep->getPlaylistUrl().toString()).append("/"));
- }
-
- encryption.uri = keyurl.toString();
-
- if(keytag->getAttributeByName("IV"))
- {
- encryption.iv.clear();
- encryption.iv = keytag->getAttributeByName("IV")->hexSequence();
- }
- }
- else
- {
- /* unsupported or invalid */
- encryption.method = CommonEncryption::Method::NONE;
- encryption.uri.clear();
- encryption.iv.clear();
- }
- }
+ parseEncryption(static_cast<const AttributesTag *>(tag),
+ rep->getPlaylistUrl(), encryption);
break;
case AttributesTag::EXTXMAP:
More information about the vlc-commits
mailing list