Skip to content

DELIA-68254 : handling errors for content protection service #6291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
DELIA-68254 : handling errors for content protection service
Reason for change: CPS shall map SecManager errors
to one of the CPS plug-in error codes.
Test Procedure: None
Risks: None
Signed-off-by: Nikita Poltorapavlo <[email protected]>
  • Loading branch information
npoltorapavlo committed Jun 18, 2025
commit 50871ae995728cfe118c50f9e962275a9837e053
71 changes: 64 additions & 7 deletions ContentProtection/ContentProtection.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,45 @@ namespace Plugin {
using State
= Exchange::IContentProtection::INotification::Status::State;

private:
enum { NoSuchSession = 21009 };
enum { WatermarkRenderFailed = 20001 };

static Core::OptionalType<uint32_t> SecManagerStatus(
uint16_t classification, uint16_t reason)
{
Core::OptionalType<uint32_t> result;
// https://github.com/comcast-contentsecurity/spec
static std::map<std::tuple<uint16_t, uint16_t>, uint32_t> map{
{ { 100, 3 }, 21003 },
{ { 100, 4 }, 21004 },
{ { 100, 5 }, 21005 },
{ { 100, 6 }, 21006 },
{ { 100, 7 }, 21007 },
{ { 100, 8 }, 21008 },
{ { 100, 9 }, NoSuchSession },
{ { 100, 12 }, 21012 },
{ { 100, 14 }, 21014 },
{ { 100, 15 }, 21015 },
{ { 200, 1 }, 22001 },
{ { 200, 3 }, 22003 },
{ { 200, 4 }, 22004 },
{ { 200, 8 }, 22008 },
{ { 200, 11 }, 22011 },
{ { 200, 12 }, 22012 },
{ { 200, 13 }, 22013 },
{ { 200, 16 }, 22016 },
{ { 300, 1 }, 23001 },
{ { 300, 3 }, 23003 },
{ { 300, 12 }, 23012 }
};
auto it = map.find(std::make_tuple(classification, reason));
if (it != map.end()) {
result = it->second;
}
return result;
}

private:
class Implementation : public Exchange::IContentProtection {
public:
Expand Down Expand Up @@ -359,7 +398,13 @@ namespace Plugin {
OpenSessionTimeout, _T("openPlaybackSession"), out, in);
if (result == Core::ERROR_NONE) {
if (!in["success"].Boolean()) {
result = Core::ERROR_GENERAL;
auto context = in["secManagerResultContext"].Object();
auto status = SecManagerStatus(
context["class"].Number(),
context["reason"].Number());
result = status.IsSet()
? status.Value()
: Core::ERROR_GENERAL;
} else {
sessionId = in["sessionId"].Number();
in.ToString(response);
Expand All @@ -376,7 +421,7 @@ namespace Plugin {
{
auto session = _parent._sessionStorage.Get(sessionId);
if (!session.IsSet()) {
return Core::ERROR_ILLEGAL_STATE; // No such session
return NoSuchSession;
}

uint32_t result;
Expand All @@ -402,7 +447,7 @@ namespace Plugin {
{
auto session = _parent._sessionStorage.Get(sessionId);
if (!session.IsSet()) {
return Core::ERROR_ILLEGAL_STATE; // No such session
return NoSuchSession;
}

uint32_t result;
Expand All @@ -420,7 +465,13 @@ namespace Plugin {
OpenSessionTimeout, _T("updatePlaybackSession"), out, in);
if (result == Core::ERROR_NONE) {
if (!in["success"].Boolean()) {
result = Core::ERROR_GENERAL;
auto context = in["secManagerResultContext"].Object();
auto status = SecManagerStatus(
context["class"].Number(),
context["reason"].Number());
result = status.IsSet()
? status.Value()
: Core::ERROR_GENERAL;
} else {
in.ToString(response);
}
Expand All @@ -433,7 +484,7 @@ namespace Plugin {
{
auto session = _parent._sessionStorage.Get(sessionId);
if (!session.IsSet()) {
return Core::ERROR_ILLEGAL_STATE; // No such session
return NoSuchSession;
}

uint32_t result;
Expand All @@ -445,7 +496,13 @@ namespace Plugin {
ClosePlaybackSessionParams, JsonObject>(
Timeout, _T("closePlaybackSession"), out, in);
if ((result == Core::ERROR_NONE) && !in["success"].Boolean()) {
result = Core::ERROR_GENERAL;
auto context = in["secManagerResultContext"].Object();
auto status = SecManagerStatus(
context["class"].Number(),
context["reason"].Number());
result = status.IsSet()
? status.Value()
: Core::ERROR_GENERAL;
}
return result;
}
Expand Down Expand Up @@ -734,7 +791,7 @@ namespace Plugin {
WatermarkStatusChanged(
watermark.Value().SessionId,
session.Value().AppId,
{ State::FAILED, 20001 });
{ State::FAILED, WatermarkRenderFailed });
}
})
== Core::ERROR_NONE);
Expand Down
Loading