@@ -293,6 +293,45 @@ namespace Plugin {
293293 using State
294294 = Exchange::IContentProtection::INotification::Status::State;
295295
296+ private:
297+ enum { NoSuchSession = 21009 };
298+ enum { WatermarkRenderFailed = 20001 };
299+
300+ static Core::OptionalType<uint32_t > SecManagerStatus (
301+ uint16_t classification, uint16_t reason)
302+ {
303+ Core::OptionalType<uint32_t > result;
304+ // https://github.com/comcast-contentsecurity/spec
305+ static std::map<std::tuple<uint16_t , uint16_t >, uint32_t > map{
306+ { { 100 , 3 }, 21003 },
307+ { { 100 , 4 }, 21004 },
308+ { { 100 , 5 }, 21005 },
309+ { { 100 , 6 }, 21006 },
310+ { { 100 , 7 }, 21007 },
311+ { { 100 , 8 }, 21008 },
312+ { { 100 , 9 }, NoSuchSession },
313+ { { 100 , 12 }, 21012 },
314+ { { 100 , 14 }, 21014 },
315+ { { 100 , 15 }, 21015 },
316+ { { 200 , 1 }, 22001 },
317+ { { 200 , 3 }, 22003 },
318+ { { 200 , 4 }, 22004 },
319+ { { 200 , 8 }, 22008 },
320+ { { 200 , 11 }, 22011 },
321+ { { 200 , 12 }, 22012 },
322+ { { 200 , 13 }, 22013 },
323+ { { 200 , 16 }, 22016 },
324+ { { 300 , 1 }, 23001 },
325+ { { 300 , 3 }, 23003 },
326+ { { 300 , 12 }, 23012 }
327+ };
328+ auto it = map.find (std::make_tuple (classification, reason));
329+ if (it != map.end ()) {
330+ result = it->second ;
331+ }
332+ return result;
333+ }
334+
296335 private:
297336 class Implementation : public Exchange ::IContentProtection {
298337 public:
@@ -361,7 +400,13 @@ namespace Plugin {
361400 OpenSessionTimeout, _T (" openPlaybackSession" ), out, in);
362401 if (result == Core::ERROR_NONE) {
363402 if (!in[" success" ].Boolean ()) {
364- result = Core::ERROR_GENERAL;
403+ auto context = in[" secManagerResultContext" ].Object ();
404+ auto status = SecManagerStatus (
405+ context[" class" ].Number (),
406+ context[" reason" ].Number ());
407+ result = status.IsSet ()
408+ ? status.Value ()
409+ : Core::ERROR_GENERAL;
365410 } else {
366411 sessionId = in[" sessionId" ].Number ();
367412 string inStr;
@@ -380,7 +425,7 @@ namespace Plugin {
380425 {
381426 auto session = _parent._sessionStorage .Get (sessionId);
382427 if (!session.IsSet ()) {
383- return Core::ERROR_ILLEGAL_STATE; // No such session
428+ return NoSuchSession;
384429 }
385430
386431 uint32_t result;
@@ -406,7 +451,7 @@ namespace Plugin {
406451 {
407452 auto session = _parent._sessionStorage .Get (sessionId);
408453 if (!session.IsSet ()) {
409- return Core::ERROR_ILLEGAL_STATE; // No such session
454+ return NoSuchSession;
410455 }
411456
412457 uint32_t result;
@@ -426,7 +471,13 @@ namespace Plugin {
426471 OpenSessionTimeout, _T (" updatePlaybackSession" ), out, in);
427472 if (result == Core::ERROR_NONE) {
428473 if (!in[" success" ].Boolean ()) {
429- result = Core::ERROR_GENERAL;
474+ auto context = in[" secManagerResultContext" ].Object ();
475+ auto status = SecManagerStatus (
476+ context[" class" ].Number (),
477+ context[" reason" ].Number ());
478+ result = status.IsSet ()
479+ ? status.Value ()
480+ : Core::ERROR_GENERAL;
430481 } else {
431482 string inStr;
432483 in.ToString (inStr);
@@ -441,7 +492,7 @@ namespace Plugin {
441492 {
442493 auto session = _parent._sessionStorage .Get (sessionId);
443494 if (!session.IsSet ()) {
444- return Core::ERROR_ILLEGAL_STATE; // No such session
495+ return NoSuchSession;
445496 }
446497
447498 uint32_t result;
@@ -453,7 +504,13 @@ namespace Plugin {
453504 ClosePlaybackSessionParams, JsonObject>(
454505 Timeout, _T (" closePlaybackSession" ), out, in);
455506 if ((result == Core::ERROR_NONE) && !in[" success" ].Boolean ()) {
456- result = Core::ERROR_GENERAL;
507+ auto context = in[" secManagerResultContext" ].Object ();
508+ auto status = SecManagerStatus (
509+ context[" class" ].Number (),
510+ context[" reason" ].Number ());
511+ result = status.IsSet ()
512+ ? status.Value ()
513+ : Core::ERROR_GENERAL;
457514 }
458515 return result;
459516 }
@@ -742,7 +799,7 @@ namespace Plugin {
742799 WatermarkStatusChanged (
743800 watermark.Value ().SessionId ,
744801 session.Value ().AppId ,
745- { State::FAILED, 20001 });
802+ { State::FAILED, WatermarkRenderFailed });
746803 }
747804 })
748805 == Core::ERROR_NONE);
0 commit comments