Skip to content

Commit 9992a4c

Browse files
committed
wip
1 parent a1a28e0 commit 9992a4c

26 files changed

+1106
-881
lines changed

src/Session.cpp

+104-515
Large diffs are not rendered by default.

src/Session.h

+6-75
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "Stream.h"
1212
#include "common/AdaptiveStream.h"
1313
#include "common/AdaptiveTree.h"
14+
#include "decrypters/DrmEngine.h"
1415
#include "decrypters/IDecrypter.h"
1516

1617
#if defined(ANDROID)
@@ -40,21 +41,7 @@ class ATTR_DLL_LOCAL CSession : public adaptive::AdaptiveStreamObserver
4041
/*
4142
* \brief Check HDCP parameters to remove unplayable representations
4243
*/
43-
void CheckHDCP();
44-
45-
/*! \brief Pre-Initialize the DRM
46-
* \param challengeB64 [OUT] Provide the challenge data as base64
47-
* \param sessionId [OUT] Provide the session ID
48-
* \param isSessionOpened [OUT] Will be true if the DRM session has been opened
49-
* \return True if has success, false otherwise
50-
*/
51-
bool PreInitializeDRM(std::string& challengeB64, std::string& sessionId, bool& isSessionOpened);
52-
53-
/*! \brief Initialize the DRM
54-
* \param addDefaultKID Set True to add the default KID to the first session
55-
* \return True if has success, false otherwise
56-
*/
57-
bool InitializeDRM(bool addDefaultKID = false);
44+
//void CheckHDCP();
5845

5946
/*! \brief Initialize adaptive tree period
6047
* \param isSessionOpened Set True to kept and re-use the DRM session opened,
@@ -93,7 +80,7 @@ class ATTR_DLL_LOCAL CSession : public adaptive::AdaptiveStreamObserver
9380
* \brief Update stream's InputstreamInfo
9481
* \param stream The stream to prepare
9582
*/
96-
void PrepareStream(CStream* stream);
83+
bool PrepareStream(CStream* stream, uint64_t startPts);
9784

9885
/*! \brief Get a stream by index (starting at 1)
9986
* \param sid The one-indexed stream id
@@ -115,50 +102,11 @@ class ATTR_DLL_LOCAL CSession : public adaptive::AdaptiveStreamObserver
115102
*/
116103
unsigned int GetStreamCount() const { return static_cast<unsigned int>(m_streams.size()); }
117104

118-
/*!
119-
* \brief Determines if the CDM session at specified index require Secure Path (TEE).
120-
* \return True if Secure Path is required, otherwise false.
121-
*/
122-
bool IsCDMSessionSecurePath(size_t index);
123-
124-
/*! \brief Get a session string (session id) by index from the cdm sessions
125-
* \param index The index (psshSet number) of the cdm session
126-
* \return The session string
127-
*/
128-
std::string GetCDMSession(unsigned int index);
129-
130105
/*! \brief Get the media type mask
131106
* \return The media type mask
132107
*/
133108
uint8_t GetMediaTypeMask() const { return m_mediaTypeMask; }
134109

135-
/*! \brief Get a single sample decrypter by index from the cdm sessions
136-
* \param index The index (psshSet number) of the cdm session
137-
* \return The single sample decrypter
138-
*/
139-
std::shared_ptr<Adaptive_CencSingleSampleDecrypter> GetSingleSampleDecryptor(
140-
unsigned int index) const;
141-
142-
/*! \brief Get the decrypter (DRM lib)
143-
* \return The decrypter
144-
*/
145-
DRM::IDecrypter* GetDecrypter() { return m_decrypter.get(); }
146-
147-
/*! \brief Get a single sample decrypter matching the session id provided
148-
* \param sessionId The session id string to match
149-
* \return The single sample decrypter
150-
*/
151-
std::shared_ptr<Adaptive_CencSingleSampleDecrypter> GetSingleSampleDecrypter(std::string sessionId);
152-
153-
/*! \brief Get decrypter capabilities for a single sample decrypter
154-
* \param index The index (psshSet number) of the cdm session
155-
* \return The single sample decrypter capabilities
156-
*/
157-
const DRM::DecrypterCapabilites& GetDecrypterCaps(unsigned int index) const
158-
{
159-
return m_cdmSessions[index].m_decrypterCaps;
160-
};
161-
162110
/*! \brief Get the total time in ms of the stream
163111
* \return The total time in ms of the stream
164112
*/
@@ -324,13 +272,9 @@ class ATTR_DLL_LOCAL CSession : public adaptive::AdaptiveStreamObserver
324272
*/
325273
bool OnGetStream(int streamid, kodi::addon::InputstreamInfo& info);
326274

