Commit 3fcdfd41 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

DVB: privatize scan_t

parent 5b15af4f
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
# include <dvbpsi/sdt.h> # include <dvbpsi/sdt.h>
#include "dvb.h" #include "dvb.h"
#include "scan.h"
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -338,8 +339,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -338,8 +339,8 @@ static int Open( vlc_object_t *p_this )
} }
/* */ /* */
p_sys->b_scan_mode = var_GetInteger( p_access, "dvb-frequency" ) == 0; bool b_scan_mode = var_GetInteger( p_access, "dvb-frequency" ) == 0;
if( p_sys->b_scan_mode ) if( b_scan_mode )
{ {
msg_Dbg( p_access, "DVB scan mode selected" ); msg_Dbg( p_access, "DVB scan mode selected" );
p_access->pf_block = BlockScan; p_access->pf_block = BlockScan;
...@@ -364,9 +365,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -364,9 +365,10 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( p_sys->b_scan_mode ) if( b_scan_mode )
{ {
scan_parameter_t parameter; scan_parameter_t parameter;
scan_t *p_scan;
msg_Dbg( p_access, "setting filter on PAT/NIT/SDT (DVB only)" ); msg_Dbg( p_access, "setting filter on PAT/NIT/SDT (DVB only)" );
FilterSet( p_access, 0x00, OTHER_TYPE ); // PAT FilterSet( p_access, 0x00, OTHER_TYPE ); // PAT
...@@ -374,11 +376,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -374,11 +376,13 @@ static int Open( vlc_object_t *p_this )
FilterSet( p_access, 0x11, OTHER_TYPE ); // SDT FilterSet( p_access, 0x11, OTHER_TYPE ); // SDT
if( FrontendGetScanParameter( p_access, &parameter ) || if( FrontendGetScanParameter( p_access, &parameter ) ||
scan_Init( VLC_OBJECT(p_access), &p_sys->scan, &parameter ) ) (p_scan = scan_New( VLC_OBJECT(p_access), &parameter )) == NULL )
{ {
Close( VLC_OBJECT(p_access) ); Close( VLC_OBJECT(p_access) );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_sys->scan = p_scan;
p_sys->i_read_once = DVB_READ_ONCE_SCAN;
} }
else else
{ {
...@@ -387,11 +391,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -387,11 +391,13 @@ static int Open( vlc_object_t *p_this )
{ {
msg_Dbg( p_access, "setting filter on all PIDs" ); msg_Dbg( p_access, "setting filter on all PIDs" );
FilterSet( p_access, 0x2000, OTHER_TYPE ); FilterSet( p_access, 0x2000, OTHER_TYPE );
p_sys->i_read_once = DVB_READ_ONCE;
} }
else else
{ {
msg_Dbg( p_access, "setting filter on PAT" ); msg_Dbg( p_access, "setting filter on PAT" );
FilterSet( p_access, 0x0, OTHER_TYPE ); FilterSet( p_access, 0x0, OTHER_TYPE );
p_sys->i_read_once = DVB_READ_ONCE_START;
} }
CAMOpen( p_access ); CAMOpen( p_access );
...@@ -401,15 +407,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -401,15 +407,8 @@ static int Open( vlc_object_t *p_this )
#endif #endif
} }
if( p_sys->b_scan_mode )
p_sys->i_read_once = DVB_READ_ONCE_SCAN;
else if( p_sys->b_budget_mode )
p_sys->i_read_once = DVB_READ_ONCE;
else
p_sys->i_read_once = DVB_READ_ONCE_START;
free( p_access->psz_demux ); free( p_access->psz_demux );
p_access->psz_demux = strdup( p_sys->b_scan_mode ? "m3u8" : "ts" ); p_access->psz_demux = strdup( p_sys->scan ? "m3u8" : "ts" );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -421,19 +420,19 @@ static void Close( vlc_object_t *p_this ) ...@@ -421,19 +420,19 @@ static void Close( vlc_object_t *p_this )
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
FilterUnset( p_access, p_sys->b_budget_mode && !p_sys->b_scan_mode ? 1 : MAX_DEMUX ); FilterUnset( p_access, p_sys->b_budget_mode && !p_sys->scan ? 1 : MAX_DEMUX );
DVRClose( p_access ); DVRClose( p_access );
FrontendClose( p_access ); FrontendClose( p_access );
if( p_sys->b_scan_mode ) if( p_sys->scan != NULL )
scan_Clean( &p_sys->scan ); scan_Destroy( p_sys->scan );
else else
{
CAMClose( p_access ); CAMClose( p_access );
#ifdef ENABLE_HTTPD #ifdef ENABLE_HTTPD
if( !p_sys->b_scan_mode )
HTTPClose( p_access ); HTTPClose( p_access );
#endif #endif
}
free( p_sys ); free( p_sys );
} }
...@@ -554,14 +553,10 @@ static block_t *Block( access_t *p_access ) ...@@ -554,14 +553,10 @@ static block_t *Block( access_t *p_access )
static block_t *BlockScan( access_t *p_access ) static block_t *BlockScan( access_t *p_access )
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
scan_t *p_scan = &p_sys->scan; scan_t *p_scan = p_sys->scan;
scan_configuration_t cfg; scan_configuration_t cfg;
scan_session_t session; scan_session_t session;
/* set satellite config file path */
if( p_scan->parameter.type == SCAN_DVB_S )
p_scan->parameter.sat_info.psz_name = var_GetString( p_access, "dvb-satellite" );
/* */ /* */
if( scan_Next( p_scan, &cfg ) ) if( scan_Next( p_scan, &cfg ) )
{ {
...@@ -581,23 +576,15 @@ static block_t *BlockScan( access_t *p_access ) ...@@ -581,23 +576,15 @@ static block_t *BlockScan( access_t *p_access )
return NULL; return NULL;
/* */ /* */
if( p_scan->parameter.type == SCAN_DVB_S ) msg_Dbg( p_access, "Scanning frequency %d", cfg.i_frequency );
{
msg_Dbg( p_access,
"Scanning frequency %d, symbol rate = %d, fec = %d",
cfg.i_frequency,
cfg.i_bandwidth,
cfg.i_fec );
}
else
msg_Dbg( p_access, "Scanning frequency %d, bandwidth = %d",
cfg.i_frequency,
cfg.i_bandwidth );
var_SetInteger( p_access, "dvb-frequency", cfg.i_frequency ); var_SetInteger( p_access, "dvb-frequency", cfg.i_frequency );
msg_Dbg( p_access, " bandwidth %d", cfg.i_bandwidth );
var_SetInteger( p_access, "dvb-bandwidth", cfg.i_bandwidth ); var_SetInteger( p_access, "dvb-bandwidth", cfg.i_bandwidth );
if ( cfg.i_fec ) if ( cfg.i_fec )
{
msg_Dbg( p_access, " FEC %d", cfg.i_fec );
var_SetInteger( p_access, "dvb-fec", cfg.i_fec ); var_SetInteger( p_access, "dvb-fec", cfg.i_fec );
}
if ( cfg.c_polarization ) if ( cfg.c_polarization )
var_SetInteger( p_access, "dvb-voltage", cfg.c_polarization == 'H' ? 18 : 13 ); var_SetInteger( p_access, "dvb-voltage", cfg.c_polarization == 'H' ? 18 : 13 );
...@@ -766,7 +753,7 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -766,7 +753,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
return VLC_SUCCESS; return VLC_SUCCESS;
case ACCESS_SET_PRIVATE_ID_STATE: case ACCESS_SET_PRIVATE_ID_STATE:
if( p_sys->b_scan_mode ) if( p_sys->scan )
return VLC_EGENERIC; return VLC_EGENERIC;
i_int = (int)va_arg( args, int ); /* Private data (pid for now)*/ i_int = (int)va_arg( args, int ); /* Private data (pid for now)*/
...@@ -782,7 +769,7 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -782,7 +769,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
break; break;
case ACCESS_SET_PRIVATE_ID_CA: case ACCESS_SET_PRIVATE_ID_CA:
if( p_sys->b_scan_mode ) if( p_sys->scan )
return VLC_EGENERIC; return VLC_EGENERIC;
p_pmt = (dvbpsi_pmt_t *)va_arg( args, dvbpsi_pmt_t * ); p_pmt = (dvbpsi_pmt_t *)va_arg( args, dvbpsi_pmt_t * );
......
...@@ -23,9 +23,6 @@ ...@@ -23,9 +23,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#include "scan.h"
/***************************************************************************** /*****************************************************************************
* Local structures * Local structures
*****************************************************************************/ *****************************************************************************/
...@@ -51,6 +48,9 @@ typedef struct ...@@ -51,6 +48,9 @@ typedef struct
bool b_has_lock; bool b_has_lock;
} frontend_status_t; } frontend_status_t;
typedef struct scan_parameter_t scan_parameter_t;
typedef struct scan_t scan_t;
typedef struct en50221_session_t typedef struct en50221_session_t
{ {
int i_slot; int i_slot;
...@@ -145,7 +145,6 @@ struct access_sys_t ...@@ -145,7 +145,6 @@ struct access_sys_t
demux_handle_t p_demux_handles[MAX_DEMUX]; demux_handle_t p_demux_handles[MAX_DEMUX];
frontend_t *p_frontend; frontend_t *p_frontend;
bool b_budget_mode; bool b_budget_mode;
bool b_scan_mode;
/* CA management */ /* CA management */
int i_ca_handle; int i_ca_handle;
...@@ -180,7 +179,7 @@ struct access_sys_t ...@@ -180,7 +179,7 @@ struct access_sys_t
#endif #endif
/* Scan */ /* Scan */
scan_t scan; scan_t *scan;
}; };
#define VIDEO0_TYPE 1 #define VIDEO0_TYPE 1
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#endif #endif
#include "dvb.h" #include "dvb.h"
#include "scan.h"
#define DMX "/dev/dvb/adapter%d/demux%d" #define DMX "/dev/dvb/adapter%d/demux%d"
#define FRONTEND "/dev/dvb/adapter%d/frontend%d" #define FRONTEND "/dev/dvb/adapter%d/frontend%d"
...@@ -402,6 +403,8 @@ static int ScanParametersDvbS( access_t *p_access, scan_parameter_t *p_scan ) ...@@ -402,6 +403,8 @@ static int ScanParametersDvbS( access_t *p_access, scan_parameter_t *p_scan )
p_scan->frequency.i_min = p_frontend->info.frequency_min; p_scan->frequency.i_min = p_frontend->info.frequency_min;
p_scan->frequency.i_max = p_frontend->info.frequency_max; p_scan->frequency.i_max = p_frontend->info.frequency_max;
/* set satellite config file path */
p_scan->sat_info.psz_name = var_InheritString( p_access, "dvb-satellite" );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -410,7 +413,6 @@ static int ScanParametersDvbC( access_t *p_access, scan_parameter_t *p_scan ) ...@@ -410,7 +413,6 @@ static int ScanParametersDvbC( access_t *p_access, scan_parameter_t *p_scan )
{ {
const frontend_t *p_frontend = p_access->p_sys->p_frontend; const frontend_t *p_frontend = p_access->p_sys->p_frontend;
memset( p_scan, 0, sizeof(*p_scan) ); memset( p_scan, 0, sizeof(*p_scan) );
p_scan->type = SCAN_DVB_C; p_scan->type = SCAN_DVB_C;
p_scan->b_exhaustive = false; p_scan->b_exhaustive = false;
...@@ -434,7 +436,6 @@ static int ScanParametersDvbT( access_t *p_access, scan_parameter_t *p_scan ) ...@@ -434,7 +436,6 @@ static int ScanParametersDvbT( access_t *p_access, scan_parameter_t *p_scan )
{ {
const frontend_t *p_frontend = p_access->p_sys->p_frontend; const frontend_t *p_frontend = p_access->p_sys->p_frontend;
memset( p_scan, 0, sizeof(*p_scan) ); memset( p_scan, 0, sizeof(*p_scan) );
p_scan->type = SCAN_DVB_T; p_scan->type = SCAN_DVB_T;
p_scan->b_exhaustive = false; p_scan->b_exhaustive = false;
......
...@@ -46,6 +46,19 @@ ...@@ -46,6 +46,19 @@
# include <dvbpsi/sdt.h> # include <dvbpsi/sdt.h>
#include "dvb.h" #include "dvb.h"
#include "scan.h"
struct scan_t
{
vlc_object_t *p_obj;
struct dialog_progress_bar_t *p_dialog;
int64_t i_index;
scan_parameter_t parameter;
int64_t i_time_start;
int i_service;
scan_service_t **pp_service;
};
/* */ /* */
scan_service_t *scan_service_New( int i_program, const scan_configuration_t *p_cfg ) scan_service_t *scan_service_New( int i_program, const scan_configuration_t *p_cfg )
...@@ -77,7 +90,7 @@ void scan_service_Delete( scan_service_t *p_srv ) ...@@ -77,7 +90,7 @@ void scan_service_Delete( scan_service_t *p_srv )
} }
/* */ /* */
int scan_Init( vlc_object_t *p_obj, scan_t *p_scan, const scan_parameter_t *p_parameter ) scan_t *scan_New( vlc_object_t *p_obj, const scan_parameter_t *p_parameter )
{ {
if( p_parameter->type == SCAN_DVB_T ) if( p_parameter->type == SCAN_DVB_T )
{ {
...@@ -104,11 +117,15 @@ int scan_Init( vlc_object_t *p_obj, scan_t *p_scan, const scan_parameter_t *p_pa ...@@ -104,11 +117,15 @@ int scan_Init( vlc_object_t *p_obj, scan_t *p_scan, const scan_parameter_t *p_pa
} }
else else
{ {
return VLC_EGENERIC; return NULL;
} }
msg_Dbg( p_obj, " - use NIT %s", p_parameter->b_use_nit ? "on" : "off" ); msg_Dbg( p_obj, " - use NIT %s", p_parameter->b_use_nit ? "on" : "off" );
msg_Dbg( p_obj, " - FTA only %s", p_parameter->b_free_only ? "on" : "off" ); msg_Dbg( p_obj, " - FTA only %s", p_parameter->b_free_only ? "on" : "off" );
scan_t *p_scan = malloc( sizeof( *p_scan ) );
if( unlikely(p_scan == NULL) )
return NULL;
p_scan->p_obj = VLC_OBJECT(p_obj); p_scan->p_obj = VLC_OBJECT(p_obj);
p_scan->i_index = 0; p_scan->i_index = 0;
p_scan->p_dialog = NULL; p_scan->p_dialog = NULL;
...@@ -116,10 +133,10 @@ int scan_Init( vlc_object_t *p_obj, scan_t *p_scan, const scan_parameter_t *p_pa ...@@ -116,10 +133,10 @@ int scan_Init( vlc_object_t *p_obj, scan_t *p_scan, const scan_parameter_t *p_pa
p_scan->parameter = *p_parameter; p_scan->parameter = *p_parameter;
p_scan->i_time_start = mdate(); p_scan->i_time_start = mdate();
return VLC_SUCCESS; return p_scan;
} }
void scan_Clean( scan_t *p_scan ) void scan_Destroy( scan_t *p_scan )
{ {
if( p_scan->p_dialog != NULL ) if( p_scan->p_dialog != NULL )
dialog_ProgressDestroy( p_scan->p_dialog ); dialog_ProgressDestroy( p_scan->p_dialog );
...@@ -127,6 +144,7 @@ void scan_Clean( scan_t *p_scan ) ...@@ -127,6 +144,7 @@ void scan_Clean( scan_t *p_scan )
for( int i = 0; i < p_scan->i_service; i++ ) for( int i = 0; i < p_scan->i_service; i++ )
scan_service_Delete( p_scan->pp_service[i] ); scan_service_Delete( p_scan->pp_service[i] );
TAB_CLEAN( p_scan->i_service, p_scan->pp_service ); TAB_CLEAN( p_scan->i_service, p_scan->pp_service );
free( p_scan );
} }
static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos ) static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos )
......
...@@ -46,7 +46,7 @@ typedef struct ...@@ -46,7 +46,7 @@ typedef struct
char c_polarization; char c_polarization;
} scan_dvbs_transponder_t; } scan_dvbs_transponder_t;
typedef struct struct scan_parameter_t
{ {
scan_type_t type; scan_type_t type;
bool b_exhaustive; bool b_exhaustive;
...@@ -80,8 +80,7 @@ typedef struct ...@@ -80,8 +80,7 @@ typedef struct
scan_dvbs_transponder_t *p_transponders; scan_dvbs_transponder_t *p_transponders;
int i_count; int i_count;
} sat_info; } sat_info;
};
} scan_parameter_t;
typedef struct typedef struct
{ {
...@@ -143,24 +142,11 @@ typedef struct ...@@ -143,24 +142,11 @@ typedef struct
} scan_session_t; } scan_session_t;
typedef struct
{
vlc_object_t *p_obj;
struct dialog_progress_bar_t *p_dialog;
int64_t i_index;
scan_parameter_t parameter;
int64_t i_time_start;
int i_service;
scan_service_t **pp_service;
} scan_t;
scan_service_t *scan_service_New( int i_program, const scan_configuration_t *p_cfg ); scan_service_t *scan_service_New( int i_program, const scan_configuration_t *p_cfg );
void scan_service_Delete( scan_service_t *p_srv ); void scan_service_Delete( scan_service_t *p_srv );
int scan_Init( vlc_object_t *p_obj, scan_t *p_scan, const scan_parameter_t *p_parameter ); scan_t *scan_New( vlc_object_t *p_obj, const scan_parameter_t *p_parameter );
void scan_Clean( scan_t *p_scan ); void scan_Destroy( scan_t *p_scan );
int scan_Next( scan_t *p_scan, scan_configuration_t *p_cfg ); int scan_Next( scan_t *p_scan, scan_configuration_t *p_cfg );
......
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