Skip to content
Snippets Groups Projects
Commit 29d5f44e authored by François Cartegnie's avatar François Cartegnie :fingers_crossed:
Browse files

demux: adaptive: add encryption to segment info

parent e8dab66b
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,17 @@ CommonEncryption::CommonEncryption()
method = CommonEncryption::Method::NONE;
}
void CommonEncryption::mergeWith(const CommonEncryption &other)
{
if(method == CommonEncryption::Method::NONE &&
other.method != CommonEncryption::Method::NONE)
method = other.method;
if(uri.empty() && !other.uri.empty())
uri = other.uri;
if(iv.empty() && !other.iv.empty())
iv = other.iv;
}
CommonEncryptionSession::CommonEncryptionSession()
{
ctx = NULL;
......
......@@ -33,6 +33,7 @@ namespace adaptive
{
public:
CommonEncryption();
void mergeWith(const CommonEncryption &);
enum Method
{
NONE,
......
......@@ -67,12 +67,15 @@ void ISegment::onChunkDownload(block_t **, SegmentChunk *, BaseRepresentation *)
}
bool ISegment::prepareChunk(SharedResources *res, SegmentChunk *chunk, BaseRepresentation *)
bool ISegment::prepareChunk(SharedResources *res, SegmentChunk *chunk, BaseRepresentation *rep)
{
if(encryption.method != CommonEncryption::Method::NONE)
CommonEncryption enc = encryption;
enc.mergeWith(rep->intheritEncryption());
if(enc.method != CommonEncryption::Method::NONE)
{
CommonEncryptionSession *encryptionSession = new CommonEncryptionSession();
if(!encryptionSession->start(res, encryption))
if(!encryptionSession->start(res, enc))
{
delete encryptionSession;
return false;
......
......@@ -30,6 +30,7 @@
#include "SegmentTimeline.h"
#include "AbstractPlaylist.hpp"
#include "BaseRepresentation.h"
#include "../encryption/CommonEncryption.hpp"
#include <algorithm>
#include <cassert>
......@@ -510,6 +511,18 @@ uint64_t SegmentInformation::translateSegmentNumber(uint64_t num, const SegmentI
return num;
}
const CommonEncryption & SegmentInformation::intheritEncryption() const
{
if(parent && commonEncryption.method == CommonEncryption::Method::NONE)
return parent->intheritEncryption();
return commonEncryption;
}
void SegmentInformation::setEncryption(const CommonEncryption &enc)
{
commonEncryption = enc;
}
vlc_tick_t SegmentInformation::getPeriodStart() const
{
if(parent)
......
......@@ -22,6 +22,7 @@
#include "ICanonicalUrl.hpp"
#include "../tools/Properties.hpp"
#include "../encryption/CommonEncryption.hpp"
#include "SegmentInfoCommon.h"
#include <vlc_common.h>
#include <vector>
......@@ -86,6 +87,8 @@ namespace adaptive
virtual void pruneBySegmentNumber(uint64_t);
virtual void pruneByPlaybackTime(vlc_tick_t);
virtual uint64_t translateSegmentNumber(uint64_t, const SegmentInformation *) const;
void setEncryption(const CommonEncryption &);
const CommonEncryption & intheritEncryption() const;
protected:
std::size_t getAllSegments(std::vector<ISegment *> &) const;
......@@ -110,6 +113,7 @@ namespace adaptive
SegmentBase *segmentBase;
SegmentList *segmentList;
MediaSegmentTemplate *mediaSegmentTemplate;
CommonEncryption commonEncryption;
};
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment