Skip to content

Commit f193c82

Browse files
committed
Enhance license error handling
1 parent c011119 commit f193c82

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

packages/video_player_avplay/tizen/src/drm_manager.cc

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,14 @@ bool DrmManager::ProcessLicense(DataForLicenseProcess &data) {
248248
static_cast<DrmLicenseHelper::DrmType>(drm_type_), nullptr, nullptr);
249249
if (DRM_SUCCESS != ret || nullptr == response_data || 0 == response_len) {
250250
LOG_ERROR("[DrmManager] Fail to get respone by license server url.");
251-
SendInstallKeyError();
251+
SendInstallKeyError("Fail to get respone by license server url.");
252252
return false;
253253
}
254254
LOG_INFO("[DrmManager] Response length : %lu", response_len);
255-
if (!InstallKey(const_cast<void *>(reinterpret_cast<const void *>(
256-
data.session_id.c_str())),
257-
static_cast<void *>(response_data),
258-
reinterpret_cast<void *>(response_len))) {
259-
SendInstallKeyError();
260-
}
255+
InstallKey(const_cast<void *>(
256+
reinterpret_cast<const void *>(data.session_id.c_str())),
257+
static_cast<void *>(response_data),
258+
reinterpret_cast<void *>(response_len));
261259
free(response_data);
262260
} else if (request_license_channel_) {
263261
// Get license via the Dart callback.
@@ -268,7 +266,7 @@ bool DrmManager::ProcessLicense(DataForLicenseProcess &data) {
268266
return false;
269267
}
270268

271-
bool DrmManager::InstallKey(void *session_id, void *response_data,
269+
void DrmManager::InstallKey(void *session_id, void *response_data,
272270
void *response_len) {
273271
LOG_INFO("[DrmManager] Start install license.");
274272

@@ -281,21 +279,17 @@ bool DrmManager::InstallKey(void *session_id, void *response_data,
281279
if (ret != DM_ERROR_NONE) {
282280
LOG_ERROR("[DrmManager] Fail to install eme key: %s",
283281
get_error_message(ret));
284-
return false;
282+
SendInstallKeyError(get_error_message(ret));
285283
}
286-
return true;
287284
}
288285

289286
void DrmManager::SetErrorCallback(ErrorCallback callback) {
290287
error_callback_ = callback;
291288
}
292289

293-
void DrmManager::SendInstallKeyError() {
290+
void DrmManager::SendInstallKeyError(const std::string &error_message) {
294291
if (error_callback_) {
295292
std::string error_code = "[DrmManager] error";
296-
std::string error_message =
297-
"Error: install drm key failed, please check licenseURL or network "
298-
"connection.";
299293
error_callback_(error_code, error_message);
300294
}
301295
}
@@ -322,16 +316,14 @@ void DrmManager::RequestLicense(std::string &session_id, std::string &message) {
322316
response = std::get<std::vector<uint8_t>>(*success_value);
323317
} else {
324318
LOG_ERROR("[DrmManager] Fail to get response.");
325-
SendInstallKeyError();
319+
SendInstallKeyError("Fail to get response.");
326320
return;
327321
}
328322
LOG_INFO("[DrmManager] Response length : %d", response.size());
329-
if (!InstallKey(const_cast<void *>(reinterpret_cast<const void *>(
330-
session_id.c_str())),
331-
reinterpret_cast<void *>(response.data()),
332-
reinterpret_cast<void *>(response.size()))) {
333-
SendInstallKeyError();
334-
}
323+
InstallKey(const_cast<void *>(
324+
reinterpret_cast<const void *>(session_id.c_str())),
325+
reinterpret_cast<void *>(response.data()),
326+
reinterpret_cast<void *>(response.size()));
335327
},
336328
nullptr, nullptr);
337329
request_license_channel_->InvokeMethod(

packages/video_player_avplay/tizen/src/drm_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class DrmManager {
3737
void StopDrmSession();
3838
void ReleaseDrmSession();
3939
void SetErrorCallback(ErrorCallback callback);
40-
void SendInstallKeyError();
4140

4241
private:
4342
struct DataForLicenseProcess {
@@ -49,8 +48,9 @@ class DrmManager {
4948
};
5049

5150
void RequestLicense(std::string &session_id, std::string &message);
52-
bool InstallKey(void *session_id, void *response_data, void *response_len);
51+
void InstallKey(void *session_id, void *response_data, void *response_len);
5352
int SetChallenge(const std::string &media_url);
53+
void SendInstallKeyError(const std::string &error_message);
5454

5555
static int OnChallengeData(void *session_id, int message_type, void *message,
5656
int message_length, void *user_data);

0 commit comments

Comments
 (0)