[vlc-commits] Linux DVB: migrate EN 50221 code

Rémi Denis-Courmont git at videolan.org
Wed May 11 21:44:00 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 11 22:42:40 2011 +0300| [aa87371faa2bb5f8a313d918cad1194ac8fe15e0] | committer: Rémi Denis-Courmont

Linux DVB: migrate EN 50221 code

This needs testing (my DVB driver is not CI-capable).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa87371faa2bb5f8a313d918cad1194ac8fe15e0
---

 modules/access/Modules.am             |    5 ++++
 modules/access/dtv/dtv.h              |    5 ++++
 modules/access/{dvb => dtv}/en50221.c |    6 ++--
 modules/access/{dvb => dtv}/en50221.h |    3 +-
 modules/access/dtv/linux.c            |   43 +++++++++++++++++++++++++++-----
 5 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/modules/access/Modules.am b/modules/access/Modules.am
index 2a52a5c..8130a38 100644
--- a/modules/access/Modules.am
+++ b/modules/access/Modules.am
@@ -135,6 +135,11 @@ libdtv_plugin_la_DEPENDENCIES =
 
 if HAVE_LINUX
 libdtv_plugin_la_SOURCES += dtv/linux.c
+if HAVE_DVBPSI
+libdtv_plugin_la_SOURCES += dtv/en50221.c dtv/en50221.h
+libdtv_plugin_la_CFLAGS += -DHAVE_DVBPSI $(DVBPSI_CFLAGS)
+libdtv_plugin_la_LIBADD += $(DVBPSI_LIBS)
+endif
 libvlc_LTLIBRARIES += libdtv_plugin.la
 endif
 
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index f24f7db..19349ec 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -43,6 +43,11 @@ const delsys_t *dvb_guess_system (dvb_device_t *);
 float dvb_get_signal_strength (dvb_device_t *);
 float dvb_get_snr (dvb_device_t *);
 
+#ifdef HAVE_DVBPSI
+struct dvbpsi_pmt_s;
+void dvb_set_ca_pmt (dvb_device_t *, struct dvbpsi_pmt_s *);
+#endif
+
 int dvb_set_inversion (dvb_device_t *, int);
 int dvb_tune (dvb_device_t *);
 
diff --git a/modules/access/dvb/en50221.c b/modules/access/dtv/en50221.c
similarity index 99%
rename from modules/access/dvb/en50221.c
rename to modules/access/dtv/en50221.c
index 5716d47..edcc56d 100644
--- a/modules/access/dvb/en50221.c
+++ b/modules/access/dtv/en50221.c
@@ -50,13 +50,13 @@
 # include <dvbpsi/demux.h>
 # include <dvbpsi/sdt.h>
 
+#undef ENABLE_HTTPD
 #ifdef ENABLE_HTTPD
 #   include <vlc_httpd.h>
 #endif
 
-#include "dvb.h"
-#include "../../demux/dvb-text.h"
-#include "en50221.h"
+#include "../demux/dvb-text.h"
+#include "dtv/en50221.h"
 
 typedef struct en50221_session_t
 {
diff --git a/modules/access/dvb/en50221.h b/modules/access/dtv/en50221.h
similarity index 95%
rename from modules/access/dvb/en50221.h
rename to modules/access/dtv/en50221.h
index 2a63c7e..48b6d74 100644
--- a/modules/access/dvb/en50221.h
+++ b/modules/access/dtv/en50221.h
@@ -24,10 +24,11 @@
  *****************************************************************************/
 
 typedef struct cam cam_t;
+struct dvbpsi_pmt_s;
 
 cam_t *en50221_Init( vlc_object_t *, int fd );
 void en50221_Poll( cam_t * );
-int en50221_SetCAPMT( cam_t *, dvbpsi_pmt_t * );
+int en50221_SetCAPMT( cam_t *, struct dvbpsi_pmt_s * );
 char *en50221_Status( cam_t *, char *req );
 void en50221_End( cam_t * );
 
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index c9d505b..29426d2 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -37,6 +37,9 @@
 #include <linux/dvb/dmx.h>
 
 #include "dtv/dtv.h"
+#ifdef HAVE_DVBPSI
+# include "dtv/en50221.h"
+#endif
 
 #ifndef O_SEARCH
 # define O_SEARCH O_RDONLY
@@ -179,7 +182,9 @@ struct dvb_device
         uint16_t pid;
     } pids[MAX_PIDS];
 #endif
-    int ca;
+#ifdef HAVE_DVBPSI
+    cam_t *cam;
+#endif
     struct dvb_frontend_info info;
     bool budget;
     //size_t buffer_size;
@@ -209,7 +214,9 @@ dvb_device_t *dvb_open (vlc_object_t *obj, bool tune)
 
     d->obj = obj;
     d->frontend = -1;
-    d->ca = -1;
+#ifdef HAVE_DVBPSI
+    d->cam = NULL;
+#endif
     d->budget = var_InheritBool (obj, "dvb-budget-mode");
 
 #ifndef USE_DMX
@@ -290,10 +297,17 @@ dvb_device_t *dvb_open (vlc_object_t *obj, bool tune)
         msg_Dbg (obj, " (%"PRIu32" tolerance)",
                  d->info.symbol_rate_tolerance);
 
-        d->ca = dvb_open_node (dirfd, device, "ca", O_RDWR);
-        if (d->ca == -1)
+#ifdef HAVE_DVBPSI
+        int ca = dvb_open_node (dirfd, device, "ca", O_RDWR);
+        if (ca != -1)
+        {
+            d->cam = en50221_Init (obj, ca);
+            if (d->cam == NULL)
+                close (ca);
+        }
+        else
             msg_Dbg (obj, "conditional access module not available (%m)");
-
+#endif
     }
     close (dirfd);
     return d;
@@ -315,8 +329,10 @@ void dvb_close (dvb_device_t *d)
                 close (d->pids[i].fd);
     }
 #endif
-    if (d->ca != -1)
-        close (d->ca);
+#ifdef HAVE_DVBPSI
+    if (d->cam != NULL)
+        en50221_End (d->cam);
+#endif
     if (d->frontend != -1)
         close (d->frontend);
     close (d->demux);
@@ -332,6 +348,11 @@ ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len)
     struct pollfd ufd[2];
     int n;
 
+#ifdef HAVE_DVBPSI
+    if (d->cam != NULL)
+        en50221_Poll (d->cam);
+#endif
+
     ufd[0].fd = d->demux;
     ufd[0].events = POLLIN;
     if (d->frontend != -1)
@@ -481,6 +502,14 @@ float dvb_get_snr (dvb_device_t *d)
     return snr / 65535.;
 }
 
+#ifdef HAVE_DVBPSI
+void dvb_set_ca_pmt (dvb_device_t *d, struct dvbpsi_pmt_s *pmt)
+{
+    if (d->cam != NULL)
+        en50221_SetCAPMT (d->cam, pmt);
+}
+#endif
+
 static int dvb_vset_props (dvb_device_t *d, size_t n, va_list ap)
 {
     struct dtv_property buf[n], *prop = buf;



More information about the vlc-commits mailing list