RDK Documentation (Open Sourced RDK Components)
AampSubtecCCManager.cpp
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 AampSubtecCCManager.cpp
22  *
23  * @brief Impl of Subtec ClosedCaption integration layer
24  *
25  */
26 
27 #include "AampSubtecCCManager.h"
28 
29 #include "priv_aamp.h" // Included for AAMPLOG
30 //TODO: Fix cyclic dependency btw GlobalConfig and AampLogManager
31 
33 
34 /**
35  * @brief Impl specific initialization code called before each public interface call
36  */
38 {
41 }
42 
43 /**
44  * @brief Impl specific initialization code for HAL
45  */
47 {
48  if(not mHALInitialized)
49  {
50  if(subtecConnector::initHal() == CC_VL_OS_API_RESULT_SUCCESS)
51  {
52  AAMPLOG_WARN("AampSubtecCCManager::calling subtecConnector::initHal() - success");
53  mHALInitialized = true;
54  }
55  else
56  {
57  AAMPLOG_WARN("AampSubtecCCManager::calling subtecConnector::initHal() - failure");
58  }
59  }
60 };
61 
62 /**
63  * @brief Impl specific initialization code for Communication with rendered
64  */
66 {
67  if(not mRendererInitialized)
68  {
69  if(subtecConnector::initPacketSender() == CC_VL_OS_API_RESULT_SUCCESS)
70  {
71  AAMPLOG_WARN("AampSubtecCCManager::calling subtecConnector::initPacketSender() - success");
72  mRendererInitialized = true;
73  }
74  else
75  {
76  AAMPLOG_WARN("AampSubtecCCManager::calling subtecConnector::initPacketSender() - failure");
77  }
78  }
79 };
80 
81 /**
82  * @brief Gets Handle or ID, Every client using subtec must call GetId in the begining , save id, which is required for Release funciton.
83  */
85 {
86  std::lock_guard<std::mutex> lock(mIdLock);
87  mId++;
88  mIdSet.insert(mId);
89  return mId;
90 }
91 
92 /**
93  * @brief Release CC resources
94  */
96 {
97  std::lock_guard<std::mutex> lock(mIdLock);
98  if( mIdSet.erase(id) > 0 )
99  {
100  int iSize = mIdSet.size();
101  AAMPLOG_WARN("AampSubtecCCManager::users:%d",iSize);
102  //No one using subtec, stop/close it.
103  if(0 == iSize)
104  {
105  subtecConnector::resetChannel();
106  if(mHALInitialized)
107  {
108  subtecConnector::close();
109  mHALInitialized = false;
110  }
111  mTrickplayStarted = false;
112  mParentalCtrlLocked = false;
113  }
114  }
115  else
116  {
117  AAMPLOG_TRACE("AampSubtecCCManager::ID:%d not found returning",id);
118  }
119 }
120 
121 /**
122  * @brief To start CC rendering
123  */
125 {
126  subtecConnector::ccMgrAPI::ccShow();
127 }
128 
129 /**
130  * @brief To stop CC rendering
131  */
133 {
134  subtecConnector::ccMgrAPI::ccHide();
135 }
136 
137 /**
138  * @brief set digital channel with specified id
139  */
141 {
142  const auto ret = subtecConnector::ccMgrAPI::ccSetDigitalChannel(id);
144  return ret;
145 }
146 
147 /**
148  * @brief set analog channel with specified id
149  */
151 {
152  const auto ret = subtecConnector::ccMgrAPI::ccSetAnalogChannel(id);
154  return ret;
155 }
156 
157 /**
158  * @brief ensure mRendering is consistent with renderer state
159  */
161 {
162  AAMPLOG_WARN("AampSubtecCCManager::");
163  if(mEnabled)
164  {
165  Start();
166  }
167  else
168  {
169  Stop();
170  }
172 }
173 
174 /**
175  * @brief Constructor
176  */
178 {
179  // Some of the apps don’t call set track and as default CC is not set, CC doesn’t work.
180  // In this case app expect to render default cc as CC1.
181  // Hence Set default CC track to CC1
182  AAMPLOG_WARN("AampSubtecCCManager::AampSubtecCCManager setting default to cc1");
183  SetTrack("CC1");
184 }
AampSubtecCCManager::GetId
virtual int GetId()
Gets Handle or ID, Every client using subtec must call GetId in the begining , save id,...
Definition: AampSubtecCCManager.cpp:84
AampCCManagerBase::SetTrack
int SetTrack(const std::string &track, const CCFormat format=eCLOSEDCAPTION_FORMAT_DEFAULT)
Set CC track.
Definition: AampCCManager.cpp:651
AampSubtecCCManager::EnsureInitialized
void EnsureInitialized() override
Impl specific initialization code called before each public interface call.
Definition: AampSubtecCCManager.cpp:37
AampCCManagerBase::mTrickplayStarted
bool mTrickplayStarted
Definition: AampCCManager.h:250
AampCCManagerBase::mParentalCtrlLocked
bool mParentalCtrlLocked
Definition: AampCCManager.h:251
AampSubtecCCManager::EnsureRendererStateConsistency
void EnsureRendererStateConsistency()
ensure mRendering is consistent with renderer state
Definition: AampSubtecCCManager.cpp:160
AampCCManagerBase::Start
void Start()
To start CC rendering.
Definition: AampCCManager.cpp:568
AampSubtecCCManager::EnsureHALInitialized
void EnsureHALInitialized() override
Impl specific initialization code for HAL.
Definition: AampSubtecCCManager.cpp:46
AampCCManagerBase::SetStyle
int SetStyle(const std::string &options)
Set CC styles for rendering.
Definition: AampCCManager.cpp:400
AampSubtecCCManager::SetDigitalChannel
int SetDigitalChannel(unsigned int id) override
set digital channel with specified id
Definition: AampSubtecCCManager.cpp:140
AampSubtecCCManager::StartRendering
void StartRendering() override
To start CC rendering.
Definition: AampSubtecCCManager.cpp:124
AampSubtecCCManager::EnsureRendererCommsInitialized
void EnsureRendererCommsInitialized() override
Impl specific initialization code for Communication with rendered.
Definition: AampSubtecCCManager.cpp:65
SubtecConnector.h
Interface header for libsubtec_connector.
AampCCManagerBase::mEnabled
bool mEnabled
Definition: AampCCManager.h:249
priv_aamp.h
Private functions and types used internally by AAMP.
AampSubtecCCManager::StopRendering
void StopRendering() override
To stop CC rendering.
Definition: AampSubtecCCManager.cpp:132
AampSubtecCCManager.h
Integration layer of Subtec ClosedCaption in AAMP.
AAMPLOG_TRACE
#define AAMPLOG_TRACE(FORMAT,...)
AAMP logging defines, this can be enabled through setLogLevel() as per the need.
Definition: AampLogManager.h:83
AampSubtecCCManager::Release
void Release(int iID) override
Release CC resources.
Definition: AampSubtecCCManager.cpp:95
AampSubtecCCManager::SetAnalogChannel
int SetAnalogChannel(unsigned int id) override
set analog channel with specified id
Definition: AampSubtecCCManager.cpp:150
AampCCManagerBase::Stop
void Stop()
To stop CC rendering.
Definition: AampCCManager.cpp:558
AampCCManagerBase::mOptions
std::string mOptions
Definition: AampCCManager.h:246
AampSubtecCCManager::AampSubtecCCManager
AampSubtecCCManager()
Constructor.
Definition: AampSubtecCCManager.cpp:177