Skip to content

Commit e295f24

Browse files
authored
Merge pull request rdkcentral#5949 from npoltorapavlo/RDK-52316-main
Merge pull request rdkcentral#5790 from npoltorapavlo/RDK-52316-24Q4
2 parents d6d87d2 + de3df4f commit e295f24

11 files changed

+1036
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: L2-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+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
path: ${{github.repository}}
21+
22+
- name: Install cmake
23+
run: |
24+
sudo apt update
25+
sudo apt install -y cmake
26+
27+
- name: Build Thunder
28+
working-directory: ${{github.workspace}}
29+
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh
30+
31+
- name: Build
32+
working-directory: ${{github.workspace}}
33+
run: |
34+
cmake -S ${GITHUB_REPOSITORY}/ContentProtection -B build/ContentProtection -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror"
35+
cmake --build build/ContentProtection --target install

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ if(PLUGIN_MIGRATIONPREPARER)
413413
add_subdirectory(MigrationPreparer)
414414
endif()
415415

416+
if(PLUGIN_CONTENTPROTECTION)
417+
add_subdirectory(ContentProtection)
418+
endif()
419+
416420
if(WPEFRAMEWORK_CREATE_IPKG_TARGETS)
417421
set(CPACK_GENERATOR "DEB")
418422
set(CPACK_DEB_COMPONENT_INSTALL ON)

ContentProtection/CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this RDK Service will be documented in this file.
4+
5+
* Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG.
6+
7+
* Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels:
8+
* **Added** for new features.
9+
* **Changed** for changes in existing functionality.
10+
* **Deprecated** for soon-to-be removed features.
11+
* **Removed** for now removed features.
12+
* **Fixed** for any bug fixes.
13+
* **Security** in case of vulnerabilities.
14+
15+
* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.
16+
17+
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
18+
19+
## [1.0.0] - 2024-07-15
20+
### Added
21+
- Add CHANGELOG
22+
23+
### Change
24+
- Reset API version to 1.0.0
25+
- Change README to inform how to update changelog and API version

ContentProtection/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# If not stated otherwise in this file or this component's LICENSE file the
2+
# following copyright and licenses apply:
3+
#
4+
# Copyright 2022 RDK Management
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
cmake_minimum_required(VERSION 3.14)
19+
20+
set(PLUGIN_NAME ContentProtection)
21+
find_package(WPEFramework NAMES WPEFramework Thunder)
22+
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})
23+
24+
set(CMAKE_CXX_STANDARD 11)
25+
26+
set(PLUGIN_CONTENTPROTECTION_STARTUPORDER "" CACHE STRING "To configure startup order of the plugin")
27+
set(PLUGIN_CONTENTPROTECTION_AUTOSTART false CACHE STRING "To automatically start the plugin")
28+
29+
add_library(${MODULE_NAME} SHARED
30+
ContentProtection.cpp
31+
Module.cpp
32+
)
33+
34+
find_package(${NAMESPACE}Plugins REQUIRED)
35+
find_package(${NAMESPACE}Definitions REQUIRED)
36+
target_link_libraries(${MODULE_NAME} PRIVATE
37+
${NAMESPACE}Plugins::${NAMESPACE}Plugins
38+
${NAMESPACE}Definitions::${NAMESPACE}Definitions
39+
)
40+
41+
install(TARGETS ${MODULE_NAME}
42+
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
43+
44+
write_config(${PLUGIN_NAME})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
precondition = ["Platform"]
2+
callsign = "org.rdk.ContentProtection"
3+
autostart = "@PLUGIN_CONTENTPROTECTION_AUTOSTART@"
4+
startuporder = "@PLUGIN_CONTENTPROTECTION_STARTUPORDER@"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(autostart ${PLUGIN_CONTENTPROTECTION_AUTOSTART})
2+
set(preconditions Platform)
3+
set(callsign "org.rdk.ContentProtection")
4+
5+
if(PLUGIN_CONTENTPROTECTION_STARTUPORDER)
6+
set (startuporder ${PLUGIN_CONTENTPROTECTION_STARTUPORDER})
7+
endif()
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* If not stated otherwise in this file or this component's LICENSE file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2022 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include "ContentProtection.h"
21+
22+
#define API_VERSION_NUMBER_MAJOR 1
23+
#define API_VERSION_NUMBER_MINOR 0
24+
#define API_VERSION_NUMBER_PATCH 0
25+
26+
namespace WPEFramework {
27+
namespace Plugin {
28+
29+
namespace {
30+
static Metadata<ContentProtection> metadata(
31+
// Version (Major, Minor, Patch)
32+
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
33+
// Preconditions
34+
{},
35+
// Terminations
36+
{},
37+
// Controls
38+
{});
39+
}
40+
41+
SERVICE_REGISTRATION(ContentProtection, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
42+
43+
const string ContentProtection::Initialize(PluginHost::IShell* service)
44+
{
45+
string result;
46+
47+
ASSERT(service != nullptr);
48+
49+
_implementation = Core::Service<Implementation>::Create<
50+
Exchange::IContentProtection>(*this);
51+
Exchange::JContentProtection::Register(*this, _implementation);
52+
53+
string token;
54+
auto security = service->QueryInterfaceByCallsign<
55+
PluginHost::IAuthenticate>("SecurityAgent");
56+
if (security != nullptr) {
57+
string payload = "http://localhost";
58+
auto ret = security->CreateToken(
59+
static_cast<uint16_t>(payload.length()),
60+
reinterpret_cast<const uint8_t*>(payload.c_str()),
61+
token);
62+
if (ret != Core::ERROR_NONE) {
63+
SYSLOG(Logging::Startup,
64+
(_T("Couldn't create token: %d"), ret));
65+
}
66+
security->Release();
67+
}
68+
69+
Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"),
70+
(_T("127.0.0.1:9998")));
71+
_secManager = Core::ProxyType<JSONRPCLink>::Create(
72+
_T("SecManager"), _T(""), "token=" + token);
73+
_watermark = Core::ProxyType<JSONRPCLink>::Create(
74+
_T("Watermark"), _T(""), "token=" + token);
75+
Subscribe();
76+
77+
return result;
78+
}
79+
80+
void ContentProtection::Deinitialize(PluginHost::IShell*)
81+
{
82+
Unsubscribe();
83+
Exchange::JContentProtection::Unregister(*this);
84+
if (_implementation != nullptr) {
85+
_implementation->Release();
86+
}
87+
}
88+
89+
string ContentProtection::Information() const
90+
{
91+
return (string());
92+
}
93+
94+
} // namespace Plugin
95+
} // namespace WPEFramework

0 commit comments

Comments
 (0)