RDK Documentation (Open Sourced RDK Components)
AampSecManager.h
Go to the documentation of this file.
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 2021 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 /**
21  * @file AampSecManager.h
22  * @brief Class to communicate with SecManager Thunder plugin
23  */
24 
25 #ifndef __AAMP_SECMANAGER_H__
26 #define __AAMP_SECMANAGER_H__
27 
28 #include <mutex>
29 #include "priv_aamp.h"
30 #include "ThunderAccess.h"
31 
32 
33 #define SECMANAGER_CALL_SIGN "org.rdk.SecManager.1"
34 #define WATERMARK_PLUGIN_CALLSIGN "org.rdk.Watermark.1"
35 //#define RDKSHELL_CALLSIGN "org.rdk.RDKShell.1" //need to be used instead of WATERMARK_PLUGIN_CALLSIGN if RDK Shell is used for rendering watermark
36 
37 /**
38  * @class AampSecManager
39  * @brief Class to get License from Sec Manager
40  */
42 {
43 public:
44 
45  /**
46  * @fn GetInstance
47  *
48  * @return AampSecManager instance
49  */
50  static AampSecManager* GetInstance();
51 
52  /**
53  * @fn DestroyInstance
54  */
55  static void DestroyInstance();
56 
57  /**
58  * @fn AcquireLicense
59  *
60  * @param[in] licenseUrl - url to fetch license from
61  * @param[in] moneyTraceMetdata - moneytrace info
62  * @param[in] accessAttributes - accessAttributes info
63  * @param[in] contentMetadata - content metadata info
64  * @param[in] licenseRequest - license challenge info
65  * @param[in] keySystemId - unique system ID of drm
66  * @param[in] mediaUsage - indicates whether its stream or download license request
67  * @param[in] accessToken - access token info
68  * @param[out] sessionId - ID of current session
69  * @param[out] licenseResponse - license response
70  * @param[out] licenseResponseLength - len of license response
71  * @param[out] statusCode - license fetch status code
72  * @param[out] reasonCode - license fetch reason code
73  * @return bool - true if license fetch successful, false otherwise
74  */
75  bool AcquireLicense(PrivateInstanceAAMP* aamp, const char* licenseUrl, const char* moneyTraceMetdata[][2],
76  const char* accessAttributes[][2], const char* contentMetadata, size_t contentMetadataLen,
77  const char* licenseRequest, size_t licenseRequestLen, const char* keySystemId,
78  const char* mediaUsage, const char* accessToken, size_t accessTokenLen,
79  int64_t* sessionId,
80  char** licenseResponse, size_t* licenseResponseLength,
81  int32_t* statusCode, int32_t* reasonCode, int32_t* businessStatus);
82 
83 
84  /**
85  * @fn UpdateSessionState
86  *
87  * @param[in] sessionId - session id
88  * @param[in] active - true if session is active, false otherwise
89  */
90  void UpdateSessionState(int64_t sessionId, bool active);
91 
92  /**
93  * @fn ReleaseSession
94  *
95  * @param[in] sessionId - session id
96  */
97  void ReleaseSession(int64_t sessionId);
98  /**
99  * @fn setVideoWindowSize
100  *
101  * @param[in] sessionId - session id
102  * @param[in] video_width - video width
103  * @param[in] video_height - video height
104  */
105  bool setVideoWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height);
106  /**
107  * @fn setPlaybackSpeedState
108  *
109  * @param[in] sessionId - session id
110  * @param[in] playback_speed - playback speed
111  * @param[in] playback_position - playback position
112  * @param[in] delayNeeded - if delay is required, to avoid any wm flash before tune
113  */
114  bool setPlaybackSpeedState(int64_t sessionId, int64_t playback_speed, int64_t playback_position, bool delayNeeded = false);
115  /**
116  * @fn loadClutWatermark
117  * @param[in] sessionId - session id
118  *
119  */
120  bool loadClutWatermark(int64_t sessionId, int64_t graphicId, int64_t watermarkClutBufferKey, int64_t watermarkImageBufferKey, int64_t clutPaletteSize, const char* clutPaletteFormat, int64_t watermarkWidth, int64_t watermarkHeight, float aspectRatio);
121 
122 private:
123 
124  /**
125  * @fn AampSecManager
126  */
127  AampSecManager();
128 
129  /**
130  * @fn ~AampSecManager
131  */
132  ~AampSecManager();
133  /**
134  * @brief Copy constructor disabled
135  *
136  */
137  AampSecManager(const AampSecManager&) = delete;
138  /**
139  * @brief assignment operator disabled
140  *
141  */
142  AampSecManager* operator=(const AampSecManager&) = delete;
143  /**
144  * @fn RegisterEvent
145  * @param[in] eventName : Event name
146  * @param[in] functionHandler : Event funciton pointer
147  */
148  void RegisterEvent (string eventName, std::function<void(const WPEFramework::Core::JSON::VariantContainer&)> functionHandler);
149  /**
150  * @fn RegisterAllEvents
151  */
152  void RegisterAllEvents ();
153  /**
154  * @fn UnRegisterAllEvents
155  */
156  void UnRegisterAllEvents ();
157 
158  /*Event Handlers*/
159  /**
160  * @fn watermarkSessionHandler
161  * @param parameters - i/p JsonObject params
162  */
163  void watermarkSessionHandler(const JsonObject& parameters);
164  /**
165  * @fn addWatermarkHandler
166  * @param parameters - i/p JsonObject params
167  */
168  void addWatermarkHandler(const JsonObject& parameters);
169  /**
170  * @fn updateWatermarkHandler
171  * @param parameters - i/p JsonObject params
172  */
173  void updateWatermarkHandler(const JsonObject& parameters);
174  /**
175  * @fn removeWatermarkHandler
176  * @param parameters - i/p JsonObject params
177  */
178  void removeWatermarkHandler(const JsonObject& parameters);
179  /**
180  * @fn showWatermarkHandler
181  * @param parameters - i/p JsonObject params
182  */
183  void showWatermarkHandler(const JsonObject& parameters);
184 
185  /**
186  * @fn ShowWatermark
187  */
188  void ShowWatermark(bool show);
189  /**
190  * @fn CreateWatermark
191  */
192  void CreateWatermark(int graphicId, int zIndex);
193  /**
194  * @fn DeleteWatermark
195  */
196  void DeleteWatermark(int graphicId);
197  /**
198  * @fn UpdateWatermark
199  */
200  void UpdateWatermark(int graphicId, int smKey, int smSize);
201  /**
202  * @fn AlwaysShowWatermarkOnTop
203  */
204  void AlwaysShowWatermarkOnTop(bool show);
205  /**
206  * @fn GetWaterMarkPalette
207  */
208  void GetWaterMarkPalette(int sessionId, int graphicId);
209  /**
210  * @fn ModifyWatermarkPalette
211  */
212  void ModifyWatermarkPalette(int graphicId, int clutKey, int imageKey);
213 
214  static AampSecManager *mInstance; /**< singleton instance*/
215  PrivateInstanceAAMP* mAamp; /**< Pointer to the PrivateInstanceAAMP*/
216  ThunderAccessAAMP mSecManagerObj; /**< ThunderAccessAAMP object for communicating with SecManager*/
217  ThunderAccessAAMP mWatermarkPluginObj; /**< ThunderAccessAAMP object for communicating with Watermark Plugin Obj*/
218  std::mutex mSecMutex; /**< Lock for accessing mSecManagerObj*/
219  std::mutex mWatMutex; /**< Lock for accessing mWatermarkPluginObj*/
220  std::mutex mSpeedStateMutex; /**< Lock for accessing mWatermarkPluginObj*/
221  std::list<std::string> mRegisteredEvents;
222  bool mSchedulerStarted;
223 };
224 
225 #endif /* __AAMP_SECMANAGER_H__ */
AampSecManager::ModifyWatermarkPalette
void ModifyWatermarkPalette(int graphicId, int clutKey, int imageKey)
ModifyWatermarkPalette.
Definition: AampSecManager.cpp:916
ThunderAccess.h
shim for dispatching UVE HDMI input playback
AampSecManager::GetWaterMarkPalette
void GetWaterMarkPalette(int sessionId, int graphicId)
GetWaterMarkPalette.
Definition: AampSecManager.cpp:871
AampSecManager::RegisterAllEvents
void RegisterAllEvents()
Registers all Events to input plugin.
Definition: AampSecManager.cpp:527
AampSecManager::mSpeedStateMutex
std::mutex mSpeedStateMutex
Definition: AampSecManager.h:220
AampSecManager::addWatermarkHandler
void addWatermarkHandler(const JsonObject &parameters)
Gets watermark image details and manages watermark rendering.
Definition: AampSecManager.cpp:579
AampSecManager::ReleaseSession
void ReleaseSession(int64_t sessionId)
To notify SecManager to release a session.
Definition: AampSecManager.cpp:354
AampSecManager::~AampSecManager
~AampSecManager()
AampScheduler Destructor.
Definition: AampSecManager.cpp:83
AampSecManager::UpdateWatermark
void UpdateWatermark(int graphicId, int smKey, int smSize)
Update Wateramrk.
Definition: AampSecManager.cpp:806
AampSecManager::operator=
AampSecManager * operator=(const AampSecManager &)=delete
assignment operator disabled
AampSecManager::setVideoWindowSize
bool setVideoWindowSize(int64_t sessionId, int64_t video_width, int64_t video_height)
To update session state to SecManager.
Definition: AampSecManager.cpp:388
AampSecManager::watermarkSessionHandler
void watermarkSessionHandler(const JsonObject &parameters)
Detects watermarking session conditions.
Definition: AampSecManager.cpp:565
AampSecManager::mInstance
static AampSecManager * mInstance
Definition: AampSecManager.h:214
AampSecManager::UpdateSessionState
void UpdateSessionState(int64_t sessionId, bool active)
To update session state to SecManager.
Definition: AampSecManager.cpp:314
AampSecManager::DestroyInstance
static void DestroyInstance()
To release AampSecManager singelton instance.
Definition: AampSecManager.cpp:47
AampSecManager::DeleteWatermark
void DeleteWatermark(int graphicId)
Delete Watermark.
Definition: AampSecManager.cpp:774
AampSecManager
Class to get License from Sec Manager.
Definition: AampSecManager.h:41
AampSecManager::mAamp
PrivateInstanceAAMP * mAamp
Definition: AampSecManager.h:215
AampScheduler
Scheduler class for asynchronous operations.
Definition: AampScheduler.h:86
AampSecManager::CreateWatermark
void CreateWatermark(int graphicId, int zIndex)
Create Watermark.
Definition: AampSecManager.cpp:742
AampSecManager::updateWatermarkHandler
void updateWatermarkHandler(const JsonObject &parameters)
Gets updated watermark image details and manages watermark rendering.
Definition: AampSecManager.cpp:636
AampSecManager::mSecMutex
std::mutex mSecMutex
Definition: AampSecManager.h:218
AampSecManager::showWatermarkHandler
void showWatermarkHandler(const JsonObject &parameters)
Handles watermark calls to be only once.
Definition: AampSecManager.cpp:686
AampSecManager::AampSecManager
AampSecManager()
AampScheduler Constructor.
Definition: AampSecManager.cpp:59
AampSecManager::GetInstance
static AampSecManager * GetInstance()
To get AampSecManager instance.
Definition: AampSecManager.cpp:35
AampSecManager::AlwaysShowWatermarkOnTop
void AlwaysShowWatermarkOnTop(bool show)
Show watermark image This method need to be used only when RDKShell is used for rendering....
Definition: AampSecManager.cpp:841
AampSecManager::loadClutWatermark
bool loadClutWatermark(int64_t sessionId, int64_t graphicId, int64_t watermarkClutBufferKey, int64_t watermarkImageBufferKey, int64_t clutPaletteSize, const char *clutPaletteFormat, int64_t watermarkWidth, int64_t watermarkHeight, float aspectRatio)
To Load ClutWatermark.
Definition: AampSecManager.cpp:469
priv_aamp.h
Private functions and types used internally by AAMP.
PrivateInstanceAAMP
Class representing the AAMP player's private instance, which is not exposed to outside world.
Definition: priv_aamp.h:640
AampSecManager::removeWatermarkHandler
void removeWatermarkHandler(const JsonObject &parameters)
Removes watermark image.
Definition: AampSecManager.cpp:655
AampSecManager::UnRegisterAllEvents
void UnRegisterAllEvents()
UnRegisters all Events from plugin.
Definition: AampSecManager.cpp:554
AampSecManager::setPlaybackSpeedState
bool setPlaybackSpeedState(int64_t sessionId, int64_t playback_speed, int64_t playback_position, bool delayNeeded=false)
To set Playback Speed State to SecManager.
Definition: AampSecManager.cpp:425
AampSecManager::mWatMutex
std::mutex mWatMutex
Definition: AampSecManager.h:219
AampSecManager::RegisterEvent
void RegisterEvent(string eventName, std::function< void(const WPEFramework::Core::JSON::VariantContainer &)> functionHandler)
Registers Event to input plugin and to mRegisteredEvents list for later use.
Definition: AampSecManager.cpp:514
AampSecManager::mSecManagerObj
ThunderAccessAAMP mSecManagerObj
Definition: AampSecManager.h:216
ThunderAccessAAMP
Support Thunder Plugin Access from AAMP.
Definition: ThunderAccess.h:41
AampSecManager::ShowWatermark
void ShowWatermark(bool show)
Show watermark image.
Definition: AampSecManager.cpp:710
AampSecManager::mWatermarkPluginObj
ThunderAccessAAMP mWatermarkPluginObj
Definition: AampSecManager.h:217
AampSecManager::AcquireLicense
bool AcquireLicense(PrivateInstanceAAMP *aamp, const char *licenseUrl, const char *moneyTraceMetdata[][2], const char *accessAttributes[][2], const char *contentMetadata, size_t contentMetadataLen, const char *licenseRequest, size_t licenseRequestLen, const char *keySystemId, const char *mediaUsage, const char *accessToken, size_t accessTokenLen, int64_t *sessionId, char **licenseResponse, size_t *licenseResponseLength, int32_t *statusCode, int32_t *reasonCode, int32_t *businessStatus)
To acquire license from SecManager.
Definition: AampSecManager.cpp:100