X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fdvb%2Faccess.c;h=687d9cb16254f8179189e8cd68cf084885444259;hb=f09152bc5946020f2b0d368698cc7a564eb3834e;hp=86b4ce8d90bb8fc9c24a8dba521de996d037cb6a;hpb=2cb472dba008f7d877ffe6bae9c5575253365282;p=vlc diff --git a/modules/access/dvb/access.c b/modules/access/dvb/access.c index 86b4ce8d90..687d9cb162 100644 --- a/modules/access/dvb/access.c +++ b/modules/access/dvb/access.c @@ -4,7 +4,7 @@ * Copyright (C) 1998-2005 the VideoLAN team * * Authors: Johan Bilien - * Jean-Paul Saman + * Jean-Paul Saman * Christophe Massiot * Laurent Aimar * @@ -27,8 +27,15 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include #ifdef HAVE_UNISTD_H # include @@ -36,6 +43,7 @@ #include #include +#include #include @@ -47,6 +55,8 @@ # include # include # include +# include +# include #else # include "dvbpsi.h" # include "descriptor.h" @@ -54,6 +64,8 @@ # include "tables/pmt.h" # include "descriptors/dr.h" # include "psi.h" +# include "demux.h" +# include "sdt.h" #endif #ifdef ENABLE_HTTPD @@ -70,8 +82,8 @@ static void Close( vlc_object_t *p_this ); #define CACHING_TEXT N_("Caching value in ms") #define CACHING_LONGTEXT N_( \ - "Allows you to modify the default caching value for dvb streams. This " \ - "value should be set in millisecond units." ) + "Caching value for DVB streams. This " \ + "value should be set in milliseconds." ) #define ADAPTER_TEXT N_("Adapter card to tune") #define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.") @@ -86,27 +98,27 @@ static void Close( vlc_object_t *p_this ); #define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]") #define PROBE_TEXT N_("Probe DVB card for capabilities") -#define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities.") +#define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities, you can disable this feature if you experience some trouble.") #define BUDGET_TEXT N_("Budget mode") -#define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder with a budget card.") +#define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder with a \"budget\" card.") /* Satellite */ #define SATNO_TEXT N_("Satellite number in the Diseqc system") -#define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=satellite number]") +#define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=satellite number].") #define VOLTAGE_TEXT N_("LNB voltage") -#define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal]") +#define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal].") #define HIGH_VOLTAGE_TEXT N_("High LNB voltage") #define HIGH_VOLTAGE_LONGTEXT N_("Enable high voltage if your cables are " \ "particularly long. This is not supported by all frontends.") #define TONE_TEXT N_("22 kHz tone") -#define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto]") +#define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto].") #define FEC_TEXT N_("Transponder FEC") -#define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto]") +#define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto].") #define SRATE_TEXT N_("Transponder symbol rate in kHz") #define SRATE_LONGTEXT "" @@ -149,17 +161,17 @@ static void Close( vlc_object_t *p_this ); #define USER_TEXT N_( "HTTP user name" ) #define USER_LONGTEXT N_( \ - "You can set the user name the administrator will use to log into " \ + "User name the administrator will use to log into " \ "the internal HTTP server." ) #define PASSWORD_TEXT N_( "HTTP password" ) #define PASSWORD_LONGTEXT N_( \ - "You can set the password the administrator will use to log into " \ + "Password the administrator will use to log into " \ "the internal HTTP server." ) #define ACL_TEXT N_( "HTTP ACL" ) #define ACL_LONGTEXT N_( \ - "You can set the access control list (equivalent to .hosts) file path, " \ + "Access control list (equivalent to .hosts) file path, " \ "which will limit the range of IPs entitled to log into the internal " \ "HTTP server." ) @@ -178,88 +190,96 @@ static void Close( vlc_object_t *p_this ); #define CRL_LONGTEXT N_( "HTTP interface Certificates Revocation List file" ) vlc_module_begin(); - set_shortname( _("DVB") ); + set_shortname( N_("DVB") ); set_description( N_("DVB input with v4l2 support") ); set_category( CAT_INPUT ); set_subcategory( SUBCAT_INPUT_ACCESS ); add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, - CACHING_LONGTEXT, VLC_TRUE ); + CACHING_LONGTEXT, true ); add_integer( "dvb-adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT, - VLC_FALSE ); + false ); add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT, - VLC_TRUE ); - add_integer( "dvb-frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT, - VLC_FALSE ); + true ); + add_integer( "dvb-frequency", 0, NULL, FREQ_TEXT, FREQ_LONGTEXT, + false ); add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT, - VLC_TRUE ); - add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_TRUE ); + true ); + add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, true ); add_bool( "dvb-budget-mode", 0, NULL, BUDGET_TEXT, BUDGET_LONGTEXT, - VLC_TRUE ); + true ); /* DVB-S (satellite) */ add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT, - VLC_TRUE ); + true ); add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT, - VLC_TRUE ); + true ); add_bool( "dvb-high-voltage", 0, NULL, HIGH_VOLTAGE_TEXT, - HIGH_VOLTAGE_LONGTEXT, VLC_TRUE ); + HIGH_VOLTAGE_LONGTEXT, true ); add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT, - VLC_TRUE ); - add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_TRUE ); + true ); + add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, true ); add_integer( "dvb-srate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT, - VLC_FALSE ); + false ); add_integer( "dvb-lnb-lof1", 0, NULL, LNB_LOF1_TEXT, - LNB_LOF1_LONGTEXT, VLC_TRUE ); + LNB_LOF1_LONGTEXT, true ); add_integer( "dvb-lnb-lof2", 0, NULL, LNB_LOF2_TEXT, - LNB_LOF2_LONGTEXT, VLC_TRUE ); + LNB_LOF2_LONGTEXT, true ); add_integer( "dvb-lnb-slof", 0, NULL, LNB_SLOF_TEXT, - LNB_SLOF_LONGTEXT, VLC_TRUE ); + LNB_SLOF_LONGTEXT, true ); /* DVB-C (cable) */ add_integer( "dvb-modulation", 0, NULL, MODULATION_TEXT, - MODULATION_LONGTEXT, VLC_TRUE ); + MODULATION_LONGTEXT, true ); /* DVB-T (terrestrial) */ add_integer( "dvb-code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT, - CODE_RATE_HP_LONGTEXT, VLC_TRUE ); + CODE_RATE_HP_LONGTEXT, true ); add_integer( "dvb-code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT, - CODE_RATE_LP_LONGTEXT, VLC_TRUE ); + CODE_RATE_LP_LONGTEXT, true ); add_integer( "dvb-bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT, - VLC_TRUE ); - add_integer( "dvb-guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, VLC_TRUE ); + true ); + add_integer( "dvb-guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, true ); add_integer( "dvb-transmission", 0, NULL, TRANSMISSION_TEXT, - TRANSMISSION_LONGTEXT, VLC_TRUE ); + TRANSMISSION_LONGTEXT, true ); add_integer( "dvb-hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT, - VLC_TRUE ); + true ); #ifdef ENABLE_HTTPD /* MMI HTTP interface */ set_section( N_("HTTP server" ), 0 ); add_string( "dvb-http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, - VLC_TRUE ); + true ); add_string( "dvb-http-user", NULL, NULL, USER_TEXT, USER_LONGTEXT, - VLC_TRUE ); + true ); add_string( "dvb-http-password", NULL, NULL, PASSWORD_TEXT, - PASSWORD_LONGTEXT, VLC_TRUE ); + PASSWORD_LONGTEXT, true ); add_string( "dvb-http-acl", NULL, NULL, ACL_TEXT, ACL_LONGTEXT, - VLC_TRUE ); + true ); add_string( "dvb-http-intf-cert", NULL, NULL, CERT_TEXT, CERT_LONGTEXT, - VLC_TRUE ); + true ); add_string( "dvb-http-intf-key", NULL, NULL, KEY_TEXT, KEY_LONGTEXT, - VLC_TRUE ); + true ); add_string( "dvb-http-intf-ca", NULL, NULL, CA_TEXT, CA_LONGTEXT, - VLC_TRUE ); + true ); add_string( "dvb-http-intf-crl", NULL, NULL, CRL_TEXT, CRL_LONGTEXT, - VLC_TRUE ); + true ); #endif - set_capability( "access2", 0 ); - add_shortcut( "dvb" ); - add_shortcut( "dvb-s" ); + set_capability( "access", 0 ); + add_shortcut( "dvb" ); /* Generic name */ + + add_shortcut( "dvb-s" ); /* Satellite */ add_shortcut( "qpsk" ); - add_shortcut( "dvb-c" ); + add_shortcut( "satellite" ); + + add_shortcut( "dvb-c" ); /* Cable */ add_shortcut( "cable" ); - add_shortcut( "dvb-t" ); + + add_shortcut( "dvb-t" ); /* Terrestrial */ add_shortcut( "terrestrial" ); - add_shortcut( "satellite" ); /* compatibility with the interface. */ + + add_shortcut( "atsc" ); /* Atsc */ + add_shortcut( "usdigital" ); + set_callbacks( Open, Close ); + vlc_module_end(); @@ -269,10 +289,17 @@ vlc_module_end(); static block_t *Block( access_t * ); static int Control( access_t *, int, va_list ); +static block_t *BlockScan( access_t * ); + #define DVB_READ_ONCE 20 #define DVB_READ_ONCE_START 2 +#define DVB_READ_ONCE_SCAN 1 #define TS_PACKET_SIZE 188 +#define DVB_SCAN_MAX_SIGNAL_TIME (300*1000) +#define DVB_SCAN_MAX_LOCK_TIME (5000*1000) +#define DVB_SCAN_MAX_PROBE_TIME (30000*1000) + static void FilterUnset( access_t *, int i_max ); static void FilterUnsetPID( access_t *, int i_pid ); static void FilterSet( access_t *, int i_pid, int i_type ); @@ -280,7 +307,6 @@ static void FilterSet( access_t *, int i_pid, int i_type ); static void VarInit( access_t * ); static int ParseMRL( access_t * ); - /***************************************************************************** * Open: open the frontend device *****************************************************************************/ @@ -298,14 +324,13 @@ static int Open( vlc_object_t *p_this ) p_access->pf_block = Block; p_access->pf_control = Control; p_access->pf_seek = NULL; - p_access->info.i_update = 0; - p_access->info.i_size = 0; - p_access->info.i_pos = 0; - p_access->info.b_eof = VLC_FALSE; - p_access->info.i_title = 0; - p_access->info.i_seekpoint = 0; + + access_InitFields( p_access ); p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); + if( !p_sys ) + return VLC_ENOMEM; + memset( p_sys, 0, sizeof( access_sys_t ) ); /* Create all variables */ @@ -319,52 +344,83 @@ static int Open( vlc_object_t *p_this ) } /* Getting frontend info */ - if( E_(FrontendOpen)( p_access) ) + if( FrontendOpen( p_access) ) { free( p_sys ); return VLC_EGENERIC; } - /* Setting frontend parameters for tuning the hardware */ - msg_Dbg( p_access, "trying to tune the frontend..."); - if( E_(FrontendSet)( p_access ) < 0 ) + /* */ + p_sys->b_scan_mode = var_GetInteger( p_access, "dvb-frequency" ) == 0; + if( p_sys->b_scan_mode ) { - E_(FrontendClose)( p_access ); - free( p_sys ); - return VLC_EGENERIC; + msg_Dbg( p_access, "DVB scan mode selected" ); + p_access->pf_block = BlockScan; + } + else + { + /* Setting frontend parameters for tuning the hardware */ + msg_Dbg( p_access, "trying to tune the frontend..."); + if( FrontendSet( p_access ) < 0 ) + { + FrontendClose( p_access ); + free( p_sys ); + return VLC_EGENERIC; + } } /* Opening DVR device */ - if( E_(DVROpen)( p_access ) < 0 ) + if( DVROpen( p_access ) < 0 ) { - E_(FrontendClose)( p_access ); + FrontendClose( p_access ); free( p_sys ); return VLC_EGENERIC; } - p_sys->b_budget_mode = var_GetBool( p_access, "dvb-budget-mode" ); - if( p_sys->b_budget_mode ) + if( p_sys->b_scan_mode ) { - msg_Dbg( p_access, "setting filter on all PIDs" ); - FilterSet( p_access, 0x2000, OTHER_TYPE ); + scan_parameter_t parameter; + + msg_Dbg( p_access, "setting filter on PAT/NIT/SDT (DVB only)" ); + FilterSet( p_access, 0x00, OTHER_TYPE ); // PAT + FilterSet( p_access, 0x10, OTHER_TYPE ); // NIT + FilterSet( p_access, 0x11, OTHER_TYPE ); // SDT + + if( FrontendGetScanParameter( p_access, ¶meter ) || + scan_Init( VLC_OBJECT(p_access), &p_sys->scan, ¶meter ) ) + { + Close( VLC_OBJECT(p_access) ); + return VLC_EGENERIC; + } } else { - msg_Dbg( p_access, "setting filter on PAT" ); - FilterSet( p_access, 0x0, OTHER_TYPE ); - } + p_sys->b_budget_mode = var_GetBool( p_access, "dvb-budget-mode" ); + if( p_sys->b_budget_mode ) + { + msg_Dbg( p_access, "setting filter on all PIDs" ); + FilterSet( p_access, 0x2000, OTHER_TYPE ); + } + else + { + msg_Dbg( p_access, "setting filter on PAT" ); + FilterSet( p_access, 0x0, OTHER_TYPE ); + } - E_(CAMOpen)( p_access ); + CAMOpen( p_access ); - if( p_sys->b_budget_mode ) +#ifdef ENABLE_HTTPD + HTTPOpen( p_access ); +#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; -#ifdef ENABLE_HTTPD - E_(HTTPOpen)( p_access ); -#endif - return VLC_SUCCESS; } @@ -376,14 +432,18 @@ static void Close( vlc_object_t *p_this ) access_t *p_access = (access_t*)p_this; access_sys_t *p_sys = p_access->p_sys; - FilterUnset( p_access, p_sys->b_budget_mode ? 1 : MAX_DEMUX ); + FilterUnset( p_access, p_sys->b_budget_mode && !p_sys->b_scan_mode ? 1 : MAX_DEMUX ); - E_(DVRClose)( p_access ); - E_(FrontendClose)( p_access ); - E_(CAMClose)( p_access ); + DVRClose( p_access ); + FrontendClose( p_access ); + if( p_sys->b_scan_mode ) + scan_Clean( &p_sys->scan ); + else + CAMClose( p_access ); #ifdef ENABLE_HTTPD - E_(HTTPClose)( p_access ); + if( !p_sys->b_scan_mode ) + HTTPClose( p_access ); #endif free( p_sys ); @@ -399,47 +459,41 @@ static block_t *Block( access_t *p_access ) for ( ; ; ) { - struct timeval timeout; - fd_set fds, fde; + struct pollfd ufds[2]; int i_ret; - int i_max_handle = p_sys->i_handle; /* Initialize file descriptor sets */ - FD_ZERO( &fds ); - FD_ZERO( &fde ); - FD_SET( p_sys->i_handle, &fds ); - FD_SET( p_sys->i_frontend_handle, &fde ); - if ( p_sys->i_frontend_handle > i_max_handle ) - i_max_handle = p_sys->i_frontend_handle; + memset (ufds, 0, sizeof (ufds)); + ufds[0].fd = p_sys->i_handle; + ufds[0].events = POLLIN; + ufds[1].fd = p_sys->i_frontend_handle; + ufds[1].events = POLLPRI; /* We'll wait 0.5 second if nothing happens */ - timeout.tv_sec = 0; - timeout.tv_usec = 500000; - /* Find if some data is available */ - i_ret = select( i_max_handle + 1, &fds, NULL, &fde, &timeout ); + i_ret = poll( ufds, 2, 500 ); - if ( p_access->b_die ) + if ( !vlc_object_alive (p_access) ) return NULL; - if ( i_ret < 0 && errno == EINTR ) - continue; - if ( i_ret < 0 ) { - msg_Err( p_access, "select error (%s)", strerror(errno) ); + if( errno == EINTR ) + continue; + + msg_Err( p_access, "poll error: %m" ); return NULL; } if ( p_sys->i_ca_handle && mdate() > p_sys->i_ca_next_event ) { - E_(CAMPoll)( p_access ); + CAMPoll( p_access ); p_sys->i_ca_next_event = mdate() + p_sys->i_ca_timeout; } - if ( FD_ISSET( p_sys->i_frontend_handle, &fde ) ) + if ( ufds[1].revents ) { - E_(FrontendPoll)( p_access ); + FrontendPoll( p_access ); } #ifdef ENABLE_HTTPD @@ -449,13 +503,13 @@ static block_t *Block( access_t *p_access ) if ( p_sys->b_request_frontend_info ) { msg_Warn( p_access, "frontend timeout for HTTP interface" ); - p_sys->b_request_frontend_info = VLC_FALSE; + p_sys->b_request_frontend_info = false; p_sys->psz_frontend_info = strdup( "Timeout getting info\n" ); } if ( p_sys->b_request_mmi_info ) { msg_Warn( p_access, "MMI timeout for HTTP interface" ); - p_sys->b_request_mmi_info = VLC_FALSE; + p_sys->b_request_mmi_info = false; p_sys->psz_mmi_info = strdup( "Timeout getting info\n" ); } vlc_cond_signal( &p_sys->httpd_cond ); @@ -464,32 +518,33 @@ static block_t *Block( access_t *p_access ) if ( p_sys->b_request_frontend_info ) { - E_(FrontendStatus)( p_access ); + FrontendStatus( p_access ); } if ( p_sys->b_request_mmi_info ) { - E_(CAMStatus)( p_access ); + CAMStatus( p_access ); } #endif if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout ) { msg_Warn( p_access, "no lock, tuning again" ); - E_(FrontendSet)( p_access ); + FrontendSet( p_access ); } - if ( FD_ISSET( p_sys->i_handle, &fds ) ) + if ( ufds[0].revents ) { p_block = block_New( p_access, p_sys->i_read_once * TS_PACKET_SIZE ); - if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer, + if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer, p_sys->i_read_once * TS_PACKET_SIZE ) ) <= 0 ) { - msg_Warn( p_access, "read failed (%s)", strerror(errno) ); + msg_Warn( p_access, "read failed (%m)" ); block_Release( p_block ); continue; } + p_block->i_buffer = i_ret; break; } } @@ -497,18 +552,173 @@ static block_t *Block( access_t *p_access ) if( p_sys->i_read_once < DVB_READ_ONCE ) p_sys->i_read_once++; + /* Update moderatly the signal properties */ + if( (p_sys->i_stat_counter++ % 100) == 0 ) + p_access->info.i_update |= INPUT_UPDATE_SIGNAL; + return p_block; } +/***************************************************************************** + * BlockScan: + *****************************************************************************/ +static block_t *BlockScan( access_t *p_access ) +{ + access_sys_t *p_sys = p_access->p_sys; + scan_t *p_scan = &p_sys->scan; + scan_configuration_t cfg; + scan_session_t session; + + /* */ + if( scan_Next( p_scan, &cfg ) ) + { + const bool b_first_eof = !p_access->info.b_eof; + + if( b_first_eof ) + msg_Warn( p_access, "Scanning finished" ); + + /* */ + p_access->info.b_eof = true; + return b_first_eof ? scan_GetM3U( p_scan ) : NULL; + } + + /* */ + + if( scan_session_Init( VLC_OBJECT(p_access), &session, &cfg ) ) + return NULL; + + /* */ + msg_Dbg( p_access, "Scanning frequency %d", cfg.i_frequency ); + var_SetInteger( p_access, "dvb-frequency", cfg.i_frequency ); + var_SetInteger( p_access, "dvb-bandwidth", cfg.i_bandwidth ); + + /* Setting frontend parameters for tuning the hardware */ + if( FrontendSet( p_access ) < 0 ) + { + msg_Err( p_access, "Failed to tune the frontend" ); + p_access->info.b_eof = true; + return NULL; + } + + /* */ + int64_t i_scan_start = mdate(); + + bool b_has_dvb_signal = false; + bool b_has_lock = false; + int i_best_snr = -1; + + for ( ; ; ) + { + struct pollfd ufds[2]; + int i_ret; + + /* Initialize file descriptor sets */ + memset (ufds, 0, sizeof (ufds)); + ufds[0].fd = p_sys->i_handle; + ufds[0].events = POLLIN; + ufds[1].fd = p_sys->i_frontend_handle; + ufds[1].events = POLLPRI; + + /* We'll wait 0.1 second if nothing happens */ + /* Find if some data is available */ + i_ret = poll( ufds, 2, 100 ); + + if( !vlc_object_alive (p_access) || scan_IsCancelled( p_scan ) ) + break; + + if( i_ret <= 0 ) + { + const mtime_t i_scan_time = mdate() - i_scan_start; + frontend_status_t status; + + FrontendGetStatus( p_access, &status ); + + b_has_dvb_signal |= status.b_has_carrier; + b_has_lock |= status.b_has_lock; + + if( ( !b_has_dvb_signal && i_scan_time > DVB_SCAN_MAX_SIGNAL_TIME ) || + ( !b_has_lock && i_scan_time > DVB_SCAN_MAX_LOCK_TIME ) || + ( i_scan_time > DVB_SCAN_MAX_PROBE_TIME ) ) + { + msg_Dbg( p_access, "timed out scanning current frequency (s=%d l=%d)", b_has_dvb_signal, b_has_lock ); + break; + } + } + + if( i_ret < 0 ) + { + if( errno == EINTR ) + continue; + + msg_Err( p_access, "poll error: %m" ); + scan_session_Clean( p_scan, &session ); + + p_access->info.b_eof = true; + return NULL; + } + + if( ufds[1].revents ) + { + frontend_statistic_t stat; + + FrontendPoll( p_access ); + + if( !FrontendGetStatistic( p_access, &stat ) ) + { + if( stat.i_snr > i_best_snr ) + i_best_snr = stat.i_snr; + } + } + + if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout ) + { + msg_Warn( p_access, "no lock, tuning again" ); + FrontendSet( p_access ); + } + + if ( ufds[0].revents ) + { + const int i_read_once = 1; + block_t *p_block = block_New( p_access, i_read_once * TS_PACKET_SIZE ); + + if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer, + i_read_once * TS_PACKET_SIZE ) ) <= 0 ) + { + msg_Warn( p_access, "read failed (%m)" ); + block_Release( p_block ); + continue; + } + p_block->i_buffer = i_ret; + + /* */ + if( scan_session_Push( &session, p_block ) ) + { + msg_Dbg( p_access, "finished scanning current frequency" ); + break; + } + } + } + + /* */ + if( i_best_snr > 0 ) + scan_service_SetSNR( &session, i_best_snr ); + + scan_session_Clean( p_scan, &session ); + return NULL; +} + /***************************************************************************** * Control: *****************************************************************************/ static int Control( access_t *p_access, int i_query, va_list args ) { access_sys_t *p_sys = p_access->p_sys; - vlc_bool_t *pb_bool, b_bool; + bool *pb_bool, b_bool; int *pi_int, i_int; int64_t *pi_64; + double *pf1, *pf2; + dvbpsi_pmt_t *p_pmt; + frontend_statistic_t stat; switch( i_query ) { @@ -517,13 +727,16 @@ static int Control( access_t *p_access, int i_query, va_list args ) case ACCESS_CAN_FASTSEEK: case ACCESS_CAN_PAUSE: case ACCESS_CAN_CONTROL_PACE: - pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); - *pb_bool = VLC_FALSE; + pb_bool = (bool*)va_arg( args, bool* ); + *pb_bool = false; break; /* */ case ACCESS_GET_MTU: pi_int = (int*)va_arg( args, int * ); - *pi_int = DVB_READ_ONCE * TS_PACKET_SIZE; + if( p_sys->b_scan_mode ) + *pi_int = 0; + else + *pi_int = DVB_READ_ONCE * TS_PACKET_SIZE; break; case ACCESS_GET_PTS_DELAY: @@ -536,11 +749,27 @@ static int Control( access_t *p_access, int i_query, va_list args ) case ACCESS_GET_TITLE_INFO: case ACCESS_SET_TITLE: case ACCESS_SET_SEEKPOINT: + case ACCESS_GET_CONTENT_TYPE: return VLC_EGENERIC; + case ACCESS_GET_SIGNAL: + pf1 = (double*)va_arg( args, double * ); + pf2 = (double*)va_arg( args, double * ); + + *pf1 = *pf2 = 0; + if( !FrontendGetStatistic( p_access, &stat ) ) + { + *pf1 = (double)stat.i_snr / 65535.0; + *pf2 = (double)stat.i_signal_strenth / 65535.0; + } + return VLC_SUCCESS; + case ACCESS_SET_PRIVATE_ID_STATE: + if( p_sys->b_scan_mode ) + return VLC_EGENERIC; + i_int = (int)va_arg( args, int ); /* Private data (pid for now)*/ - b_bool = (vlc_bool_t)va_arg( args, vlc_bool_t ); /* b_selected */ + b_bool = (bool)va_arg( args, int ); /* b_selected */ if( !p_sys->b_budget_mode ) { /* FIXME we may want to give the real type (me ?, I don't ;) */ @@ -552,14 +781,13 @@ static int Control( access_t *p_access, int i_query, va_list args ) break; case ACCESS_SET_PRIVATE_ID_CA: - { - dvbpsi_pmt_t *p_pmt; + if( p_sys->b_scan_mode ) + return VLC_EGENERIC; p_pmt = (dvbpsi_pmt_t *)va_arg( args, dvbpsi_pmt_t * ); - E_(CAMSet)( p_access, p_pmt ); + CAMSet( p_access, p_pmt ); break; - } default: msg_Warn( p_access, "unimplemented query in control" ); @@ -593,7 +821,7 @@ static void FilterSet( access_t *p_access, int i_pid, int i_type ) return; } - if( E_(DMXSetFilter)( p_access, i_pid, + if( DMXSetFilter( p_access, i_pid, &p_sys->p_demux_handles[i].i_handle, i_type ) ) { msg_Err( p_access, "DMXSetFilter failed" ); @@ -615,7 +843,7 @@ static void FilterUnset( access_t *p_access, int i_max ) { if( p_sys->p_demux_handles[i].i_type ) { - E_(DMXUnsetFilter)( p_access, p_sys->p_demux_handles[i].i_handle ); + DMXUnsetFilter( p_access, p_sys->p_demux_handles[i].i_handle ); p_sys->p_demux_handles[i].i_type = 0; } } @@ -631,7 +859,7 @@ static void FilterUnsetPID( access_t *p_access, int i_pid ) if( p_sys->p_demux_handles[i].i_type && p_sys->p_demux_handles[i].i_pid == i_pid ) { - E_(DMXUnsetFilter)( p_access, p_sys->p_demux_handles[i].i_handle ); + DMXUnsetFilter( p_access, p_sys->p_demux_handles[i].i_handle ); p_sys->p_demux_handles[i].i_type = 0; } } @@ -717,6 +945,9 @@ static int ParseMRL( access_t *p_access ) { msg_Err( p_access, "the DVB input old syntax is deprecated, use vlc " "-p dvb to see an explanation of the new syntax" ); + intf_UserFatal( p_access, true, _("Input syntax is deprecated"), + _("The given syntax is deprecated. Run \"vlc -p dvb\" to see an " \ + "explanation of the new syntax.") ); free( psz_dup ); return VLC_EGENERIC; } @@ -761,6 +992,9 @@ static int ParseMRL( access_t *p_access ) else { msg_Err( p_access, "illegal polarization %c", *psz_parser ); + intf_UserFatal( p_access, false, _("Illegal Polarization"), + _("The provided polarization \"%c\" is not valid."), + *psz_parser ); free( psz_dup ); return VLC_EGENERIC; }