Skip navigation

test-cas.c/mk.sh/MAG-CAS-plugin.h

  Example custom cas(ECM):

Example test-cas.c:

#include "MAG-CAS-plugin.h"
#include "stdio.h"
-#define DEBUG(x...) {}//printf(x)
+#define DEBUG(x...) printf(x)
#define DEBUG_CALL() DEBUG("Called function %s\n",__FUNCTION__)

 STB_MAG_Cas_t PluginInterface;
@@ -123,7 +123,7 @@
CAS_Flags_e CAS_GetCasFlags(void)
{
   DEBUG_CALL();
-  return CAS_Flags_DecodeAll;
+  return CAS_Flags_PMT_ECM;
};
/**
  * Get the format of ECM data expected by the plugin in
@@ -155,7 +155,7 @@
     DescramblerInterface.SetScramblingKey = mag_interface->SetScramblingKey;
     DescramblerInterface.SetScramblingType = mag_interface->SetScramblingType;
   }
-  PluginInterface.Decrypt = CAS_Decrypt;
+  PluginInterface.Decrypt = NULL;
   PluginInterface.Deinit = CAS_Deinit;
   PluginInterface.GetCasFlags = CAS_GetCasFlags;
   PluginInterface.GetEcmFormat = NULL;
@@ -165,6 +165,13 @@
   PluginInterface.OnPmtChange = NULL;
   PluginInterface.ResetStream = CAS_ResetStream;
   PluginInterface.SetAdditionalParam = CAS_SetAdditionalParam;
+
+  DescramblerInterface.SetScramblingType(CAS_SCRAMBLING_TYPE_CSA);
+  char evenKey[8]={0x11,0x11,0x11,0x33,0x11,0x11,0x11,0x33};
+  char oddKey[8]={0x11,0x11,0x11,0x33,0x11,0x11,0x11,0x33};
+  DescramblerInterface.SetScramblingKey(evenKey,0);
+  DescramblerInterface.SetScramblingKey(oddKey,1);
+
   return &PluginInterface;
};

Notes:

*When compiling, set option -fPIC

2)Set GetSysID

GetSysID

* Get CAS vendor SysID as defined in DVB. Useful only in

  • CAS_Flags_PMT_ECM mode
  • /

int (*GetSysID)(void);

According this SysID - from stream PID is determined where ECM packets are. Example was designed to decrypt totally with resources of plugin.

Need Help

Dave is an expert on the MAG STB and the author of this article.

Was this article helpful?

Yes No

Sorry to hear that.
How can we improve this article?

We use cookies in order to optimise our website, provide you with the best possible user experience and help us promote our products. Please read our Cookie Policy to find out how we use cookies and how you can control cookies.
By using this website or closing this message, you acknowledge our Privacy Policy and agree to our use of cookies as described in our Cookie Policy.