@@ -293,6 +293,45 @@ namespace Plugin {
293
293
using State
294
294
= Exchange::IContentProtection::INotification::Status::State;
295
295
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
+
296
335
private:
297
336
class Implementation : public Exchange ::IContentProtection {
298
337
public:
@@ -361,7 +400,13 @@ namespace Plugin {
361
400
OpenSessionTimeout, _T (" openPlaybackSession" ), out, in);
362
401
if (result == Core::ERROR_NONE) {
363
402
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;
365
410
} else {
366
411
sessionId = in[" sessionId" ].Number ();
367
412
string inStr;
@@ -380,7 +425,7 @@ namespace Plugin {
380
425
{
381
426
auto session = _parent._sessionStorage .Get (sessionId);
382
427
if (!session.IsSet ()) {
383
- return Core::ERROR_ILLEGAL_STATE; // No such session
428
+ return NoSuchSession;
384
429
}
385
430
386
431
uint32_t result;
@@ -406,7 +451,7 @@ namespace Plugin {
406
451
{
407
452
auto session = _parent._sessionStorage .Get (sessionId);
408
453
if (!session.IsSet ()) {
409
- return Core::ERROR_ILLEGAL_STATE; // No such session
454
+ return NoSuchSession;
410
455
}
411
456
412
457
uint32_t result;
@@ -426,7 +471,13 @@ namespace Plugin {
426
471
OpenSessionTimeout, _T (" updatePlaybackSession" ), out, in);
427
472
if (result == Core::ERROR_NONE) {
428
473
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;
430
481
} else {
431
482
string inStr;
432
483
in.ToString (inStr);
@@ -441,7 +492,7 @@ namespace Plugin {
441
492
{
442
493
auto session = _parent._sessionStorage .Get (sessionId);
443
494
if (!session.IsSet ()) {
444
- return Core::ERROR_ILLEGAL_STATE; // No such session
495
+ return NoSuchSession;
445
496
}
446
497
447
498
uint32_t result;
@@ -453,7 +504,13 @@ namespace Plugin {
453
504
ClosePlaybackSessionParams, JsonObject>(
454
505
Timeout, _T (" closePlaybackSession" ), out, in);
455
506
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;
457
514
}
458
515
return result;
459
516
}
@@ -742,7 +799,7 @@ namespace Plugin {
742
799
WatermarkStatusChanged (
743
800
watermark.Value ().SessionId ,
744
801
session.Value ().AppId ,
745
- { State::FAILED, 20001 });
802
+ { State::FAILED, WatermarkRenderFailed });
746
803
}
747
804
})
748
805
== Core::ERROR_NONE);
0 commit comments