Commit 9c36906f authored by Christophe Massiot's avatar Christophe Massiot

* modules/demux/ts.c, modules/access/dvb: Added support for the CAM device

  of linuxtv drivers. We currently only descramble one channel (this will
  change in the near future). Also fixed a few demux-related bugs.
parent 61c73831
......@@ -55,6 +55,7 @@ enum access_query_e
/* Special mode for access/demux communication
* XXX: avoid to use it unless you can't */
ACCESS_SET_PRIVATE_ID_STATE, /* arg1= int i_private_data, vlc_bool_t b_selected can fail */
ACCESS_SET_PRIVATE_ID_CA, /* arg1= int i_program_number, uint16_t i_vpid, uint16_t i_apid1, uint16_t i_apid2, uint16_t i_apid3, uint8_t i_length, uint8_t *p_data */
};
struct access_t
......
......@@ -61,6 +61,9 @@ static void Close( vlc_object_t *p_this );
#define DEVICE_TEXT N_("Device number to use on adapter")
#define DEVICE_LONGTEXT ""
#define CAM_TEXT N_("Use CAM")
#define CAM_LONGTEXT ""
#define FREQ_TEXT N_("Transponder/multiplex frequency")
#define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
......@@ -131,6 +134,7 @@ vlc_module_begin();
VLC_FALSE );
add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
VLC_TRUE );
add_bool( "dvb-cam", 0, NULL, CAM_TEXT, CAM_LONGTEXT, VLC_FALSE );
add_integer( "dvb-frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT,
......@@ -273,6 +277,14 @@ static int Open( vlc_object_t *p_this )
FilterSet( p_access, 0x0, OTHER_TYPE );
}
p_sys->b_cam = var_GetBool( p_access, "dvb-cam" );
if ( p_sys->b_cam )
{
msg_Dbg( p_access, "initing CAM..." );
if ( E_(CAMOpen)( p_access ) < 0 )
p_sys->b_cam = VLC_FALSE;
}
return VLC_SUCCESS;
}
......@@ -288,6 +300,10 @@ static void Close( vlc_object_t *p_this )
E_(DVRClose)( p_access );
E_(FrontendClose)( p_access );
if ( p_sys->b_cam )
E_(CAMClose)( p_access );
free( p_sys );
}
......@@ -391,6 +407,27 @@ static int Control( access_t *p_access, int i_query, va_list args )
}
break;
case ACCESS_SET_PRIVATE_ID_CA:
if ( p_sys->b_cam )
{
int i_program;
uint16_t i_vpid, i_apid1, i_apid2, i_apid3;
uint8_t i_cad_length;
uint8_t *p_cad;
i_program = (int)va_arg( args, int );
i_vpid = (int16_t)va_arg( args, int );
i_apid1 = (uint16_t)va_arg( args, int );
i_apid2 = (uint16_t)va_arg( args, int );
i_apid3 = (uint16_t)va_arg( args, int );
i_cad_length = (uint8_t)va_arg( args, int );
p_cad = (uint8_t *)va_arg( args, uint8_t * );
E_(CAMSet)( p_access, i_program, i_vpid, i_apid1, i_apid2,
i_apid3, i_cad_length, p_cad );
}
break;
default:
msg_Warn( p_access, "unimplemented query in control" );
return VLC_EGENERIC;
......@@ -475,6 +512,7 @@ static void VarInit( access_t *p_access )
/* */
var_Create( p_access, "dvb-adapter", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_access, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_access, "dvb-cam", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_access, "dvb-frequency", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_access, "dvb-inversion", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_access, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
......@@ -513,8 +551,9 @@ static int ParseMRL( access_t *p_access )
#define GET_OPTION_INT( option ) \
if ( !strncmp( psz_parser, option "=", strlen(option "=") ) ) \
{ \
val.i_int = strtol( psz_parser+strlen(option "="), &psz_parser, 0 );\
var_Set( p_access, "dvb-" option, val ); \
val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser, \
0 ); \
var_Set( p_access, "dvb-" option, val ); \
}
#define GET_OPTION_BOOL( option ) \
......@@ -522,7 +561,7 @@ static int ParseMRL( access_t *p_access )
{ \
val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser, \
0 ); \
var_Set( p_access, "dvb-" option, val ); \
var_Set( p_access, "dvb-" option, val ); \
}
/* Test for old syntax */
......@@ -539,6 +578,7 @@ static int ParseMRL( access_t *p_access )
{
GET_OPTION_INT("adapter")
else GET_OPTION_INT("device")
else GET_OPTION_BOOL("cam")
else GET_OPTION_INT("frequency")
else GET_OPTION_INT("inversion")
else GET_OPTION_BOOL("probe")
......
......@@ -51,6 +51,8 @@ struct access_sys_t
demux_handle_t p_demux_handles[MAX_DEMUX];
frontend_t *p_frontend;
vlc_bool_t b_budget_mode;
vlc_bool_t b_cam;
int i_cam_handle;
};
#define VIDEO0_TYPE 1
......@@ -74,3 +76,7 @@ int E_(DMXUnsetFilter)( access_t *, int i_fd );
int E_(DVROpen)( access_t * );
void E_(DVRClose)( access_t * );
int E_(CAMOpen)( access_t * );
int E_(CAMSet)( access_t *, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t,
uint16_t, uint8_t * );
void E_(CAMClose)( access_t * );
......@@ -46,6 +46,9 @@
#include <linux/errno.h>
#include "dvb.h"
#include "network.h"
#define DMX_BUFFER_SIZE (1024 * 1024)
/*
* Frontends
......@@ -1083,6 +1086,12 @@ int E_(DVROpen)( access_t * p_access )
return VLC_EGENERIC;
}
if ( ioctl( p_sys->i_handle, DMX_SET_BUFFER_SIZE, DMX_BUFFER_SIZE ) < 0 )
{
msg_Warn( p_access, "couldn't set DMX_BUFFER_SIZE (%s)",
strerror(errno) );
}
return VLC_SUCCESS;
}
......@@ -1096,3 +1105,76 @@ void E_(DVRClose)( access_t * p_access )
close( p_sys->i_handle );
}
/*
* CAM device
*
* This uses the external cam_set program from libdvb-0.5.4
*/
/*****************************************************************************
* CAMOpen :
*****************************************************************************/
int E_(CAMOpen)( access_t * p_access )
{
access_sys_t *p_sys = p_access->p_sys;
p_sys->i_cam_handle = net_OpenTCP( p_access, "localhost", 4711 );
if ( p_sys->i_cam_handle < 0 )
{
return -VLC_EGENERIC;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* CAMSet :
*****************************************************************************/
int E_(CAMSet)( access_t * p_access, uint16_t i_program, uint16_t i_vpid,
uint16_t i_apid1, uint16_t i_apid2, uint16_t i_apid3,
uint16_t i_cad_length, uint8_t *p_cad )
{
access_sys_t *p_sys = p_access->p_sys;
uint8_t p_str[12];
memcpy( p_str, &i_program, 2 );
memcpy( p_str + 2, &i_vpid, 2 );
memcpy( p_str + 4, &i_apid1, 2 );
memcpy( p_str + 6, &i_apid2, 2 );
memcpy( p_str + 8, &i_apid3, 2 );
memcpy( p_str + 10, &i_cad_length, 2 );
if ( net_Write( p_access, p_sys->i_cam_handle, p_str, 12 ) != 12 )
{
msg_Err( p_access, "write 1 failed (%s)", strerror(errno) );
return -VLC_EGENERIC;
}
if ( i_cad_length )
{
if ( net_Write( p_access, p_sys->i_cam_handle, p_cad, i_cad_length )
!= i_cad_length )
{
msg_Err( p_access, "write 2 failed (%s) %d", strerror(errno),
i_cad_length );
return -VLC_EGENERIC;
}
}
return VLC_SUCCESS;
}
/*****************************************************************************
* CAMClose :
*****************************************************************************/
void E_(CAMClose)( access_t * p_access )
{
access_sys_t *p_sys = p_access->p_sys;
if ( p_sys->i_cam_handle )
{
close( p_sys->i_cam_handle );
}
}
This diff is collapsed.
......@@ -394,7 +394,8 @@ static int AStreamControl( stream_t *s, int i_query, va_list args )
case STREAM_CONTROL_ACCESS:
i_int = (int) va_arg( args, int );
if( i_int != ACCESS_SET_PRIVATE_ID_STATE )
if( i_int != ACCESS_SET_PRIVATE_ID_STATE
&& i_int != ACCESS_SET_PRIVATE_ID_CA )
{
msg_Err( s, "Hey, what are you thinking ?"
"DON'T USE STREAM_CONTROL_ACCESS !!!" );
......
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