[dvblast-devel] comm: Allow command socket to work with ASI and UDP inputs.

Georgi Chorbadzhiyski git at videolan.org
Tue Sep 13 11:29:26 CEST 2011


dvblast | branch: master | Georgi Chorbadzhiyski <gf at unixsol.org> | Mon Sep 12 21:07:04 2011 +0300| [f0109a028910a0b2622f982f063c9e0fa50ae8fe] | committer: Georgi Chorbadzhiyski

comm: Allow command socket to work with ASI and UDP inputs.

Previously cmd socket worked only with DVB input. That was ok
since there were no commands (well except SHUTDOWN and RELOAD)
that were useful without DVB input. Now that lots of commands
were added to deal with input stream, this patch allows cmd
socket to be used with any input (ASI, DVB and UDP). DVB only
commands are ignored when there is no DVB input used.

Signed-off-by: Georgi Chorbadzhiyski <gf at unixsol.org>

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

 NEWS      |    2 ++
 asi.c     |   23 ++++++++++++++++-------
 comm.c    |   18 ++++++++++++++++++
 dvblast.c |   15 ---------------
 udp.c     |   21 +++++++++++++++------
 5 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/NEWS b/NEWS
index e3d200b..d085f9b 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,8 @@ Changes between 1.2 and 2.0:
   * Add support for getting PMT table for chosen service in dvblastctl
   * Add support for getting PID information (bps, error counters and more)
   * Add support for setting service name and provider name per output
+  * Command socket is usable with any input (ASI, DVB, UDP), previously
+    only DVB input worked
 
 Changes between 1.1 and 1.2:
 ----------------------------
diff --git a/asi.c b/asi.c
index d4ea1e7..bc0a43e 100644
--- a/asi.c
+++ b/asi.c
@@ -173,13 +173,19 @@ void asi_Open( void )
  *****************************************************************************/
 block_t *asi_Read( mtime_t i_poll_timeout )
 {
-    struct pollfd pfd;
-    int i_ret;
+    struct pollfd pfd[2];
+    int i_ret, i_nb_fd = 1;
 
-    pfd.fd = i_handle;
-    pfd.events = POLLIN | POLLPRI;
+    pfd[0].fd = i_handle;
+    pfd[0].events = POLLIN;
+    if ( i_comm_fd != -1 )
+    {
+        pfd[1].fd = i_comm_fd;
+        pfd[1].events = POLLIN;
+        i_nb_fd++;
+    }
 
-    i_ret = poll( &pfd, 1, (i_poll_timeout + 999) / 1000 );
+    i_ret = poll( pfd, i_nb_fd, (i_poll_timeout + 999) / 1000 );
 
     i_wallclock = mdate();
 
@@ -191,7 +197,7 @@ block_t *asi_Read( mtime_t i_poll_timeout )
         return NULL;
     }
 
-    if ( (pfd.revents & POLLPRI) )
+    if ( (pfd[0].revents & POLLPRI) )
     {
         unsigned int i_val;
 
@@ -214,7 +220,7 @@ block_t *asi_Read( mtime_t i_poll_timeout )
         }
     }
 
-    if ( (pfd.revents & POLLIN) )
+    if ( (pfd[0].revents & POLLIN) )
     {
         struct iovec p_iov[i_bufsize / TS_SIZE];
         block_t *p_ts, **pp_current = &p_ts;
@@ -274,6 +280,9 @@ block_t *asi_Read( mtime_t i_poll_timeout )
         i_last_packet = 0;
     }
 
+    if ( i_comm_fd != -1 && pfd[1].revents )
+        comm_Read();
+
     return NULL;
 }
 
diff --git a/comm.c b/comm.c
index 4e7891d..522627c 100644
--- a/comm.c
+++ b/comm.c
@@ -103,6 +103,23 @@ void comm_Read( void )
 
     i_command = p_buffer[1];
 
+    if ( i_frequency == 0 ) /* ASI or UDP, disable DVB only commands */
+    {
+        switch ( i_command )
+        {
+            case CMD_FRONTEND_STATUS:
+            case CMD_MMI_STATUS:
+            case CMD_MMI_SLOT_STATUS:
+            case CMD_MMI_OPEN:
+            case CMD_MMI_CLOSE:
+            case CMD_MMI_RECV:
+            case CMD_MMI_SEND:
+                i_answer = RET_NODATA;
+                i_answer_size = 0;
+                goto return_answer;
+        }
+    }
+
     switch ( i_command )
     {
     case CMD_RELOAD:
@@ -253,6 +270,7 @@ void comm_Read( void )
         break;
     }
 
+ return_answer:
     p_answer[0] = COMM_HEADER_MAGIC;
     p_answer[1] = i_answer;
     p_answer[2] = 0;
diff --git a/dvblast.c b/dvblast.c
index 2c6d03e..93a2dea 100644
--- a/dvblast.c
+++ b/dvblast.c
@@ -632,11 +632,6 @@ int main( int i_argc, char **pp_argv )
             break;
 
         case 'r':
-            if ( pf_Open != dvb_Open && pf_Open != NULL )
-            {
-                msg_Err( NULL, "-r is only available for linux-dvb input" );
-                usage();
-            }
             psz_srv_socket = optarg;
             break;
 
@@ -764,11 +759,6 @@ int main( int i_argc, char **pp_argv )
             psz_udp_src = optarg;
             if ( pf_Open != NULL )
                 usage();
-            if ( psz_srv_socket != NULL )
-            {
-                msg_Err( NULL, "-r is only available for linux-dvb input" );
-                usage();
-            }
             pf_Open = udp_Open;
             pf_Read = udp_Read;
             pf_Reset = udp_Reset;
@@ -780,11 +770,6 @@ int main( int i_argc, char **pp_argv )
             i_asi_adapter = strtol( optarg, NULL, 0 );
             if ( pf_Open != NULL )
                 usage();
-            if ( psz_srv_socket != NULL )
-            {
-                msg_Err( NULL, "-r is only available for linux-dvb input" );
-                usage();
-            }
             pf_Open = asi_Open;
             pf_Read = asi_Read;
             pf_Reset = asi_Reset;
diff --git a/udp.c b/udp.c
index b95263c..92f69b8 100644
--- a/udp.c
+++ b/udp.c
@@ -240,13 +240,19 @@ void udp_Open( void )
  *****************************************************************************/
 block_t *udp_Read( mtime_t i_poll_timeout )
 {
-    struct pollfd pfd;
-    int i_ret;
+    struct pollfd pfd[2];
+    int i_ret, i_nb_fd = 1;
 
-    pfd.fd = i_handle;
-    pfd.events = POLLIN;
+    pfd[0].fd = i_handle;
+    pfd[0].events = POLLIN;
+    if ( i_comm_fd != -1 )
+    {
+        pfd[1].fd = i_comm_fd;
+        pfd[1].events = POLLIN;
+        i_nb_fd++;
+    }
 
-    i_ret = poll( &pfd, 1, (i_poll_timeout + 999) / 1000 );
+    i_ret = poll( pfd, i_nb_fd, (i_poll_timeout + 999) / 1000 );
 
     i_wallclock = mdate();
 
@@ -258,7 +264,7 @@ block_t *udp_Read( mtime_t i_poll_timeout )
         return NULL;
     }
 
-    if ( pfd.revents )
+    if ( pfd[0].revents )
     {
         struct iovec p_iov[i_block_cnt + 1];
         block_t *p_ts, **pp_current = &p_ts;
@@ -365,6 +371,9 @@ err:
         i_last_packet = 0;
     }
 
+    if ( i_comm_fd != -1 && pfd[1].revents )
+        comm_Read();
+
     return NULL;
 }
 



More information about the dvblast-devel mailing list