RDK Documentation (Open Sourced RDK Components)
AampCCManager.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 2018 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 AampCCManager.h
22  *
23  * @brief Integration layer of ClosedCaption in AAMP
24  *
25  */
26 
27 #ifndef __AAMP_CC_MANAGER_H__
28 #define __AAMP_CC_MANAGER_H__
29 
30 #include <string>
31 #include <vector>
32 #include "main_aamp.h"
33 #include "AampLogManager.h"
34 
35 /**
36  * @enum CCFormat
37  * @brief Different CC formats
38  */
40 {
41  eCLOSEDCAPTION_FORMAT_608 = 0,
42  eCLOSEDCAPTION_FORMAT_708,
43  eCLOSEDCAPTION_FORMAT_DEFAULT
44 };
45 
46 /**
47  * @class AampCCManagerBase
48  * @brief Handles closed caption operations
49  */
50 
52 {
53 public:
54  /**
55  * @fn Init
56  *
57  * @param[in] handle - decoder handle
58  * @return int - 0 on sucess, -1 on failure
59  */
60  int Init(void *handle);
61 
62  /**
63  * @brief Gets Handle or ID, Every client using subtec must call GetId in the begining , save id, which is required for Release funciton.
64  * @return int - unique ID
65  */
66  virtual int GetId() { return 0; };
67 
68  /**
69  * @brief Release CC resources
70  * @param[in] id - returned from GetId function
71  */
72  virtual void Release(int iID) = 0;
73 
74  /**
75  * @fn SetStatus
76  *
77  * @param[in] enable - true to enable CC rendering
78  * @return int - 0 on success, -1 on failure
79  */
80  int SetStatus(bool enable);
81 
82  /**
83  * @brief Get CC rendering status
84  *
85  * @return bool - true if enabled, false otherwise
86  */
87  bool GetStatus() { return mEnabled; };
88 
89  /**
90  * @brief Get current CC track
91  *
92  * @return std::string - current CC track
93  */
94  const std::string &GetTrack() { return mTrack; }
95 
96  /**
97  * @fn SetTrack
98  *
99  * @param[in] track - CC track to be selected
100  * @param[in] format - force track to 608/708 or default
101  * @return int - 0 on success, -1 on failure
102  */
103  int SetTrack(const std::string &track, const CCFormat format = eCLOSEDCAPTION_FORMAT_DEFAULT);
104 
105  /**
106  * @fn SetStyle
107  *
108  * @param[in] options - rendering style options
109  * @return int - 0 on success, -1 on failure
110  */
111  int SetStyle(const std::string &options);
112 
113  /**
114  * @brief Get current CC styles
115  *
116  * @return std::string - current CC options
117  */
118  //TODO: Default values can't be queried
119  const std::string &GetStyle() { return mOptions; }
120 
121  /**
122  * @fn SetTrickplayStatus
123  *
124  * @param[in] enable - true when trickplay starts, false otherwise
125  * @return void
126  */
127  void SetTrickplayStatus(bool enable);
128 
129  /**
130  * @fn SetParentalControlStatus
131  *
132  * @param[in] locked - true when parental control lock enabled, false otherwise
133  * @return void
134  */
135  void SetParentalControlStatus(bool locked);
136 
137  /**
138  * @fn RestoreCC
139  *
140  * @return void
141  */
142  void RestoreCC();
143 
144  virtual ~AampCCManagerBase(){ };
145 
146  /**
147  * @brief update stored list of text tracks
148  *
149  * @param[in] newTextTracks - list of text tracks to store
150  * @return void
151  */
152  void updateLastTextTracks(const std::vector<TextTrackInfo>& newTextTracks) { mLastTextTracks = newTextTracks; }
153 
154  /**
155  * @brief Get list of text tracks
156  *
157  * @return const std::vector<TextTrackInfo>& - list of text tracks
158  */
159  const std::vector<TextTrackInfo>& getLastTextTracks() const { return mLastTextTracks; }
160 
161  void SetLogger(AampLogManager *logObj) { mLogObj = logObj;}
162 
163  /**
164  * @brief To check whether Out of Band Closed caption/Subtile rendering supported or not.
165  *
166  * @return bool, True if Out of Band Closed caption/subtitle rendering supported
167  */
169 
170 protected:
171  /**
172  * @brief To start CC rendering
173  *
174  * @return void
175  */
176  virtual void StartRendering() = 0;
177 
178  /**
179  * @brief To stop CC rendering
180  *
181  * @return void
182  */
183  virtual void StopRendering() = 0;
184 
185  /**
186  * @brief Impl specific initialization code called before each public interface call
187  * @return void
188  */
189  virtual void EnsureInitialized(){};
190 
191  /**
192  * @brief Impl specific initialization code for HAL
193  * @return void
194  */
195  virtual void EnsureHALInitialized(){};
196 
197  /**
198  * @brief Impl specific initialization code for Communication with renderer
199  * @return void
200  */
202 
203  /**
204  * @brief Impl specific initialization code called once in Init() function
205  *
206  * @return 0 - success, -1 - failure
207  */
208  virtual int Initialize(void *handle){return 0;}
209 
210  /**
211  * @brief set digital channel with specified id
212  *
213  * @return CC_VL_OS_API_RESULT
214  */
215  virtual int SetDigitalChannel(unsigned int id) = 0;
216 
217  /**
218  * @brief set analog channel with specified id
219  *
220  * @return CC_VL_OS_API_RESULT
221  */
222  virtual int SetAnalogChannel(unsigned int id) = 0;
223 
224  /**
225  * @brief validate mCCHandle
226  *
227  * @return bool
228  */
229  virtual bool CheckCCHandle() const {return true;}
230 
231  /**
232  * @fn Start
233  *
234  * @return void
235  */
236  void Start();
237 
238  /**
239  * @fn Stop
240  *
241  * @return void
242  */
243  void Stop();
244 
245 
246  std::string mOptions{}; /**< CC rendering styles */
247  std::string mTrack{}; /**< CC track */
248  std::vector<TextTrackInfo> mLastTextTracks{};
249  bool mEnabled{false}; /**< true if CC rendering enabled, false otherwise */
250  bool mTrickplayStarted{false}; /**< If a trickplay is going on or not */
251  bool mParentalCtrlLocked{false}; /**< If Parental Control lock enabled on not */
252  AampLogManager *mLogObj{NULL};
253 };
254 
255 /**
256  * @class AampCCManager
257  * @brief Handle the CC manager instance
258  */
259 
261 {
262 public:
263  /**
264  * @fn GetInstance
265  *
266  * @return AampCCManager - singleton instance
267  */
268  static AampCCManagerBase * GetInstance();
269 
270  /**
271  * @fn DestroyInstance
272  *
273  * @return void
274  */
275  static void DestroyInstance();
276 
277 private:
278  static AampCCManagerBase *mInstance; /**< Singleton instance */
279 };
280 
281 
282 #endif /* __AAMP_CC_MANAGER_H__ */
AampCCManagerBase::Release
virtual void Release(int iID)=0
Release CC resources.
AampCCManagerBase::getLastTextTracks
const std::vector< TextTrackInfo > & getLastTextTracks() const
Get list of text tracks.
Definition: AampCCManager.h:159
AampLogManager.h
Log managed for Aamp.
AampCCManagerBase::StopRendering
virtual void StopRendering()=0
To stop CC rendering.
AampCCManagerBase::SetTrack
int SetTrack(const std::string &track, const CCFormat format=eCLOSEDCAPTION_FORMAT_DEFAULT)
Set CC track.
Definition: AampCCManager.cpp:651
AampCCManagerBase::Initialize
virtual int Initialize(void *handle)
Impl specific initialization code called once in Init() function.
Definition: AampCCManager.h:208
AampCCManagerBase::mTrickplayStarted
bool mTrickplayStarted
Definition: AampCCManager.h:250
AampCCManagerBase::SetParentalControlStatus
void SetParentalControlStatus(bool locked)
To enable/disable CC when parental control locked/unlocked.
Definition: AampCCManager.cpp:628
AampCCManagerBase::Init
int Init(void *handle)
Initialize CC resource.
Definition: AampCCManager.cpp:578
main_aamp.h
Types and APIs exposed by the AAMP player.
AampCCManagerBase::GetTrack
const std::string & GetTrack()
Get current CC track.
Definition: AampCCManager.h:94
AampCCManagerBase::SetAnalogChannel
virtual int SetAnalogChannel(unsigned int id)=0
set analog channel with specified id
AampCCManagerBase::mParentalCtrlLocked
bool mParentalCtrlLocked
Definition: AampCCManager.h:251
AampCCManagerBase::SetStatus
int SetStatus(bool enable)
Enable/disable CC rendering.
Definition: AampCCManager.cpp:755
AampCCManagerBase::EnsureInitialized
virtual void EnsureInitialized()
Impl specific initialization code called before each public interface call.
Definition: AampCCManager.h:189
AampCCManagerBase::SetDigitalChannel
virtual int SetDigitalChannel(unsigned int id)=0
set digital channel with specified id
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AampCCManagerBase::Start
void Start()
To start CC rendering.
Definition: AampCCManager.cpp:568
AampCCManagerBase::StartRendering
virtual void StartRendering()=0
To start CC rendering.
AampCCManager::DestroyInstance
static void DestroyInstance()
Destroy instance.
Definition: AampCCManager.cpp:817
AampCCManagerBase::SetStyle
int SetStyle(const std::string &options)
Set CC styles for rendering.
Definition: AampCCManager.cpp:400
AampCCManagerBase::IsOOBCCRenderingSupported
bool IsOOBCCRenderingSupported()
To check whether Out of Band Closed caption/Subtile rendering supported or not.
Definition: AampCCManager.cpp:781
AampCCManagerBase::mTrack
std::string mTrack
Definition: AampCCManager.h:247
AampCCManagerBase
Handles closed caption operations.
Definition: AampCCManager.h:51
AampCCManagerBase::GetStyle
const std::string & GetStyle()
Get current CC styles.
Definition: AampCCManager.h:119
AampCCManagerBase::mEnabled
bool mEnabled
Definition: AampCCManager.h:249
AampCCManagerBase::EnsureHALInitialized
virtual void EnsureHALInitialized()
Impl specific initialization code for HAL.
Definition: AampCCManager.h:195
CCFormat
CCFormat
Different CC formats.
Definition: AampCCManager.h:39
AampCCManagerBase::EnsureRendererCommsInitialized
virtual void EnsureRendererCommsInitialized()
Impl specific initialization code for Communication with renderer.
Definition: AampCCManager.h:201
AampCCManagerBase::GetStatus
bool GetStatus()
Get CC rendering status.
Definition: AampCCManager.h:87
AampCCManagerBase::SetTrickplayStatus
void SetTrickplayStatus(bool enable)
To enable/disable CC when trickplay starts/ends.
Definition: AampCCManager.cpp:609
AampCCManagerBase::GetId
virtual int GetId()
Gets Handle or ID, Every client using subtec must call GetId in the begining , save id,...
Definition: AampCCManager.h:66
AampCCManager::GetInstance
static AampCCManagerBase * GetInstance()
Get the singleton instance.
Definition: AampCCManager.cpp:799
AampCCManager::mInstance
static AampCCManagerBase * mInstance
Singleton instance.
Definition: AampCCManager.h:278
AampCCManagerBase::RestoreCC
void RestoreCC()
To restore cc state after new tune.
Definition: AampCCManager.cpp:744
AampCCManager
Handle the CC manager instance.
Definition: AampCCManager.h:260
AampCCManagerBase::Stop
void Stop()
To stop CC rendering.
Definition: AampCCManager.cpp:558
AampCCManagerBase::updateLastTextTracks
void updateLastTextTracks(const std::vector< TextTrackInfo > &newTextTracks)
update stored list of text tracks
Definition: AampCCManager.h:152
AampCCManagerBase::mOptions
std::string mOptions
Definition: AampCCManager.h:246
AampCCManagerBase::CheckCCHandle
virtual bool CheckCCHandle() const
validate mCCHandle
Definition: AampCCManager.h:229