327-
protected:
328-
/*! \brief Check for and load decrypter module matching the supplied key system
329-
* \param key_system [OUT] Will be assigned to if a decrypter is found matching
330-
* the set license type
331-
*/
332-
void SetSupportedDecrypterURN(std::vector<std::string_view>& keySystems);
275+
const DRM::CDRMEngine& GetDRMEngine() const { return m_drmEngine; }
333276

277+
protected:
334278
/*! \brief Destroy all CencSingleSampleDecrypter instances
335279
*/
336280
void DisposeSampleDecrypter();
@@ -339,21 +283,8 @@ class ATTR_DLL_LOCAL CSession : public adaptive::AdaptiveStreamObserver
339283
*/
340284
void DisposeDecrypter();
341285

342-
void ExtractStreamProtectionData(const PLAYLIST::CPeriod::PSSHSet& psshSet,
343-
std::string& defaultKid,
344-
std::vector<uint8_t>& initData,
345-
const std::vector<std::string_view>& keySystems);
346-
347286
private:
348-
std::shared_ptr<DRM::IDecrypter> m_decrypter;
349-
350-
struct CCdmSession
351-
{
352-
DRM::DecrypterCapabilites m_decrypterCaps;
353-
std::shared_ptr<Adaptive_CencSingleSampleDecrypter> m_cencSingleSampleDecrypter;
354-
std::string m_sessionId;
355-
};
356-
std::vector<CCdmSession> m_cdmSessions;
287+
DRM::CDRMEngine m_drmEngine;
357288

358289
adaptive::AdaptiveTree* m_adaptiveTree{nullptr};
359290
CHOOSER::IRepresentationChooser* m_reprChooser{nullptr};

src/Stream.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ void CStream::Disable()
2626
Reset();
2727

2828
m_isEnabled = false;
29-
m_isEncrypted = false;
3029
}
3130
}
3231

src/Stream.h

+4-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ class ATTR_DLL_LOCAL CStream
2323
CStream(adaptive::AdaptiveTree* tree,
2424
PLAYLIST::CAdaptationSet* adp,
2525
PLAYLIST::CRepresentation* initialRepr)
26-
: m_isEnabled{false},
27-
m_isEncrypted{false},
28-
m_mainId{0},
29-
m_adStream{tree, adp, initialRepr},
30-
m_isValid{true} {};
31-
26+
: m_isEnabled{false}, m_mainId{0}, m_adStream{tree, adp, initialRepr}, m_isValid{true}
27+
{
28+
}
3229

33-
~CStream() { Disable(); };
30+
~CStream() { Disable(); }
3431

