diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2017-05-18 09:05:46 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2017-05-18 09:05:46 +0200 |
commit | b01a1ee81864033c4489233b037b73476584fec8 (patch) | |
tree | dcb7f7f58472a8ad77c3f07ccce11f81a76e023f /ci.h | |
parent | 50211c706a120cf1d7b60898c5e43b15dff6455b (diff) | |
download | vdr-b01a1ee81864033c4489233b037b73476584fec8.tar.gz vdr-b01a1ee81864033c4489233b037b73476584fec8.tar.bz2 |
Extended the CI API to allow plugins to implement additional CAM resources
Diffstat (limited to 'ci.h')
-rw-r--r-- | ci.h | 102 |
1 files changed, 100 insertions, 2 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: ci.h 4.8 2017/05/01 16:26:34 kls Exp $ + * $Id: ci.h 4.9 2017/05/18 09:05:46 kls Exp $ */ #ifndef __CI_H @@ -21,6 +21,99 @@ #define MAX_CONNECTIONS_PER_CAM_SLOT 8 // maximum possible value is 254 #define CAM_READ_TIMEOUT 50 // ms +class cCiTransportConnection; +class cCamSlot; + +// VDR's Common Interface functions implement only the features that are absolutely +// necessary to control a CAM. If a plugin wants to implement additional functionality +// (i.e. "resources"), it can do so by deriving from cCiResourceHandler, cCiSession +// and (if necessary) from cCiApplicationInformation. + +class cCiSession { +private: + uint16_t sessionId; + uint32_t resourceId; + cCiTransportConnection *tc; +protected: + void SetTsPostProcessor(void); + ///< If this cCiSession implements the TsPostProcess() function, it shall call + ///< SetTsPostProcessor() to register itself as the TS post processor. + void SetResourceId(uint32_t Id); + ///< If this is a class that has been derived from an existing cCiSession class, + ///< but implements a different resource id, it shall call SetResourceId() with + ///< that Id. + int GetTag(int &Length, const uint8_t **Data); + const uint8_t *GetData(const uint8_t *Data, int &Length); + void SendData(int Tag, int Length = 0, const uint8_t *Data = NULL); + cCiTransportConnection *Tc(void) { return tc; } +public: + cCiSession(uint16_t SessionId, uint32_t ResourceId, cCiTransportConnection *Tc); + virtual ~cCiSession(); + uint16_t SessionId(void) { return sessionId; } + uint32_t ResourceId(void) { return resourceId; } + cCamSlot *CamSlot(void); + virtual bool HasUserIO(void) { return false; } + virtual void Process(int Length = 0, const uint8_t *Data = NULL); + virtual bool TsPostProcess(uint8_t *TsPacket) { return false; } + ///< If this cCiSession needs to do additional processing on TS packets (after + ///< the CAM has done the decryption), it shall implement TsPostProcess() and + ///< do whatever operations are necessary on the given TsPacket. This function + ///< is called once for each TS packet, and any and all operations must be + ///< finished upon return. + ///< A derived cCiSession that implements this function must call + ///< SetTsPostProcessor() to make it actually get called. + ///< Returns true if the TsPacket was in any way modified. + }; + +class cCiApplicationInformation : public cCiSession { +protected: + int state; + uint8_t applicationType; + uint16_t applicationManufacturer; + uint16_t manufacturerCode; + char *menuString; +public: + cCiApplicationInformation(uint16_t SessionId, cCiTransportConnection *Tc); + virtual ~cCiApplicationInformation(); + virtual void Process(int Length = 0, const uint8_t *Data = NULL); + bool EnterMenu(void); + const char *GetMenuString(void) { return menuString; } + }; + +class cCiResourceHandler : public cListObject { +public: + cCiResourceHandler(void); + ///< Creates a new resource handler, through which the available resources + ///< can be provides. A resource handler shall be allocated on the heap and + ///< registered with the global CiResourceHandlers, as in + ///< CiResourceHandlers.Register(new cMyResourceHandler); + ///< It will be automatically deleted at the end of the program. + virtual ~cCiResourceHandler(); + virtual const uint32_t *ResourceIds(void) const = 0; + ///< Returns a pointer to an array of resource identifiers, where the + ///< last value is zero. + virtual cCiSession *GetNewCiSession(uint32_t ResourceId, uint16_t SessionId, cCiTransportConnection *Tc) = 0; + ///< Returns a new cCiSession, according to the given ResourceId. + }; + +class cCiResourceHandlers : public cList<cCiResourceHandler> { +private: + cVector<uint32_t> resourceIds; +public: + cCiResourceHandlers(void); + ///< Creates the default list of resourceIds. + void Register(cCiResourceHandler *ResourceHandler); + ///< Adds the given ResourceHandler to the list of resource handlers and + ///< appends its ResourceIds to the global resourceIds. + ///< A plugin that implements additional CAM capabilities must call + ///< this function to register its resources. + const uint32_t *Ids(void) { return &resourceIds[0]; } + int NumIds(void) { return resourceIds.Size(); } + cCiSession *GetNewCiSession(uint32_t ResourceId, uint16_t SessionId, cCiTransportConnection *Tc); + }; + +extern cCiResourceHandlers CiResourceHandlers; + class cCiMMI; class cCiMenu { @@ -73,7 +166,6 @@ public: }; class cDevice; -class cCamSlot; enum eModuleStatus { msNone, msReset, msPresent, msReady }; @@ -377,6 +469,12 @@ public: ///< A derived class that implements this function will also need ///< to set the WantsTsData parameter in the call to the base class ///< constructor to true in order to receive the TS data. + virtual bool TsPostProcess(uchar *Data); + ///< If there is a cCiSession that needs to do additional processing on TS packets + ///< (after the CAM has done the decryption), this function will call its + ///< TsPostProcess() function to have it do whatever operations are necessary on + ///< the given TsPacket. + ///< Returns true if the TsPacket was in any way modified. virtual bool Inject(uchar *Data, int Count); ///< Sends all Count bytes of the given Data to the CAM, and returns true ///< if this was possible. If the data can't be sent to the CAM completely, |