Commit a5c43591 authored by massiot's avatar massiot

* udp.c: New input for DVBlast : UDP instead of linux-dvb (-D).

 * ALL: Virtualize the input functions to allow multiple input modules.


git-svn-id: svn://svn.videolan.org/dvblast/trunk@82 55d3f8b6-4a41-4d2d-a900-313d1436a5b8
parent a684ad3c
......@@ -6,7 +6,7 @@ CFLAGS += -g
CFLAGS += -I/usr/src/kernel/linux-2.6.29.1/include
LDFLAGS_DVBLAST += -ldvbpsi -lpthread
OBJ_DVBLAST = dvblast.o util.o dvb.o demux.o output.o en50221.o comm.o
OBJ_DVBLAST = dvblast.o util.o dvb.o udp.o demux.o output.o en50221.o comm.o
OBJ_DVBLASTCTL = util.o dvblastctl.o
all: dvblast dvblastctl
......
/*****************************************************************************
* comm.c
* comm.c: Handles the communication socket (linux-dvb only)
*****************************************************************************
* Copyright (C) 2008 VideoLAN
* $Id$
......
......@@ -117,7 +117,7 @@ void demux_Open( void )
memset( p_pids, 0, sizeof(p_pids) );
dvb_Open();
pf_Open();
for ( i = 0; i < 8192; i++ )
{
......@@ -126,7 +126,7 @@ void demux_Open( void )
}
if ( b_budget_mode )
i_demux_fd = dvb_SetFilter(8192);
i_demux_fd = pf_SetFilter(8192);
SetPID(PAT_PID); /* PAT */
p_pat_dvbpsi_handle = dvbpsi_AttachPAT( PATCallback, NULL );
......@@ -148,7 +148,7 @@ void demux_Open( void )
*****************************************************************************/
void demux_Run( void )
{
block_t *p_ts = dvb_Read();
block_t *p_ts = pf_Read();
while ( p_ts != NULL )
{
......@@ -442,7 +442,7 @@ static void SetPID( uint16_t i_pid )
if ( !b_budget_mode && p_pids[i_pid].i_refcount
&& p_pids[i_pid].i_demux_fd == -1 )
p_pids[i_pid].i_demux_fd = dvb_SetFilter( i_pid );
p_pids[i_pid].i_demux_fd = pf_SetFilter( i_pid );
}
static void UnsetPID( uint16_t i_pid )
......@@ -452,7 +452,7 @@ static void UnsetPID( uint16_t i_pid )
if ( !b_budget_mode && !p_pids[i_pid].i_refcount
&& p_pids[i_pid].i_demux_fd != -1 )
{
dvb_UnsetFilter( p_pids[i_pid].i_demux_fd, i_pid );
pf_UnsetFilter( p_pids[i_pid].i_demux_fd, i_pid );
p_pids[i_pid].i_demux_fd = -1;
}
}
......
/*****************************************************************************
* dvb.c
* dvb.c: linux-dvb input for DVBlast
*****************************************************************************
* Copyright (C) 2008-2009 VideoLAN
* $Id$
......
......@@ -63,6 +63,14 @@ int b_enable_epg = 0;
int b_unique_tsid = 0;
volatile int b_hup_received = 0;
int i_verbose = DEFAULT_VERBOSITY;
uint16_t i_src_port = DEFAULT_PORT;
in_addr_t i_src_addr = { 0 };
int b_src_rawudp = 0;
void (*pf_Open)( void ) = NULL;
block_t * (*pf_Read)( void ) = NULL;
int (*pf_SetFilter)( uint16_t i_pid ) = NULL;
void (*pf_UnsetFilter)( int i_fd, uint16_t i_pid ) = NULL;
/*****************************************************************************
* Configuration files
......@@ -211,7 +219,7 @@ static void DisplayVersion()
*****************************************************************************/
void usage()
{
msg_Raw( NULL, "Usage: dvblast [-q] [-c <config file>] [-r <remote socket>] [-t <ttl>] [-o <SSRC IP>] [-i <RT priority>] [-a <adapter>] [-n <frontend number>] [-S <diseqc>] -f <frequency> [-s <symbol rate>] [-v <0|13|18>] [-p] [-b <bandwidth>] [-m <modulation] [-u] [-W] [-U] [-d <dest IP:port>] [-e] [-T]" );
msg_Raw( NULL, "Usage: dvblast [-q] [-c <config file>] [-r <remote socket>] [-t <ttl>] [-o <SSRC IP>] [-i <RT priority>] [-a <adapter>] [-n <frontend number>] [-S <diseqc>] [-f <frequency>|-D <src mcast>:<port>] [-s <symbol rate>] [-v <0|13|18>] [-p] [-b <bandwidth>] [-m <modulation] [-u] [-W] [-U] [-d <dest IP:port>] [-e] [-T]" );
msg_Raw( NULL, " -q: be quiet (less verbosity, repeat or use number for even quieter)" );
msg_Raw( NULL, " -v: voltage to apply to the LNB (QPSK)" );
msg_Raw( NULL, " -p: force 22kHz pulses for high-band selection (DVB-S)" );
......@@ -223,6 +231,7 @@ void usage()
msg_Raw( NULL, " -W: add extra delays for slow CAMs" );
msg_Raw( NULL, " -U: use raw UDP rather than RTP (required by some IPTV set top boxes)" );
msg_Raw( NULL, " -d: duplicate all received packets to a given destination" );
msg_Raw( NULL, " -D: read packets from a multicast address instead of a DVB card" );
msg_Raw( NULL, " -e: enable EPG pass through (EIT data)" );
msg_Raw( NULL, " -T: generate unique TS ID for each program" );
msg_Raw( NULL, " -h: display this full help" );
......@@ -241,7 +250,7 @@ int main( int i_argc, char **pp_argv )
if ( i_argc == 1 )
usage();
while ( ( c = getopt(i_argc, pp_argv, "q::c:r:t:o:i:a:n:f:s:S:v:pb:m:uWUTd:ehV")) != -1 )
while ( ( c = getopt(i_argc, pp_argv, "q::c:r:t:o:i:a:n:f:s:S:v:pb:m:uWUTd:D:ehV")) != -1 )
{
switch ( c )
{
......@@ -273,6 +282,11 @@ 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;
......@@ -303,6 +317,12 @@ int main( int i_argc, char **pp_argv )
case 'f':
i_frequency = strtol( optarg, NULL, 0 );
if ( pf_Open != NULL )
usage();
pf_Open = dvb_Open;
pf_Read = dvb_Read;
pf_SetFilter = dvb_SetFilter;
pf_UnsetFilter = dvb_UnsetFilter;
break;
case 's':
......@@ -357,6 +377,39 @@ int main( int i_argc, char **pp_argv )
break;
}
case 'D':
{
char *psz_token;
struct in_addr maddr;
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_SetFilter = udp_SetFilter;
pf_UnsetFilter = udp_UnsetFilter;
if ( (psz_token = strrchr( optarg, '/' )) != NULL )
{
*psz_token = '\0';
b_src_rawudp = ( strncasecmp( psz_token + 1, "udp", 3 ) == 0 );
}
if ( (psz_token = strrchr( optarg, ':' )) != NULL )
{
*psz_token = '\0';
i_src_port = atoi( psz_token + 1 );
}
if ( !inet_aton( optarg, &maddr ) )
usage();
i_src_addr = maddr.s_addr;
break;
}
case 'e':
b_enable_epg = 1;
break;
......
......@@ -102,6 +102,14 @@ extern int b_unique_tsid;
extern volatile int b_hup_received;
extern mtime_t i_ca_timeout;
extern int i_comm_fd;
extern uint16_t i_src_port;
extern in_addr_t i_src_addr;
extern int b_src_rawudp;
extern void (*pf_Open)( void );
extern block_t * (*pf_Read)( void );
extern int (*pf_SetFilter)( uint16_t i_pid );
extern void (*pf_UnsetFilter)( int i_fd, uint16_t i_pid );
/*****************************************************************************
* Prototypes
......@@ -121,6 +129,11 @@ int dvb_SetFilter( uint16_t i_pid );
void dvb_UnsetFilter( int i_fd, uint16_t i_pid );
uint8_t dvb_FrontendStatus( uint8_t *p_answer, ssize_t *pi_size );
void udp_Open( void );
block_t * udp_Read( void );
int udp_SetFilter( uint16_t i_pid );
void udp_UnsetFilter( int i_fd, uint16_t i_pid );
void demux_Open( void );
void demux_Run( void );
void demux_Change( output_t *p_output, uint16_t i_sid,
......
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