Skip to content

Commit 100ecf2

Browse files
Microsoft Playready support for Amazon Prime RDK app (#449)
Summary: Microsoft Playready support for Amazon Prime RDK app Type: Feature Test Plan: UT/CT, Fullstack Jira: NO-JIRA
1 parent ef0589a commit 100ecf2

59 files changed

Lines changed: 655 additions & 417 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

media/client/ipc/include/MediaKeysIpc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ class MediaKeysIpc : public IMediaKeys, public IpcModule
6969

7070
bool containsKey(int32_t keySessionId, const std::vector<uint8_t> &keyId) override;
7171

72-
MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client, bool isLDL,
72+
MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
7373
int32_t &keySessionId) override;
7474

7575
MediaKeyErrorStatus generateRequest(int32_t keySessionId, InitDataType initDataType,
76-
const std::vector<uint8_t> &initData) override;
76+
const std::vector<uint8_t> &initData,
77+
const LimitedDurationLicense &ldlState) override;
7778

7879
MediaKeyErrorStatus loadSession(int32_t keySessionId) override;
7980

media/client/ipc/source/MediaKeysIpc.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ bool MediaKeysIpc::containsKey(int32_t keySessionId, const std::vector<uint8_t>
334334
}
335335

336336
MediaKeyErrorStatus MediaKeysIpc::createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
337-
bool isLDL, int32_t &keySessionId)
337+
int32_t &keySessionId)
338338
{
339339
if (!reattachChannelIfRequired())
340340
{
@@ -362,7 +362,6 @@ MediaKeyErrorStatus MediaKeysIpc::createKeySession(KeySessionType sessionType, s
362362
firebolt::rialto::CreateKeySessionRequest request;
363363
request.set_media_keys_handle(m_mediaKeysHandle);
364364
request.set_session_type(protoSessionType);
365-
request.set_is_ldl(isLDL);
366365

367366
firebolt::rialto::CreateKeySessionResponse response;
368367
// Default error status to FAIL
@@ -387,7 +386,8 @@ MediaKeyErrorStatus MediaKeysIpc::createKeySession(KeySessionType sessionType, s
387386
}
388387

389388
MediaKeyErrorStatus MediaKeysIpc::generateRequest(int32_t keySessionId, InitDataType initDataType,
390-
const std::vector<uint8_t> &initData)
389+
const std::vector<uint8_t> &initData,
390+
const LimitedDurationLicense &ldlState)
391391
{
392392
if (!reattachChannelIfRequired())
393393
{
@@ -415,10 +415,29 @@ MediaKeyErrorStatus MediaKeysIpc::generateRequest(int32_t keySessionId, InitData
415415
break;
416416
}
417417

418+
GenerateRequestRequest_LimitedDurationLicense protoLimitedDurationLicense{
419+
GenerateRequestRequest_LimitedDurationLicense_NOT_SPECIFIED};
420+
switch (ldlState)
421+
{
422+
case LimitedDurationLicense::NOT_SPECIFIED:
423+
protoLimitedDurationLicense = GenerateRequestRequest_LimitedDurationLicense_NOT_SPECIFIED;
424+
break;
425+
case LimitedDurationLicense::ENABLED:
426+
protoLimitedDurationLicense = GenerateRequestRequest_LimitedDurationLicense_ENABLED;
427+
break;
428+
case LimitedDurationLicense::DISABLED:
429+
protoLimitedDurationLicense = GenerateRequestRequest_LimitedDurationLicense_DISABLED;
430+
break;
431+
default:
432+
RIALTO_CLIENT_LOG_WARN("Received unknown limited duration license state");
433+
break;
434+
}
435+
418436
firebolt::rialto::GenerateRequestRequest request;
419437
request.set_media_keys_handle(m_mediaKeysHandle);
420438
request.set_key_session_id(keySessionId);
421439
request.set_init_data_type(protoInitDataType);
440+
request.set_ldl_state(protoLimitedDurationLicense);
422441

423442
for (auto it = initData.begin(); it != initData.end(); it++)
424443
{

media/client/main/include/MediaKeys.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ class MediaKeys : public IMediaKeys
7979

8080
bool containsKey(int32_t keySessionId, const std::vector<uint8_t> &keyId) override;
8181

82-
MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client, bool isLDL,
82+
MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
8383
int32_t &keySessionId) override;
8484

8585
MediaKeyErrorStatus generateRequest(int32_t keySessionId, InitDataType initDataType,
86-
const std::vector<uint8_t> &initData) override;
86+
const std::vector<uint8_t> &initData,
87+
const LimitedDurationLicense &ldlState) override;
8788

8889
MediaKeyErrorStatus loadSession(int32_t keySessionId) override;
8990

media/client/main/source/MediaKeys.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ bool MediaKeys::containsKey(int32_t keySessionId, const std::vector<uint8_t> &ke
115115
}
116116

117117
MediaKeyErrorStatus MediaKeys::createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
118-
bool isLDL, int32_t &keySessionId)
118+
int32_t &keySessionId)
119119
{
120120
RIALTO_CLIENT_LOG_DEBUG("entry:");
121121

122-
auto result{m_mediaKeysIpc->createKeySession(sessionType, client, isLDL, keySessionId)};
122+
auto result{m_mediaKeysIpc->createKeySession(sessionType, client, keySessionId)};
123123
if (isNetflixPlayready(m_keySystem) && MediaKeyErrorStatus::OK == result)
124124
{
125125
KeyIdMap::instance().addSession(keySessionId);
@@ -128,11 +128,12 @@ MediaKeyErrorStatus MediaKeys::createKeySession(KeySessionType sessionType, std:
128128
}
129129

130130
MediaKeyErrorStatus MediaKeys::generateRequest(int32_t keySessionId, InitDataType initDataType,
131-
const std::vector<uint8_t> &initData)
131+
const std::vector<uint8_t> &initData,
132+
const LimitedDurationLicense &ldlState)
132133
{
133134
RIALTO_CLIENT_LOG_DEBUG("entry:");
134135

135-
return m_mediaKeysIpc->generateRequest(keySessionId, initDataType, initData);
136+
return m_mediaKeysIpc->generateRequest(keySessionId, initDataType, initData, ldlState);
136137
}
137138

138139
MediaKeyErrorStatus MediaKeys::loadSession(int32_t keySessionId)

media/public/include/IMediaKeys.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,12 @@ class IMediaKeys
110110
*
111111
* @param[in] sessionType : The session type.
112112
* @param[in] client : Client object for callbacks
113-
* @param[in] isLDL : Is this an LDL
114113
* @param[out] keySessionId: The key session id
115114
*
116115
* @retval an error status.
117116
*/
118117
virtual MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
119-
bool isLDL, int32_t &keySessionId) = 0;
118+
int32_t &keySessionId) = 0;
120119

121120
/**
122121
* @brief Generates a licence request.
@@ -130,11 +129,14 @@ class IMediaKeys
130129
* @param[in] keySessionId : The key session id for the session.
131130
* @param[in] initDataType : The init data type.
132131
* @param[in] initData : The init data.
132+
* @param[in] ldlState : The Limited Duration License state. Most of key systems do not need this parameter,
133+
* so the default value is NOT_SPECIFIED.
133134
*
134135
* @retval an error status.
135136
*/
136-
virtual MediaKeyErrorStatus generateRequest(int32_t keySessionId, InitDataType initDataType,
137-
const std::vector<uint8_t> &initData) = 0;
137+
virtual MediaKeyErrorStatus
138+
generateRequest(int32_t keySessionId, InitDataType initDataType, const std::vector<uint8_t> &initData,
139+
const LimitedDurationLicense &ldlState = LimitedDurationLicense::NOT_SPECIFIED) = 0;
138140

139141
/**
140142
* @brief Loads an existing key session

media/public/include/MediaCommon.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,16 @@ struct PlaybackInfo
473473
int64_t currentPosition{-1}; /**< The current playback position */
474474
double volume{1.0}; /**< The current volume */
475475
};
476+
477+
/**
478+
* @brief Limited duration license state.
479+
*/
480+
enum class LimitedDurationLicense
481+
{
482+
NOT_SPECIFIED, /**< The license duration is not specified */
483+
ENABLED, /**< The license has a limited duration */
484+
DISABLED /**< The license does not have a limited duration */
485+
};
476486
} // namespace firebolt::rialto
477487

478488
#endif // FIREBOLT_RIALTO_MEDIA_COMMON_H_

media/server/gstplayer/source/GstDecryptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ GstFlowReturn GstRialtoDecryptorPrivate::decrypt(GstBuffer *buffer, GstCaps *cap
280280
}
281281
}
282282

283-
if (protectionData->key && m_decryptionService->isNetflixPlayreadyKeySystem(protectionData->keySessionId))
283+
if (protectionData->key && m_decryptionService->isExtendedInterfaceUsed(protectionData->keySessionId))
284284
{
285285
GstMapInfo keyMap;
286286
if (m_gstWrapper->gstBufferMap(protectionData->key, &keyMap, GST_MAP_READ))

media/server/ipc/source/MediaKeysModuleService.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ firebolt::rialto::InitDataType covertInitDataType(firebolt::rialto::GenerateRequ
100100
return firebolt::rialto::InitDataType::UNKNOWN;
101101
}
102102
}
103+
104+
firebolt::rialto::LimitedDurationLicense
105+
covertLimitedDurationLicense(firebolt::rialto::GenerateRequestRequest_LimitedDurationLicense protoLimitedDurationLicense)
106+
{
107+
switch (protoLimitedDurationLicense)
108+
{
109+
case firebolt::rialto::GenerateRequestRequest_LimitedDurationLicense::GenerateRequestRequest_LimitedDurationLicense_NOT_SPECIFIED:
110+
return firebolt::rialto::LimitedDurationLicense::NOT_SPECIFIED;
111+
case firebolt::rialto::GenerateRequestRequest_LimitedDurationLicense::GenerateRequestRequest_LimitedDurationLicense_ENABLED:
112+
return firebolt::rialto::LimitedDurationLicense::ENABLED;
113+
case firebolt::rialto::GenerateRequestRequest_LimitedDurationLicense::GenerateRequestRequest_LimitedDurationLicense_DISABLED:
114+
return firebolt::rialto::LimitedDurationLicense::DISABLED;
115+
default:
116+
return firebolt::rialto::LimitedDurationLicense::NOT_SPECIFIED;
117+
}
118+
}
103119
} // namespace
104120

105121
namespace firebolt::rialto::server::ipc
@@ -262,7 +278,7 @@ void MediaKeysModuleService::createKeySession(::google::protobuf::RpcController
262278
m_cdmService.createKeySession(request->media_keys_handle(), convertKeySessionType(request->session_type()),
263279
std::make_shared<MediaKeysClient>(request->media_keys_handle(),
264280
ipcController->getClient()),
265-
request->is_ldl(), keySessionId);
281+
keySessionId);
266282
if (MediaKeyErrorStatus::OK == status)
267283
{
268284
response->set_key_session_id(keySessionId);
@@ -278,10 +294,11 @@ void MediaKeysModuleService::generateRequest(::google::protobuf::RpcController *
278294
{
279295
RIALTO_SERVER_LOG_DEBUG("entry:");
280296

281-
MediaKeyErrorStatus status = m_cdmService.generateRequest(request->media_keys_handle(), request->key_session_id(),
282-
covertInitDataType(request->init_data_type()),
283-
std::vector<std::uint8_t>{request->init_data().begin(),
284-
request->init_data().end()});
297+
MediaKeyErrorStatus status =
298+
m_cdmService.generateRequest(request->media_keys_handle(), request->key_session_id(),
299+
covertInitDataType(request->init_data_type()),
300+
std::vector<std::uint8_t>{request->init_data().begin(), request->init_data().end()},
301+
covertLimitedDurationLicense(request->ldl_state()));
285302
response->set_error_status(convertMediaKeyErrorStatus(status));
286303
done->Run();
287304
}

media/server/main/include/IMediaKeySession.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ class IMediaKeySessionFactory
5555
* @param[in] ocdmSystem : The ocdm system object to create the session on.
5656
* @param[in] sessionType : The session type.
5757
* @param[in] client : Client object for callbacks.
58-
* @param[in] isLDL : Is this an LDL.
5958
*
6059
* @retval the new media keys instance or null on error.
6160
*/
6261
virtual std::unique_ptr<IMediaKeySession>
6362
createMediaKeySession(const std::string &keySystem, int32_t keySessionId,
6463
const firebolt::rialto::wrappers::IOcdmSystem &ocdmSystem, KeySessionType sessionType,
65-
std::weak_ptr<IMediaKeysClient> client, bool isLDL) const = 0;
64+
std::weak_ptr<IMediaKeysClient> client) const = 0;
6665
};
6766

6867
/**
@@ -84,11 +83,12 @@ class IMediaKeySession
8483
*
8584
* @param[in] initDataType : The init data type.
8685
* @param[in] initData : The init data.
86+
* @param[in] ldlState : The Limited Duration License state. Most of key systems do not need this parameter.
8787
*
8888
* @retval an error status.
8989
*/
90-
virtual MediaKeyErrorStatus generateRequest(InitDataType initDataType, const std::vector<uint8_t> &initData) = 0;
91-
90+
virtual MediaKeyErrorStatus generateRequest(InitDataType initDataType, const std::vector<uint8_t> &initData,
91+
const LimitedDurationLicense &ldlState) = 0;
9292
/**
9393
* @brief Loads the existing key session.
9494
*
@@ -179,13 +179,6 @@ class IMediaKeySession
179179
* @retval an error status.
180180
*/
181181
virtual MediaKeyErrorStatus selectKeyId(const std::vector<uint8_t> &keyId) = 0;
182-
183-
/**
184-
* @brief Checks, if key system of media key session is Netflix playready.
185-
*
186-
* @retval true if key system is Netflix playready
187-
*/
188-
virtual bool isNetflixPlayreadyKeySystem() const = 0;
189182
};
190183
} // namespace firebolt::rialto::server
191184

media/server/main/include/MediaKeySession.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class MediaKeySessionFactory : public IMediaKeySessionFactory
4343
std::unique_ptr<IMediaKeySession> createMediaKeySession(const std::string &keySystem, int32_t keySessionId,
4444
const firebolt::rialto::wrappers::IOcdmSystem &ocdmSystem,
4545
KeySessionType sessionType,
46-
std::weak_ptr<IMediaKeysClient> client,
47-
bool isLDL) const override;
46+
std::weak_ptr<IMediaKeysClient> client) const override;
4847
};
4948

5049
/**
@@ -61,20 +60,19 @@ class MediaKeySession : public IMediaKeySession, public firebolt::rialto::wrappe
6160
* @param[in] ocdmSystem : The ocdm system object to create the session on.
6261
* @param[in] sessionType : The session type.
6362
* @param[in] client : Client object for callbacks.
64-
* @param[in] isLDL : Is this an LDL.
6563
* @param[in] mainThreadFactory : The main thread factory.
6664
*/
6765
MediaKeySession(const std::string &keySystem, int32_t keySessionId,
6866
const firebolt::rialto::wrappers::IOcdmSystem &ocdmSystem, KeySessionType sessionType,
69-
std::weak_ptr<IMediaKeysClient> client, bool isLDL,
70-
const std::shared_ptr<IMainThreadFactory> &mainThreadFactory);
67+
std::weak_ptr<IMediaKeysClient> client, const std::shared_ptr<IMainThreadFactory> &mainThreadFactory);
7168

7269
/**
7370
* @brief Virtual destructor.
7471
*/
7572
virtual ~MediaKeySession();
7673

77-
MediaKeyErrorStatus generateRequest(InitDataType initDataType, const std::vector<uint8_t> &initData) override;
74+
MediaKeyErrorStatus generateRequest(InitDataType initDataType, const std::vector<uint8_t> &initData,
75+
const LimitedDurationLicense &ldlState) override;
7876

7977
MediaKeyErrorStatus loadSession() override;
8078

@@ -96,8 +94,6 @@ class MediaKeySession : public IMediaKeySession, public firebolt::rialto::wrappe
9694

9795
MediaKeyErrorStatus selectKeyId(const std::vector<uint8_t> &keyId) override;
9896

99-
bool isNetflixPlayreadyKeySystem() const override;
100-
10197
void onProcessChallenge(const char url[], const uint8_t challenge[], const uint16_t challengeLength) override;
10298

10399
void onKeyUpdated(const uint8_t keyId[], const uint8_t keyIdLength) override;
@@ -137,11 +133,6 @@ class MediaKeySession : public IMediaKeySession, public firebolt::rialto::wrappe
137133
*/
138134
std::shared_ptr<IMainThread> m_mainThread;
139135

140-
/**
141-
* @brief Is the session LDL.
142-
*/
143-
const bool m_kIsLDL;
144-
145136
/**
146137
* @brief Is the ocdm session constructed.
147138
*/
@@ -187,12 +178,24 @@ class MediaKeySession : public IMediaKeySession, public firebolt::rialto::wrappe
187178
*/
188179
std::mutex m_ocdmErrorMutex;
189180

181+
/**
182+
* @brief Drm header to be set once the session is constructed
183+
*/
184+
std::vector<uint8_t> m_queuedDrmHeader;
185+
186+
/**
187+
* @brief Flag used to check if extended interface is used
188+
*/
189+
bool m_extendedInterfaceInUse{false};
190+
190191
/**
191192
* @brief Posts a getChallenge task onto the main thread.
192193
*
194+
* @param[in] ldlState : The Limited Duration License state.
195+
*
193196
* The challenge data is retrieved from ocdm and notified on a onLicenseRequest.
194197
*/
195-
void getChallenge();
198+
void getChallenge(const LimitedDurationLicense &ldlState);
196199

197200
/**
198201
* @brief Initalises the ocdm error data which checks for onError callbacks.

0 commit comments

Comments
 (0)