RDK Documentation (Open Sourced RDK Components)
AampMemorySystem.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 2020 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 AAMPMEMORYSYSTEM_H
21 #define AAMPMEMORYSYSTEM_H
22 
23 /**
24  * @file AampMemorySystem.h
25  * @brief Memory handler for Aamp DRM process
26  */
27 
28 #include <stdint.h>
29 #include <vector>
30 #include <unistd.h>
31 #include "AampConfig.h"
32 
33 /**
34  * @class AAMPMemorySystem
35  * @brief Handles the operations for AAMP memory managemnts
36  */
38 public:
39  /**
40  * @brief Encode a block of data to send over the divide
41  * @param dataIn pointer to the data to encode
42  * @param dataInSz the size to encode
43  * @param out dataOut the data to send
44  * @return true if data is encoded
45  */
46  virtual bool encode(const uint8_t *dataIn, uint32_t dataInSz, std::vector<uint8_t>& dataOut) = 0;
47  /**
48  * @brief Decode from getting back
49  * @param dataIn pointer to the data to decode
50  * @param size the size to decode
51  * @param out dataOut the data to recover
52  * @param int dataOutSz the size of the space for data to recover
53  */
54  virtual bool decode(const uint8_t* dataIn, uint32_t dataInSz, uint8_t *dataOut, uint32_t dataOutSz) = 0;
55 
56  /**
57  * @brief Call this if there's an failure external to the MS and it needs to tidy up unexpectedly
58  */
59  virtual void terminateEarly() {}
60 
61  AAMPMemorySystem(AampLogManager *logObj): mLogObj(logObj) {}
62  AAMPMemorySystem(const AAMPMemorySystem&) = delete;
63  AAMPMemorySystem& operator=(const AAMPMemorySystem&) = delete;
64  virtual ~AAMPMemorySystem() {}
65  AampLogManager *mLogObj;
66 };
67 
68 /**
69  * @class AampMemoryHandleCloser
70  * @brief This just closes a file on descope
71  */
73 public:
74  AampMemoryHandleCloser(int handle) : handle_(handle) {};
75  ~AampMemoryHandleCloser() { if (handle_ > 0) { close(handle_); } }
76 private:
77  int handle_;
78 };
79 
80 
81 #endif /* AAMPMEMORYSYSTEM_H */
82 
AAMPMemorySystem::decode
virtual bool decode(const uint8_t *dataIn, uint32_t dataInSz, uint8_t *dataOut, uint32_t dataOutSz)=0
Decode from getting back.
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AAMPMemorySystem::encode
virtual bool encode(const uint8_t *dataIn, uint32_t dataInSz, std::vector< uint8_t > &dataOut)=0
Encode a block of data to send over the divide.
AampConfig.h
Configurations for AAMP.
AampMemoryHandleCloser
This just closes a file on descope.
Definition: AampMemorySystem.h:72
AAMPMemorySystem::terminateEarly
virtual void terminateEarly()
Call this if there's an failure external to the MS and it needs to tidy up unexpectedly.
Definition: AampMemorySystem.h:59
AAMPMemorySystem
Handles the operations for AAMP memory managemnts.
Definition: AampMemorySystem.h:37