3532
/*!
3633
* \brief Stop/disable the AdaptiveStream and reset
@@ -82,7 +79,6 @@ class ATTR_DLL_LOCAL CStream
8279
}
8380

8481
bool m_isEnabled;
85-
bool m_isEncrypted;
8682
uint16_t m_mainId;
8783
adaptive::AdaptiveStream m_adStream;
8884
kodi::addon::InputstreamInfo m_info;

src/common/AdaptiveDecrypter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ class Adaptive_CencSingleSampleDecrypter : public AP4_CencSingleSampleDecrypter
5555

5656
virtual AP4_UI32 AddPool() { return 0; }
5757
virtual void RemovePool(AP4_UI32 poolId) {}
58-
virtual std::string GetSessionId() { return {}; }
58+
virtual std::string GetSessionId() = 0;
5959
};

src/common/AdaptiveTree.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ namespace adaptive
4040
m_manifestParams = left.m_manifestParams;
4141
m_manifestHeaders = left.m_manifestHeaders;
4242
m_settings = left.m_settings;
43-
m_supportedKeySystems = left.m_supportedKeySystems;
4443
m_pathSaveManifest = left.m_pathSaveManifest;
4544
stream_start_ = left.stream_start_;
4645

@@ -49,11 +48,9 @@ namespace adaptive
4948
}
5049

5150
void AdaptiveTree::Configure(CHOOSER::IRepresentationChooser* reprChooser,
52-
std::vector<std::string_view> supportedKeySystems,
5351
std::string_view manifestUpdParams)
5452
{
5553
m_reprChooser = reprChooser;
56-
m_supportedKeySystems = supportedKeySystems;
5754

5855
auto srvBroker = CSrvBroker::GetInstance();
5956

src/common/AdaptiveTree.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ATTR_DLL_LOCAL AdaptiveTree
7373
uint64_t available_time_{0}; // in ms
7474
uint64_t m_liveDelay{0}; // Apply a delay in seconds from the live edge
7575

76-
std::vector<std::string_view> m_supportedKeySystems;
76+
std::vector<std::string_view> m_supportedKeySystems; // REMOVE ME
7777
std::string location_;
7878

7979
CryptoMode m_cryptoMode{CryptoMode::NONE};
@@ -86,11 +86,10 @@ class ATTR_DLL_LOCAL AdaptiveTree
8686

8787
/*!
8888
* \brief Configure the adaptive tree.
89-
* \param kodiProps The Kodi properties
89+
* \param reprChooser The representation chooser
9090
* \param manifestUpdParams Parameters to be add to manifest request url, depends on manifest implementation
9191
*/
9292
virtual void Configure(CHOOSER::IRepresentationChooser* reprChooser,
93-
std::vector<std::string_view> supportedKeySystems,
9493
std::string_view manifestUpdParams);
9594

9695
/*

src/common/Representation.h

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "SegmentBase.h"
1616
#include "SegTemplate.h"
1717
#include "SegmentList.h"
18+
#include "decrypters/DrmEngineDefines.h"
1819

1920
#ifdef INPUTSTREAM_TEST_BUILD
2021
#include "test/KodiStubs.h"
@@ -158,6 +159,9 @@ class ATTR_DLL_LOCAL CRepresentation : public CCommonSegAttribs, public CCommonA
158159
bool IsIncludedStream() const { return m_isIncludedStream; }
159160
void SetIsIncludedStream(bool isIncludedStream) { m_isIncludedStream = isIncludedStream; }
160161

162+
std::vector<DRM::DRMInfo>& DrmInfos() { return m_drmInfo; }
163+
void AddDrmInfo(DRM::DRMInfo drmInfo) { m_drmInfo.emplace_back(drmInfo); }
164+
161165
void CopyHLSData(const CRepresentation* other);
162166

163167
static bool CompareBandwidth(std::unique_ptr<CRepresentation>& left,
@@ -239,6 +243,7 @@ class ATTR_DLL_LOCAL CRepresentation : public CCommonSegAttribs, public CCommonA
239243
bool m_isWaitForSegment{false};
240244

241245
bool m_isIncludedStream{false};
246+
std::vector<DRM::DRMInfo> m_drmInfo;
242247
};
243248

244249
} // namespace PLAYLIST

src/decrypters/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
set(SOURCES
2+
DrmEngine.cpp
23
DrmFactory.cpp
34
Helpers.cpp
45
HelperPr.cpp
56
HelperWv.cpp
67
)
78

89
set(HEADERS
10+
DrmEngine.h
11+
DrmEngineDefines.h
912
DrmFactory.h
1013
Helpers.h
1114
HelperPr.h

0 commit comments

Comments
 (0)