Commit f0109a02 authored by Georgi Chorbadzhiyski's avatar 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: default avatarGeorgi Chorbadzhiyski <gf@unixsol.org>
parent e87ccbbb
...@@ -21,6 +21,8 @@ Changes between 1.2 and 2.0: ...@@ -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 PMT table for chosen service in dvblastctl
* Add support for getting PID information (bps, error counters and more) * Add support for getting PID information (bps, error counters and more)
* Add support for setting service name and provider name per output * 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: Changes between 1.1 and 1.2:
---------------------------- ----------------------------
......
...@@ -173,13 +173,19 @@ void asi_Open( void ) ...@@ -173,13 +173,19 @@ void asi_Open( void )
*****************************************************************************/ *****************************************************************************/
block_t *asi_Read( mtime_t i_poll_timeout ) block_t *asi_Read( mtime_t i_poll_timeout )
{ {
struct pollfd pfd; struct pollfd pfd[2];
int i_ret; int i_ret, i_nb_fd = 1;
pfd.fd = i_handle; pfd[0].fd = i_handle;
pfd.events = POLLIN | POLLPRI; 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(); i_wallclock = mdate();
...@@ -191,7 +197,7 @@ block_t *asi_Read( mtime_t i_poll_timeout ) ...@@ -191,7 +197,7 @@ block_t *asi_Read( mtime_t i_poll_timeout )
return NULL; return NULL;
} }
if ( (pfd.revents & POLLPRI) ) if ( (pfd[0].revents & POLLPRI) )
{ {
unsigned int i_val; unsigned int i_val;
...@@ -214,7 +220,7 @@ block_t *asi_Read( mtime_t i_poll_timeout ) ...@@ -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]; struct iovec p_iov[i_bufsize / TS_SIZE];
block_t *p_ts, **pp_current = &p_ts; block_t *p_ts, **pp_current = &p_ts;
...@@ -274,6 +280,9 @@ block_t *asi_Read( mtime_t i_poll_timeout ) ...@@ -274,6 +280,9 @@ block_t *asi_Read( mtime_t i_poll_timeout )
i_last_packet = 0; i_last_packet = 0;
} }
if ( i_comm_fd != -1 && pfd[1].revents )
comm_Read();
return NULL; return NULL;
} }
......
...@@ -103,6 +103,23 @@ void comm_Read( void ) ...@@ -103,6 +103,23 @@ void comm_Read( void )
i_command = p_buffer[1]; 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 ) switch ( i_command )
{ {
case CMD_RELOAD: case CMD_RELOAD:
...@@ -253,6 +270,7 @@ void comm_Read( void ) ...@@ -253,6 +270,7 @@ void comm_Read( void )
break; break;
} }
return_answer:
p_answer[0] = COMM_HEADER_MAGIC; p_answer[0] = COMM_HEADER_MAGIC;
p_answer[1] = i_answer; p_answer[1] = i_answer;
p_answer[2] = 0; p_answer[2] = 0;
......
...@@ -632,11 +632,6 @@ int main( int i_argc, char **pp_argv ) ...@@ -632,11 +632,6 @@ int main( int i_argc, char **pp_argv )
break; break;
case 'r': 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; psz_srv_socket = optarg;
break; break;
...@@ -764,11 +759,6 @@ int main( int i_argc, char **pp_argv ) ...@@ -764,11 +759,6 @@ int main( int i_argc, char **pp_argv )
psz_udp_src = optarg; psz_udp_src = optarg;
if ( pf_Open != NULL ) if ( pf_Open != NULL )
usage(); usage();
if ( psz_srv_socket != NULL )
{
msg_Err( NULL, "-r is only available for linux-dvb input" );
usage();
}
pf_Open = udp_Open; pf_Open = udp_Open;
pf_Read = udp_Read; pf_Read = udp_Read;
pf_Reset = udp_Reset; pf_Reset = udp_Reset;
...@@ -780,11 +770,6 @@ int main( int i_argc, char **pp_argv ) ...@@ -780,11 +770,6 @@ int main( int i_argc, char **pp_argv )
i_asi_adapter = strtol( optarg, NULL, 0 ); i_asi_adapter = strtol( optarg, NULL, 0 );
if ( pf_Open != NULL ) if ( pf_Open != NULL )
usage(); usage();
if ( psz_srv_socket != NULL )
{
msg_Err( NULL, "-r is only available for linux-dvb input" );
usage();
}
pf_Open = asi_Open; pf_Open = asi_Open;
pf_Read = asi_Read; pf_Read = asi_Read;
pf_Reset = asi_Reset; pf_Reset = asi_Reset;
......
...@@ -240,13 +240,19 @@ void udp_Open( void ) ...@@ -240,13 +240,19 @@ void udp_Open( void )
*****************************************************************************/ *****************************************************************************/
block_t *udp_Read( mtime_t i_poll_timeout ) block_t *udp_Read( mtime_t i_poll_timeout )
{ {
struct pollfd pfd; struct pollfd pfd[2];
int i_ret; int i_ret, i_nb_fd = 1;
pfd.fd = i_handle; pfd[0].fd = i_handle;
pfd.events = POLLIN; 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(); i_wallclock = mdate();
...@@ -258,7 +264,7 @@ block_t *udp_Read( mtime_t i_poll_timeout ) ...@@ -258,7 +264,7 @@ block_t *udp_Read( mtime_t i_poll_timeout )
return NULL; return NULL;
} }
if ( pfd.revents ) if ( pfd[0].revents )
{ {
struct iovec p_iov[i_block_cnt + 1]; struct iovec p_iov[i_block_cnt + 1];
block_t *p_ts, **pp_current = &p_ts; block_t *p_ts, **pp_current = &p_ts;
...@@ -365,6 +371,9 @@ err: ...@@ -365,6 +371,9 @@ err:
i_last_packet = 0; i_last_packet = 0;
} }
if ( i_comm_fd != -1 && pfd[1].revents )
comm_Read();
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment