Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

access.c

00001 /*****************************************************************************
00002  * access.c: DVB card input v4l2 only
00003  *****************************************************************************
00004  * Copyright (C) 1998-2004 the VideoLAN team
00005  *
00006  * Authors: Johan Bilien <[email protected]>
00007  *          Jean-Paul Saman <[email protected]>
00008  *          Christophe Massiot <[email protected]>
00009  *          Laurent Aimar <[email protected]>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00024  *****************************************************************************/
00025 
00026 
00027 /*****************************************************************************
00028  * Preamble
00029  *****************************************************************************/
00030 #include <vlc/vlc.h>
00031 #include <vlc/input.h>
00032 
00033 #ifdef HAVE_UNISTD_H
00034 #   include <unistd.h>
00035 #endif
00036 
00037 #include <fcntl.h>
00038 #include <sys/types.h>
00039 
00040 #include <errno.h>
00041 
00042 /* Include dvbpsi headers */
00043 #ifdef HAVE_DVBPSI_DR_H
00044 #   include <dvbpsi/dvbpsi.h>
00045 #   include <dvbpsi/descriptor.h>
00046 #   include <dvbpsi/pat.h>
00047 #   include <dvbpsi/pmt.h>
00048 #   include <dvbpsi/dr.h>
00049 #   include <dvbpsi/psi.h>
00050 #else
00051 #   include "dvbpsi.h"
00052 #   include "descriptor.h"
00053 #   include "tables/pat.h"
00054 #   include "tables/pmt.h"
00055 #   include "descriptors/dr.h"
00056 #   include "psi.h"
00057 #endif
00058 
00059 #include "dvb.h"
00060 
00061 /*****************************************************************************
00062  * Module descriptor
00063  *****************************************************************************/
00064 static int  Open( vlc_object_t *p_this );
00065 static void Close( vlc_object_t *p_this );
00066 
00067 #define CACHING_TEXT N_("Caching value in ms")
00068 #define CACHING_LONGTEXT N_( \
00069     "Allows you to modify the default caching value for dvb streams. This " \
00070     "value should be set in millisecond units." )
00071 
00072 #define ADAPTER_TEXT N_("Adapter card to tune")
00073 #define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.")
00074 
00075 #define DEVICE_TEXT N_("Device number to use on adapter")
00076 #define DEVICE_LONGTEXT ""
00077 
00078 #define FREQ_TEXT N_("Transponder/multiplex frequency")
00079 #define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
00080 
00081 #define INVERSION_TEXT N_("Inversion mode")
00082 #define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]")
00083 
00084 #define PROBE_TEXT N_("Probe DVB card for capabilities")
00085 #define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities.")
00086 
00087 #define BUDGET_TEXT N_("Budget mode")
00088 #define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder with a budget card.")
00089 
00090 /* Satellite */
00091 #define SATNO_TEXT N_("Satellite number in the Diseqc system")
00092 #define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=satellite number]")
00093 
00094 #define VOLTAGE_TEXT N_("LNB voltage")
00095 #define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal]")
00096 
00097 #define HIGH_VOLTAGE_TEXT N_("High LNB voltage")
00098 #define HIGH_VOLTAGE_LONGTEXT N_("Enable high voltage if your cables are " \
00099     "particularly long. This is not supported by all frontends.")
00100 
00101 #define TONE_TEXT N_("22 kHz tone")
00102 #define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto]")
00103 
00104 #define FEC_TEXT N_("Transponder FEC")
00105 #define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto]")
00106 
00107 #define SRATE_TEXT N_("Transponder symbol rate in kHz")
00108 #define SRATE_LONGTEXT ""
00109 
00110 #define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
00111 #define LNB_LOF1_LONGTEXT ""
00112 
00113 #define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
00114 #define LNB_LOF2_LONGTEXT ""
00115 
00116 #define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
00117 #define LNB_SLOF_LONGTEXT ""
00118 
00119 /* Cable */
00120 #define MODULATION_TEXT N_("Modulation type")
00121 #define MODULATION_LONGTEXT N_("Modulation type for front-end device.")
00122 
00123 /* Terrestrial */
00124 #define CODE_RATE_HP_TEXT N_("Terrestrial high priority stream code rate (FEC)")
00125 #define CODE_RATE_HP_LONGTEXT ""
00126 
00127 #define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
00128 #define CODE_RATE_LP_LONGTEXT ""
00129 
00130 #define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
00131 #define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
00132 
00133 #define GUARD_TEXT N_("Terrestrial guard interval")
00134 #define GUARD_LONGTEXT ""
00135 
00136 #define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
00137 #define TRANSMISSION_LONGTEXT ""
00138 
00139 #define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
00140 #define HIERARCHY_LONGTEXT ""
00141 
00142 vlc_module_begin();
00143     set_shortname( _("DVB") );
00144     set_description( N_("DVB input with v4l2 support") );
00145     set_category( CAT_INPUT );
00146     set_subcategory( SUBCAT_INPUT_ACCESS );
00147 
00148     add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
00149                  CACHING_LONGTEXT, VLC_TRUE );
00150     add_integer( "dvb-adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT,
00151                  VLC_FALSE );
00152     add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
00153                  VLC_TRUE );
00154     add_integer( "dvb-frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT,
00155                  VLC_FALSE );
00156     add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT,
00157                  VLC_TRUE );
00158     add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_TRUE );
00159     add_bool( "dvb-budget-mode", 0, NULL, BUDGET_TEXT, BUDGET_LONGTEXT,
00160               VLC_TRUE );
00161     /* DVB-S (satellite) */
00162     add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT,
00163                  VLC_TRUE );
00164     add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT,
00165                  VLC_TRUE );
00166     add_bool( "dvb-high-voltage", 0, NULL, HIGH_VOLTAGE_TEXT,
00167               HIGH_VOLTAGE_LONGTEXT, VLC_TRUE );
00168     add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT,
00169                  VLC_TRUE );
00170     add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_TRUE );
00171     add_integer( "dvb-srate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT,
00172                  VLC_FALSE );
00173     add_integer( "dvb-lnb-lof1", 0, NULL, LNB_LOF1_TEXT,
00174                  LNB_LOF1_LONGTEXT, VLC_TRUE );
00175     add_integer( "dvb-lnb-lof2", 0, NULL, LNB_LOF2_TEXT,
00176                  LNB_LOF2_LONGTEXT, VLC_TRUE );
00177     add_integer( "dvb-lnb-slof", 0, NULL, LNB_SLOF_TEXT,
00178                  LNB_SLOF_LONGTEXT, VLC_TRUE );
00179     /* DVB-C (cable) */
00180     add_integer( "dvb-modulation", 0, NULL, MODULATION_TEXT,
00181                  MODULATION_LONGTEXT, VLC_TRUE );
00182     /* DVB-T (terrestrial) */
00183     add_integer( "dvb-code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT,
00184                  CODE_RATE_HP_LONGTEXT, VLC_TRUE );
00185     add_integer( "dvb-code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT,
00186                  CODE_RATE_LP_LONGTEXT, VLC_TRUE );
00187     add_integer( "dvb-bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
00188                  VLC_TRUE );
00189     add_integer( "dvb-guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, VLC_TRUE );
00190     add_integer( "dvb-transmission", 0, NULL, TRANSMISSION_TEXT,
00191                  TRANSMISSION_LONGTEXT, VLC_TRUE );
00192     add_integer( "dvb-hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
00193                  VLC_TRUE );
00194 
00195     set_capability( "access2", 0 );
00196     add_shortcut( "dvb" );
00197     add_shortcut( "dvb-s" );
00198     add_shortcut( "qpsk" );
00199     add_shortcut( "dvb-c" );
00200     add_shortcut( "cable" );
00201     add_shortcut( "dvb-t" );
00202     add_shortcut( "terrestrial" );
00203     add_shortcut( "satellite" );    /* compatibility with the interface. */
00204     set_callbacks( Open, Close );
00205 vlc_module_end();
00206 
00207 
00208 /*****************************************************************************
00209  * Local prototypes
00210  *****************************************************************************/
00211 static block_t *Block( access_t * );
00212 static int Control( access_t *, int, va_list );
00213 
00214 #define DVB_READ_ONCE 20
00215 #define DVB_READ_ONCE_START 2
00216 #define TS_PACKET_SIZE 188
00217 
00218 static void FilterUnset( access_t *, int i_max );
00219 static void FilterUnsetPID( access_t *, int i_pid );
00220 static void FilterSet( access_t *, int i_pid, int i_type );
00221 
00222 static void VarInit( access_t * );
00223 static int  ParseMRL( access_t * );
00224 
00225 
00226 /*****************************************************************************
00227  * Open: open the frontend device
00228  *****************************************************************************/
00229 static int Open( vlc_object_t *p_this )
00230 {
00231     access_t     *p_access = (access_t*)p_this;
00232     access_sys_t *p_sys;
00233 
00234     /* Only if selected */
00235     if( *p_access->psz_access == '\0' )
00236         return VLC_EGENERIC;
00237 
00238     /* Set up access */
00239     p_access->pf_read = NULL;
00240     p_access->pf_block = Block;
00241     p_access->pf_control = Control;
00242     p_access->pf_seek = NULL;
00243     p_access->info.i_update = 0;
00244     p_access->info.i_size = 0;
00245     p_access->info.i_pos = 0;
00246     p_access->info.b_eof = VLC_FALSE;
00247     p_access->info.i_title = 0;
00248     p_access->info.i_seekpoint = 0;
00249 
00250     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
00251     memset( p_sys, 0, sizeof( access_sys_t ) );
00252 
00253     /* Create all variables */
00254     VarInit( p_access );
00255 
00256     /* Parse the command line */
00257     if( ParseMRL( p_access ) )
00258     {
00259         free( p_sys );
00260         return VLC_EGENERIC;
00261     }
00262 
00263     /* Getting frontend info */
00264     if( E_(FrontendOpen)( p_access) )
00265     {
00266         free( p_sys );
00267         return VLC_EGENERIC;
00268     }
00269 
00270     /* Setting frontend parameters for tuning the hardware */
00271     msg_Dbg( p_access, "trying to tune the frontend...");
00272     if( E_(FrontendSet)( p_access ) < 0 )
00273     {
00274         E_(FrontendClose)( p_access );
00275         free( p_sys );
00276         return VLC_EGENERIC;
00277     }
00278 
00279     /* Opening DVR device */
00280     if( E_(DVROpen)( p_access ) < 0 )
00281     {
00282         E_(FrontendClose)( p_access );
00283         free( p_sys );
00284         return VLC_EGENERIC;
00285     }
00286 
00287     p_sys->b_budget_mode = var_GetBool( p_access, "dvb-budget-mode" );
00288     if( p_sys->b_budget_mode )
00289     {
00290         msg_Dbg( p_access, "setting filter on all PIDs" );
00291         FilterSet( p_access, 0x2000, OTHER_TYPE );
00292     }
00293     else
00294     {
00295         msg_Dbg( p_access, "setting filter on PAT" );
00296         FilterSet( p_access, 0x0, OTHER_TYPE );
00297     }
00298 
00299     E_(CAMOpen)( p_access );
00300 
00301     if( p_sys->b_budget_mode )
00302         p_sys->i_read_once = DVB_READ_ONCE;
00303     else
00304         p_sys->i_read_once = DVB_READ_ONCE_START;
00305 
00306     return VLC_SUCCESS;
00307 }
00308 
00309 /*****************************************************************************
00310  * Close : Close the device
00311  *****************************************************************************/
00312 static void Close( vlc_object_t *p_this )
00313 {
00314     access_t     *p_access = (access_t*)p_this;
00315     access_sys_t *p_sys = p_access->p_sys;
00316 
00317     FilterUnset( p_access, p_sys->b_budget_mode ? 1 : MAX_DEMUX );
00318 
00319     E_(DVRClose)( p_access );
00320     E_(FrontendClose)( p_access );
00321     E_(CAMClose)( p_access );
00322 
00323     free( p_sys );
00324 }
00325 
00326 /*****************************************************************************
00327  * Block:
00328  *****************************************************************************/
00329 static block_t *Block( access_t *p_access )
00330 {
00331     access_sys_t *p_sys = p_access->p_sys;
00332     block_t *p_block;
00333 
00334     for ( ; ; )
00335     {
00336         struct timeval timeout;
00337         fd_set fds, fde;
00338         int i_ret;
00339         int i_max_handle = p_sys->i_handle;
00340 
00341         /* Initialize file descriptor sets */
00342         FD_ZERO( &fds );
00343         FD_ZERO( &fde );
00344         FD_SET( p_sys->i_handle, &fds );
00345         FD_SET( p_sys->i_frontend_handle, &fde );
00346         if ( p_sys->i_frontend_handle > i_max_handle )
00347             i_max_handle = p_sys->i_frontend_handle;
00348 
00349         /* We'll wait 0.5 second if nothing happens */
00350         timeout.tv_sec = 0;
00351         timeout.tv_usec = 500000;
00352 
00353         /* Find if some data is available */
00354         i_ret = select( i_max_handle + 1, &fds, NULL, &fde, &timeout );
00355 
00356         if ( p_access->b_die )
00357             return NULL;
00358 
00359         if ( i_ret < 0 && errno == EINTR )
00360             continue;
00361 
00362         if ( i_ret < 0 )
00363         {
00364             msg_Err( p_access, "select error (%s)", strerror(errno) );
00365             return NULL;
00366         }
00367 
00368         if ( p_sys->i_ca_handle && mdate() > p_sys->i_ca_next_event )
00369         {
00370             E_(CAMPoll)( p_access );
00371             p_sys->i_ca_next_event = mdate() + p_sys->i_ca_timeout;
00372         }
00373 
00374         if ( FD_ISSET( p_sys->i_frontend_handle, &fde ) )
00375         {
00376             E_(FrontendPoll)( p_access );
00377         }
00378 
00379         if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout )
00380         {
00381             msg_Warn( p_access, "no lock, tuning again" );
00382             E_(FrontendSet)( p_access );
00383         }
00384 
00385         if ( FD_ISSET( p_sys->i_handle, &fds ) )
00386         {
00387             p_block = block_New( p_access,
00388                                  p_sys->i_read_once * TS_PACKET_SIZE );
00389             if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer,
00390                                 p_sys->i_read_once * TS_PACKET_SIZE ) ) <= 0 )
00391             {
00392                 msg_Warn( p_access, "read failed (%s)", strerror(errno) );
00393                 block_Release( p_block );
00394                 continue;
00395             }
00396             break;
00397         }
00398     }
00399 
00400     if( p_sys->i_read_once < DVB_READ_ONCE )
00401         p_sys->i_read_once++;
00402 
00403     return p_block;
00404 }
00405 
00406 /*****************************************************************************
00407  * Control:
00408  *****************************************************************************/
00409 static int Control( access_t *p_access, int i_query, va_list args )
00410 {
00411     access_sys_t *p_sys = p_access->p_sys;
00412     vlc_bool_t   *pb_bool, b_bool;
00413     int          *pi_int, i_int;
00414     int64_t      *pi_64;
00415 
00416     switch( i_query )
00417     {
00418         /* */
00419         case ACCESS_CAN_SEEK:
00420         case ACCESS_CAN_FASTSEEK:
00421         case ACCESS_CAN_PAUSE:
00422         case ACCESS_CAN_CONTROL_PACE:
00423             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
00424             *pb_bool = VLC_FALSE;
00425             break;
00426         /* */
00427         case ACCESS_GET_MTU:
00428             pi_int = (int*)va_arg( args, int * );
00429             *pi_int = DVB_READ_ONCE * TS_PACKET_SIZE;
00430             break;
00431 
00432         case ACCESS_GET_PTS_DELAY:
00433             pi_64 = (int64_t*)va_arg( args, int64_t * );
00434             *pi_64 = var_GetInteger( p_access, "dvb-caching" ) * 1000;
00435             break;
00436 
00437         /* */
00438         case ACCESS_SET_PAUSE_STATE:
00439         case ACCESS_GET_TITLE_INFO:
00440         case ACCESS_SET_TITLE:
00441         case ACCESS_SET_SEEKPOINT:
00442             return VLC_EGENERIC;
00443 
00444         case ACCESS_SET_PRIVATE_ID_STATE:
00445             i_int  = (int)va_arg( args, int );               /* Private data (pid for now)*/
00446             b_bool = (vlc_bool_t)va_arg( args, vlc_bool_t ); /* b_selected */
00447             if( !p_sys->b_budget_mode )
00448             {
00449                 /* FIXME we may want to give the real type (me ?, I don't ;) */
00450                 if( b_bool )
00451                     FilterSet( p_access, i_int, OTHER_TYPE );
00452                 else
00453                     FilterUnsetPID( p_access, i_int );
00454             }
00455             break;
00456 
00457         case ACCESS_SET_PRIVATE_ID_CA:
00458         {
00459             dvbpsi_pmt_t *p_pmt;
00460 
00461             p_pmt = (dvbpsi_pmt_t *)va_arg( args, dvbpsi_pmt_t * );
00462 
00463             E_(CAMSet)( p_access, p_pmt );
00464             break;
00465         }
00466 
00467         default:
00468             msg_Warn( p_access, "unimplemented query in control" );
00469             return VLC_EGENERIC;
00470 
00471     }
00472     return VLC_SUCCESS;
00473 }
00474 
00475 /*****************************************************************************
00476  * FilterSet/FilterUnset:
00477  *****************************************************************************/
00478 static void FilterSet( access_t *p_access, int i_pid, int i_type )
00479 {
00480     access_sys_t *p_sys = p_access->p_sys;
00481     int i;
00482 
00483     /* Find first free slot */
00484     for( i = 0; i < MAX_DEMUX; i++ )
00485     {
00486         if( !p_sys->p_demux_handles[i].i_type )
00487             break;
00488 
00489         if( p_sys->p_demux_handles[i].i_pid == i_pid )
00490             return; /* Already set */
00491     }
00492 
00493     if( i >= MAX_DEMUX )
00494     {
00495         msg_Err( p_access, "no free p_demux_handles !" );
00496         return;
00497     }
00498 
00499     if( E_(DMXSetFilter)( p_access, i_pid,
00500                            &p_sys->p_demux_handles[i].i_handle, i_type ) )
00501     {
00502         msg_Err( p_access, "DMXSetFilter failed" );
00503         return;
00504     }
00505     p_sys->p_demux_handles[i].i_type = i_type;
00506     p_sys->p_demux_handles[i].i_pid = i_pid;
00507 
00508     if( p_sys->i_read_once < DVB_READ_ONCE )
00509         p_sys->i_read_once++;
00510 }
00511 
00512 static void FilterUnset( access_t *p_access, int i_max )
00513 {
00514     access_sys_t *p_sys = p_access->p_sys;
00515     int i;
00516 
00517     for( i = 0; i < i_max; i++ )
00518     {
00519         if( p_sys->p_demux_handles[i].i_type )
00520         {
00521             E_(DMXUnsetFilter)( p_access, p_sys->p_demux_handles[i].i_handle );
00522             p_sys->p_demux_handles[i].i_type = 0;
00523         }
00524     }
00525 }
00526 
00527 static void FilterUnsetPID( access_t *p_access, int i_pid )
00528 {
00529     access_sys_t *p_sys = p_access->p_sys;
00530     int i;
00531 
00532     for( i = 0; i < MAX_DEMUX; i++ )
00533     {
00534         if( p_sys->p_demux_handles[i].i_type &&
00535             p_sys->p_demux_handles[i].i_pid == i_pid )
00536         {
00537             E_(DMXUnsetFilter)( p_access, p_sys->p_demux_handles[i].i_handle );
00538             p_sys->p_demux_handles[i].i_type = 0;
00539         }
00540     }
00541 }
00542 
00543 /*****************************************************************************
00544  * VarInit/ParseMRL:
00545  *****************************************************************************/
00546 static void VarInit( access_t *p_access )
00547 {
00548     /* */
00549     var_Create( p_access, "dvb-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00550 
00551     /* */
00552     var_Create( p_access, "dvb-adapter", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00553     var_Create( p_access, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00554     var_Create( p_access, "dvb-frequency", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00555     var_Create( p_access, "dvb-inversion", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00556     var_Create( p_access, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
00557     var_Create( p_access, "dvb-budget-mode", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
00558 
00559     /* */
00560     var_Create( p_access, "dvb-satno", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00561     var_Create( p_access, "dvb-voltage", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00562     var_Create( p_access, "dvb-high-voltage", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
00563     var_Create( p_access, "dvb-tone", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00564     var_Create( p_access, "dvb-fec", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00565     var_Create( p_access, "dvb-srate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00566     var_Create( p_access, "dvb-lnb-lof1", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00567     var_Create( p_access, "dvb-lnb-lof2", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00568     var_Create( p_access, "dvb-lnb-slof", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00569 
00570     /* */
00571     var_Create( p_access, "dvb-modulation", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00572 
00573     /* */
00574     var_Create( p_access, "dvb-code-rate-hp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00575     var_Create( p_access, "dvb-code-rate-lp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00576     var_Create( p_access, "dvb-bandwidth", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00577     var_Create( p_access, "dvb-transmission", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00578     var_Create( p_access, "dvb-guard", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00579     var_Create( p_access, "dvb-hierarchy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00580 }
00581 
00582 /* */
00583 static int ParseMRL( access_t *p_access )
00584 {
00585     char *psz_dup = strdup( p_access->psz_path );
00586     char *psz_parser = psz_dup;
00587     char *psz_next;
00588     vlc_value_t         val;
00589 
00590 #define GET_OPTION_INT( option )                                            \
00591     if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
00592     {                                                                       \
00593         val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser,   \
00594                             0 );                                            \
00595         var_Set( p_access, "dvb-" option, val );                            \
00596     }
00597 
00598 #define GET_OPTION_BOOL( option )                                           \
00599     if ( !strncmp( psz_parser, option "=", strlen(option "=") ) )           \
00600     {                                                                       \
00601         val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser,  \
00602                              0 );                                           \
00603         var_Set( p_access, "dvb-" option, val );                            \
00604     }
00605 
00606     /* Test for old syntax */
00607     strtol( psz_parser, &psz_next, 10 );
00608     if( psz_next != psz_parser )
00609     {
00610         msg_Err( p_access, "the DVB input old syntax is deprecated, use vlc "
00611                           "-p dvb to see an explanation of the new syntax" );
00612         free( psz_dup );
00613         return VLC_EGENERIC;
00614     }
00615 
00616     while( *psz_parser )
00617     {
00618         GET_OPTION_INT("adapter")
00619         else GET_OPTION_INT("device")
00620         else GET_OPTION_INT("frequency")
00621         else GET_OPTION_INT("inversion")
00622         else GET_OPTION_BOOL("probe")
00623         else GET_OPTION_BOOL("budget-mode")
00624 
00625         else GET_OPTION_INT("voltage")
00626         else GET_OPTION_BOOL("high-voltage")
00627         else GET_OPTION_INT("tone")
00628         else GET_OPTION_INT("satno")
00629         else GET_OPTION_INT("fec")
00630         else GET_OPTION_INT("srate")
00631         else GET_OPTION_INT("lnb-lof1")
00632         else GET_OPTION_INT("lnb-lof2")
00633         else GET_OPTION_INT("lnb-slof")
00634 
00635         else GET_OPTION_INT("modulation")
00636 
00637         else GET_OPTION_INT("code-rate-hp")
00638         else GET_OPTION_INT("code-rate-lp")
00639         else GET_OPTION_INT("bandwidth")
00640         else GET_OPTION_INT("transmission")
00641         else GET_OPTION_INT("guard")
00642         else GET_OPTION_INT("hierarchy")
00643 
00644         /* Redundant with voltage but much easier to use */
00645         else if( !strncmp( psz_parser, "polarization=",
00646                            strlen( "polarization=" ) ) )
00647         {
00648             psz_parser += strlen( "polarization=" );
00649             if ( *psz_parser == 'V' || *psz_parser == 'v' )
00650                 val.i_int = 13;
00651             else if ( *psz_parser == 'H' || *psz_parser == 'h' )
00652                 val.i_int = 18;
00653             else
00654             {
00655                 msg_Err( p_access, "illegal polarization %c", *psz_parser );
00656                 free( psz_dup );
00657                 return VLC_EGENERIC;
00658             }
00659             var_Set( p_access, "dvb-voltage", val );
00660         }
00661         else
00662         {
00663             msg_Err( p_access, "unknown option (%s)", psz_parser );
00664             free( psz_dup );
00665             return VLC_EGENERIC;
00666         }
00667 
00668         if ( *psz_parser )
00669             psz_parser++;
00670     }
00671 #undef GET_OPTION_INT
00672 #undef GET_OPTION_BOOL
00673 
00674     free( psz_dup );
00675     return VLC_SUCCESS;
00676 }
00677 

Generated on Tue Dec 20 10:14:23 2005 for vlc-0.8.4a by  doxygen 1.4.2