[dvblast-devel] [PATCH 3/4] comm: Add supported for GET_{PAT, CAT, NIT, SDT} commands

Georgi Chorbadzhiyski gf at unixsol.org
Thu Aug 25 15:00:08 CEST 2011


These commands return currently active tables that have
passed through demux.
---
 comm.c |   34 ++++++++++++++++++++++++++++++++++
 comm.h |   13 ++++++++++++-
 2 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/comm.c b/comm.c
index 171aead..61674c3 100644
--- a/comm.c
+++ b/comm.c
@@ -77,6 +77,8 @@ void comm_Read( void )
     ssize_t i_size, i_answer_size = 0;
     uint8_t p_buffer[COMM_BUFFER_SIZE], p_answer[COMM_BUFFER_SIZE];
     uint8_t i_command, i_answer;
+    uint8_t *p_packed_section;
+    unsigned int i_packed_section_size;
 
     i_size = recvfrom( i_comm_fd, p_buffer, COMM_BUFFER_SIZE, 0,
                        (struct sockaddr *)&sun_client, &sun_length );
@@ -153,6 +155,38 @@ void comm_Read( void )
         i_answer_size = 0;
         break;
 
+    case CMD_GET_PAT:
+    case CMD_GET_CAT:
+    case CMD_GET_NIT:
+    case CMD_GET_SDT:
+    {
+#define CASE_TABLE(x) \
+        case CMD_GET_##x: \
+        { \
+            i_answer = RET_##x; \
+            p_packed_section = demux_get_current_packed_##x(&i_packed_section_size); \
+            break; \
+        }
+        switch ( i_command )
+        {
+            CASE_TABLE(PAT)
+            CASE_TABLE(CAT)
+            CASE_TABLE(NIT)
+            CASE_TABLE(SDT)
+        }
+#undef CASE_TABLE
+
+        if ( p_packed_section && i_packed_section_size )
+        {
+            i_answer_size = i_packed_section_size;
+            memcpy( p_answer + COMM_HEADER_SIZE, p_packed_section, i_packed_section_size );
+            free( p_packed_section );
+        } else {
+            i_answer = RET_NODATA;
+        }
+
+        break;
+    }
     default:
         msg_Err( NULL, "wrong command %u", i_command );
         i_answer = RET_HUH;
diff --git a/comm.h b/comm.h
index 017a96d..58f8828 100644
--- a/comm.h
+++ b/comm.h
@@ -19,8 +19,10 @@
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/ca.h>
 
-#define COMM_BUFFER_SIZE 4096
+#include <bitstream/mpeg/psi.h>
+
 #define COMM_HEADER_SIZE 4
+#define COMM_BUFFER_SIZE (COMM_HEADER_SIZE + ((PSI_PRIVATE_MAX_SIZE + PSI_HEADER_SIZE) * PSI_TABLE_MAX_SECTIONS))
 #define COMM_HEADER_MAGIC 0x48
 
 #define CMD_RELOAD 1
@@ -32,6 +34,10 @@
 #define CMD_MMI_CLOSE 7 /* arg: slot */
 #define CMD_MMI_RECV 8 /* arg: slot */
 #define CMD_MMI_SEND 9 /* arg: slot, en50221_mmi_object_t */
+#define CMD_GET_PAT 10
+#define CMD_GET_CAT 11
+#define CMD_GET_NIT 12
+#define CMD_GET_SDT 13
 
 #define RET_OK 0
 #define RET_ERR 1
@@ -40,6 +46,11 @@
 #define RET_MMI_SLOT_STATUS 4
 #define RET_MMI_RECV 5
 #define RET_MMI_WAIT 6
+#define RET_NODATA 7
+#define RET_PAT 8
+#define RET_CAT 9
+#define RET_NIT 10
+#define RET_SDT 11
 #define RET_HUH 255
 
 struct ret_frontend_status
-- 
1.7.5.1



More information about the dvblast-devel mailing list