RDK Documentation (Open Sourced RDK Components)
casservice.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt 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 #ifndef _CAS_SERVICE_H_
21 #define _CAS_SERVICE_H_
22 
23 #include <memory>
24 #include "mediaplayer.h"
25 #include "rdkmediaplayerimpl.h"
26 #include "CASDataListener.h"
27 #include "CASManager.h"
28 #include "CASHelper.h"
29 #include "rmfbase.h"
30 #include "ICasSectionFilter.h"
31 
32 using namespace anycas;
33 class MediaPlayerSink;
34 class RMFPlayer;
35 
36 class PSIInfo
37 {
38 public:
39  std::vector<uint8_t> pat;
40  std::vector<uint8_t> pmt;
41  std::vector<uint8_t> cat;
42 };
43 
44 class CASService : public CASDataListener, CASStatusInform
45 {
46 public:
47  CASService(const EventEmitter& emit, const CASEnvironment& env, ICasSectionFilter* casSFInterface, ICasPipeline *casPipelineInterface)
48  :emit_(emit),
49  env_(env),
50  casSFInterface_(casSFInterface),
51  casPipelineInterface_(casPipelineInterface),
52  bManagementSession_(false) { }
53  ~CASService() = default;
54 
55  /**
56  * @brief This API to initialize the CAS Serivce includes casManager and casHelper
57  *
58  * @param[in] management flag to represents whether CAS created for Management
59  * @param[in] casOcdmId CAS openCDM Id
60  * @param[in] psiInfo PSI info, more of PAT, PMT, CAT
61  *
62  * @return Returns status of the operation true or false
63  * @retval true on success, false upon any failure.
64  */
65  bool initialize(bool management, const std::string& casOcdmId, PSIInfo *psiInfo);
66 
67  /**
68  * @brief This API to start/stop the decryption of the audio/video content
69  *
70  * @param[in] startPids Pids List to be started to play (Audio Video Pids)
71  * @param[in] stopPids Pids List to be stopped which is currently playing (empty for the Channel tune, e.g. used upon Audio Language change)
72  *
73  * @return Returns status of the operation true or false
74  * @retval true on success, false upon any failure.
75  */
76  bool startStopDecrypt(const std::vector<uint16_t>& startPids, const std::vector<uint16_t>& stopPids);
77 
78  /**
79  * @brief This API is updatePSI when PAT/PMT/CAT updates.
80  *
81  * @param[in] pat updated PAT Buffer
82  * @param[in] pmt updated PMT Buffer
83  * @param[in] cat updated CAT Buffer
84  */
85  void updatePSI(const std::vector<uint8_t>& pat, const std::vector<uint8_t>& pmt, const std::vector<uint8_t>& cat);
86 
87  /**
88  * @brief This API is invoked by CAS plugin when it requires to sends the CAS Status
89  *
90  * @param[in] status CAS Status which contains the status, errorno and message
91  */
92  virtual void informStatus(const CASStatus& status) override;
93 
94  /**
95  * @brief This API is invoked by CAS plugin when it requires to push data
96  *
97  * @param[in] data data to be send back as response asynchronously
98  */
99  void casPublicData(const std::vector<uint8_t>& data);
100 
101  /**
102  * @brief This API is invoked by CAS plugin when it requires to push data
103  *
104  * @param[in] filterId filter id for the corressponding section data received
105  * @param[in] data section data to be processed
106  */
107  void processSectionData(const uint32_t& filterId, const std::vector<uint8_t>& data);
108 
109  /**
110  * @brief This API is to get CASHelper
111  *
112  * @return Returns the CAS Helper object
113  */
114  std::shared_ptr<CASHelper> getCasHelper() { return casHelper_; }
115 
116  /**
117  * @brief This API is to check whether current one is for Managemnet or Tuning Session
118  *
119  * @return Returns true or false whether it is a session for tuning or management
120  * @retval true if a management session, false otherwise
121  */
122  bool isManagementSession() const;
123 
124 private:
125  std::shared_ptr<CASManager> casManager_;
126  std::shared_ptr<CASHelper> casHelper_;
127  EventEmitter emit_;
128  PSIInfo psiInfo;
129  bool bManagementSession_;
130  std::string casOcdmId_;
131  CASEnvironment env_;
132 
133  ICasSectionFilter* casSFInterface_;
134  ICasPipeline* casPipelineInterface_;
135 
136 };
137 
138 #endif // _CAS_SERVICE_H_
PSIInfo
Definition: casservice.h:36
CASService
Definition: casservice.h:44
RMFPlayer
Definition: rmfplayer.h:48
CASService::getCasHelper
std::shared_ptr< CASHelper > getCasHelper()
This API is to get CASHelper.
Definition: casservice.h:114
EventEmitter
Definition: rtevents.h:51