Skip to content

Commit 9a429cd

Browse files
RDK-58380 : Avoid implicit cast of Core::JSON objects (rdkcentral#6314)
Reason for change: Call Value() to get the real value. Fix format specifiers. Tidy up yml workflow file. Test Procedure: None Risks: None Signed-off-by: Nikita Poltorapavlo <[email protected]> Co-authored-by: Anand Kandasamy <[email protected]>
1 parent 57c62cb commit 9a429cd

File tree

4 files changed

+86
-80
lines changed

4 files changed

+86
-80
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: ContentProtection
2+
3+
on:
4+
push:
5+
paths:
6+
- ContentProtection/**
7+
- .github/workflows/*ContentProtection*.yml
8+
pull_request:
9+
paths:
10+
- ContentProtection/**
11+
- .github/workflows/*ContentProtection*.yml
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
include:
19+
- src: 'ContentProtection'
20+
build: 'build/ContentProtection'
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
path: ${{github.repository}}
25+
- run: |
26+
sudo apt update
27+
sudo apt install -y cmake
28+
- run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh
29+
- run: |
30+
cmake \
31+
-S ${GITHUB_REPOSITORY}/${{ matrix.src }} \
32+
-B ${{ matrix.build }} \
33+
-DCMAKE_INSTALL_PREFIX="install" \
34+
-DCMAKE_CXX_FLAGS="-Wall -Werror"
35+
cmake --build ${{ matrix.build }} --target install

.github/workflows/L2-ContentProtection.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

ContentProtection/ContentProtection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Plugin {
6161
token);
6262
if (ret != Core::ERROR_NONE) {
6363
SYSLOG(Logging::Startup,
64-
(_T("Couldn't create token: %d"), ret));
64+
(_T("Couldn't create token: %" PRIu32), ret));
6565
}
6666
security->Release();
6767
}

ContentProtection/ContentProtection.h

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,11 @@ namespace Plugin {
571571
Timeout, _T("onAddWatermark"),
572572
[&](const OnAddWatermarkParams& params) {
573573
_watermarkStorage.Set(
574-
params.GraphicId,
575-
{ params.SessionId,
576-
params.AdjustVisibilityRequired,
577-
params.GraphicImageBufferKey,
578-
params.GraphicImageSize });
574+
params.GraphicId.Value(),
575+
{ params.SessionId.Value(),
576+
params.AdjustVisibilityRequired.Value(),
577+
params.GraphicImageBufferKey.Value(),
578+
params.GraphicImageSize.Value() });
579579

580580
CreateWatermarkParams out;
581581
out.Id = params.GraphicId;
@@ -587,7 +587,8 @@ namespace Plugin {
587587
!= Core::ERROR_NONE)
588588
|| !in["success"].Boolean()) {
589589
TRACE(Trace::Error,
590-
(_T("create %d failed"), params.GraphicId));
590+
(_T("create %" PRIu32 " failed"),
591+
params.GraphicId.Value()));
591592
}
592593
})
593594
== Core::ERROR_NONE);
@@ -603,7 +604,8 @@ namespace Plugin {
603604
!= Core::ERROR_NONE)
604605
|| !in["success"].Boolean()) {
605606
TRACE(Trace::Error,
606-
(_T("delete %d failed"), params.GraphicId));
607+
(_T("delete %" PRIu32 " failed"),
608+
params.GraphicId.Value()));
607609
}
608610
})
609611
== Core::ERROR_NONE);
@@ -612,7 +614,7 @@ namespace Plugin {
612614
[&](const OnDisplayWatermarkParams& params) {
613615
uint32_t result;
614616
ShowWatermarkParams out;
615-
out.Show = !params.HideWatermark;
617+
out.Show = !params.HideWatermark.Value();
616618
JsonObject in;
617619
result = _watermark->Invoke<
618620
ShowWatermarkParams, JsonObject>(
@@ -627,31 +629,33 @@ namespace Plugin {
627629
Timeout, _T("onWatermarkSession"),
628630
[&](const OnWatermarkSessionParams& params) {
629631
auto session = _sessionStorage.Get(
630-
params.SessionId);
632+
params.SessionId.Value());
631633
if (!session.IsSet()) {
632634
return; // No such session
633635
}
636+
auto value = params.ConditionContext.Value();
634637
WatermarkStatusChanged(
635-
params.SessionId,
638+
params.SessionId.Value(),
636639
session.Value().AppId,
637-
{ ((params.ConditionContext == 1)
640+
{ ((value == 1)
638641
? State::GRANTED
639-
: ((params.ConditionContext == 2)
642+
: ((value == 2)
640643
? State::NOT_REQUIRED
641-
: ((params.ConditionContext == 3)
644+
: ((value == 3)
642645
? State::DENIED
643646
: State::FAILED))),
644-
params.ConditionContext });
647+
value });
645648
})
646649
== Core::ERROR_NONE);
647650
ASSERT(_secManager->Subscribe<OnUpdateWatermarkParams>(
648651
Timeout, _T("onUpdateWatermark"),
649652
[&](const OnUpdateWatermarkParams& params) {
650653
auto palette = _palettedImageDataStorage.Get(
651-
params.GraphicId);
654+
params.GraphicId.Value());
652655
if (!palette.IsSet()) {
653656
TRACE(Trace::Error,
654-
(_T("no palette %d"), params.GraphicId));
657+
(_T("no palette %" PRIu32),
658+
params.GraphicId.Value()));
655659
} else {
656660
PaletteWatermarkParams out;
657661
out.Id = params.GraphicId;
@@ -669,34 +673,34 @@ namespace Plugin {
669673
!= Core::ERROR_NONE)
670674
|| !in["success"].Boolean()) {
671675
TRACE(Trace::Error,
672-
(_T("modify %d failed"),
673-
params.GraphicId));
676+
(_T("modify %" PRIu32 " failed"),
677+
params.GraphicId.Value()));
674678
}
675679
}
676680
})
677681
== Core::ERROR_NONE);
678682
ASSERT(_watermark->Subscribe<OnWatermarkRequestStatusParams>(
679683
Timeout, _T("onWatermarkRequestStatus"),
680684
[&](const OnWatermarkRequestStatusParams& params) {
681-
if (params.Type == "show") {
682-
if (!params.Success) {
685+
if (params.Type.Value() == "show") {
686+
if (!params.Success.Value()) {
683687
TRACE(Trace::Error, (_T("show failed")));
684688
}
685689
// Watermark plugin does not tell
686690
// which call ended, can be any. Can't take this
687691
// information as a response
688-
} else if (!params.Success) {
692+
} else if (!params.Success.Value()) {
689693
auto watermark = _watermarkStorage
690-
.Get(params.Id);
694+
.Get(params.Id.Value());
691695
if (watermark.IsSet()) {
692696
TRACE(Trace::Error,
693-
(_T("%s %d failed"),
697+
(_T("%s %" PRIu32 " failed"),
694698
params.Type.Value().c_str(),
695-
params.Id));
699+
params.Id.Value()));
696700
}
697-
} else if (params.Type == "create") {
701+
} else if (params.Type.Value() == "create") {
698702
auto watermark = _watermarkStorage
699-
.Get(params.Id);
703+
.Get(params.Id.Value());
700704
if (watermark.IsSet()) {
701705
UpdateWatermarkParams out;
702706
out.Id = params.Id;
@@ -712,13 +716,13 @@ namespace Plugin {
712716
!= Core::ERROR_NONE)
713717
|| !in["success"].Boolean()) {
714718
TRACE(Trace::Error,
715-
(_T("update %d failed"),
716-
params.Id));
719+
(_T("update %" PRIu32 " failed"),
720+
params.Id.Value()));
717721
}
718722
}
719-
} else if (params.Type == "update") {
723+
} else if (params.Type.Value() == "update") {
720724
auto watermark = _watermarkStorage
721-
.Get(params.Id);
725+
.Get(params.Id.Value());
722726
if (watermark.IsSet()
723727
&& watermark.Value()
724728
.AdjustVisibilityRequired) {
@@ -732,18 +736,20 @@ namespace Plugin {
732736
_T("getPalettedWatermark"),
733737
out, in)
734738
!= Core::ERROR_NONE)
735-
|| !in.ImageWidth || !in.ImageHeight) {
739+
|| !in.ImageWidth.Value()
740+
|| !in.ImageHeight.Value()) {
736741
TRACE(Trace::Error,
737-
(_T("get %d failed"), params.Id));
742+
(_T("get %" PRIu32 " failed"),
743+
params.Id.Value()));
738744
} else {
739745
_palettedImageDataStorage.Set(
740-
params.Id,
741-
{ in.ImageKey,
742-
in.ImageWidth,
743-
in.ImageHeight,
744-
in.ClutKey,
745-
in.ClutSize,
746-
in.ClutType });
746+
params.Id.Value(),
747+
{ in.ImageKey.Value(),
748+
in.ImageWidth.Value(),
749+
in.ImageHeight.Value(),
750+
in.ClutKey.Value(),
751+
in.ClutSize.Value(),
752+
in.ClutType.Value() });
747753

748754
LoadClutWatermarkParams out;
749755
out.SessionId = watermark.Value()
@@ -757,8 +763,8 @@ namespace Plugin {
757763
out.WatermarkWidth = in.ImageWidth;
758764
out.WatermarkHeight = in.ImageHeight;
759765
out.AspectRatio
760-
= ((float)in.ImageWidth
761-
/ (float)in.ImageHeight);
766+
= ((float)in.ImageWidth.Value()
767+
/ (float)in.ImageHeight.Value());
762768
JsonObject in2;
763769
if ((_secManager->Invoke<
764770
LoadClutWatermarkParams,
@@ -769,8 +775,8 @@ namespace Plugin {
769775
!= Core::ERROR_NONE)
770776
|| !in2["success"].Boolean()) {
771777
TRACE(Trace::Error,
772-
(_T("load %d failed"),
773-
params.Id));
778+
(_T("load %" PRIu32 " failed"),
779+
params.Id.Value()));
774780
}
775781
}
776782
}
@@ -781,7 +787,7 @@ namespace Plugin {
781787
Timeout, _T("onWatermarkRenderFailed"),
782788
[&](const OnWatermarkRenderFailedParams& params) {
783789
auto watermark = _watermarkStorage
784-
.Get(params.Image);
790+
.Get(params.Image.Value());
785791
if (watermark.IsSet()) {
786792
auto session = _sessionStorage.Get(
787793
watermark.Value().SessionId);

0 commit comments

Comments
 (0)