1 /*****************************************************************************
2 * access.c: DVB card input v4l2 only
3 *****************************************************************************
4 * Copyright (C) 1998-2005 the VideoLAN team
6 * Authors: Johan Bilien <jobi@via.ecp.fr>
7 * Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
8 * Christophe Massiot <massiot@via.ecp.fr>
9 * Laurent Aimar <fenrir@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
34 #include <vlc_common.h>
35 #include <vlc_plugin.h>
36 #include <vlc_access.h>
37 #include <vlc_input.h>
38 #include <vlc_interface.h>
39 #include <vlc_dialog.h>
45 #include <sys/types.h>
50 /* Include dvbpsi headers */
51 #ifdef HAVE_DVBPSI_DR_H
52 # include <dvbpsi/dvbpsi.h>
53 # include <dvbpsi/descriptor.h>
54 # include <dvbpsi/pat.h>
55 # include <dvbpsi/pmt.h>
56 # include <dvbpsi/dr.h>
57 # include <dvbpsi/psi.h>
58 # include <dvbpsi/demux.h>
59 # include <dvbpsi/sdt.h>
62 # include "descriptor.h"
63 # include "tables/pat.h"
64 # include "tables/pmt.h"
65 # include "descriptors/dr.h"
68 # include "tables/sdt.h"
72 # include <vlc_httpd.h>
77 /*****************************************************************************
79 *****************************************************************************/
80 static int Open( vlc_object_t *p_this );
81 static void Close( vlc_object_t *p_this );
83 #define CACHING_TEXT N_("Caching value in ms")
84 #define CACHING_LONGTEXT N_( \
85 "Caching value for DVB streams. This " \
86 "value should be set in milliseconds." )
88 #define ADAPTER_TEXT N_("Adapter card to tune")
89 #define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.")
91 #define DEVICE_TEXT N_("Device number to use on adapter")
92 #define DEVICE_LONGTEXT ""
94 #define FREQ_TEXT N_("Transponder/multiplex frequency")
95 #define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
97 #define INVERSION_TEXT N_("Inversion mode")
98 #define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]")
100 #define PROBE_TEXT N_("Probe DVB card for capabilities")
101 #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.")
103 #define BUDGET_TEXT N_("Budget mode")
104 #define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder with a \"budget\" card.")
107 #define SATNO_TEXT N_("Satellite number in the Diseqc system")
108 #define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=satellite number].")
110 #define VOLTAGE_TEXT N_("LNB voltage")
111 #define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal].")
113 #define HIGH_VOLTAGE_TEXT N_("High LNB voltage")
114 #define HIGH_VOLTAGE_LONGTEXT N_("Enable high voltage if your cables are " \
115 "particularly long. This is not supported by all frontends.")
117 #define TONE_TEXT N_("22 kHz tone")
118 #define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto].")
120 #define FEC_TEXT N_("Transponder FEC")
121 #define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto].")
123 #define SRATE_TEXT N_("Transponder symbol rate in kHz")
124 #define SRATE_LONGTEXT ""
126 #define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
127 #define LNB_LOF1_LONGTEXT ""
129 #define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
130 #define LNB_LOF2_LONGTEXT ""
132 #define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
133 #define LNB_SLOF_LONGTEXT ""
136 #define MODULATION_TEXT N_("Modulation type")
137 #define MODULATION_LONGTEXT N_("Modulation type for front-end device.")
140 #define CODE_RATE_HP_TEXT N_("Terrestrial high priority stream code rate (FEC)")
141 #define CODE_RATE_HP_LONGTEXT ""
143 #define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
144 #define CODE_RATE_LP_LONGTEXT ""
146 #define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
147 #define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
149 #define GUARD_TEXT N_("Terrestrial guard interval")
150 #define GUARD_LONGTEXT ""
152 #define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
153 #define TRANSMISSION_LONGTEXT ""
155 #define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
156 #define HIERARCHY_LONGTEXT ""
158 #define HOST_TEXT N_( "HTTP Host address" )
159 #define HOST_LONGTEXT N_( \
160 "To enable the internal HTTP server, set its address and port here." )
162 #define USER_TEXT N_( "HTTP user name" )
163 #define USER_LONGTEXT N_( \
164 "User name the administrator will use to log into " \
165 "the internal HTTP server." )
167 #define PASSWORD_TEXT N_( "HTTP password" )
168 #define PASSWORD_LONGTEXT N_( \
169 "Password the administrator will use to log into " \
170 "the internal HTTP server." )
172 #define ACL_TEXT N_( "HTTP ACL" )
173 #define ACL_LONGTEXT N_( \
174 "Access control list (equivalent to .hosts) file path, " \
175 "which will limit the range of IPs entitled to log into the internal " \
178 #define CERT_TEXT N_( "Certificate file" )
179 #define CERT_LONGTEXT N_( "HTTP interface x509 PEM certificate file " \
182 #define KEY_TEXT N_( "Private key file" )
183 #define KEY_LONGTEXT N_( "HTTP interface x509 PEM private key file" )
185 #define CA_TEXT N_( "Root CA file" )
186 #define CA_LONGTEXT N_( "HTTP interface x509 PEM trusted root CA " \
187 "certificates file" )
189 #define CRL_TEXT N_( "CRL file" )
190 #define CRL_LONGTEXT N_( "HTTP interface Certificates Revocation List file" )
193 set_shortname( N_("DVB") )
194 set_description( N_("DVB input with v4l2 support") )
195 set_category( CAT_INPUT )
196 set_subcategory( SUBCAT_INPUT_ACCESS )
198 add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
199 CACHING_LONGTEXT, true )
201 add_integer( "dvb-adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT,
203 add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
205 add_integer( "dvb-frequency", 0, NULL, FREQ_TEXT, FREQ_LONGTEXT,
208 add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT,
210 add_bool( "dvb-probe", true, NULL, PROBE_TEXT, PROBE_LONGTEXT, true )
211 add_bool( "dvb-budget-mode", false, NULL, BUDGET_TEXT, BUDGET_LONGTEXT,
213 /* DVB-S (satellite) */
214 add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT,
216 add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT,
218 add_bool( "dvb-high-voltage", false, NULL, HIGH_VOLTAGE_TEXT,
219 HIGH_VOLTAGE_LONGTEXT, true )
220 add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT,
222 add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, true )
223 add_integer( "dvb-srate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT,
225 add_integer( "dvb-lnb-lof1", 0, NULL, LNB_LOF1_TEXT,
226 LNB_LOF1_LONGTEXT, true )
227 add_integer( "dvb-lnb-lof2", 0, NULL, LNB_LOF2_TEXT,
228 LNB_LOF2_LONGTEXT, true )
229 add_integer( "dvb-lnb-slof", 0, NULL, LNB_SLOF_TEXT,
230 LNB_SLOF_LONGTEXT, true )
232 add_integer( "dvb-modulation", 0, NULL, MODULATION_TEXT,
233 MODULATION_LONGTEXT, true )
234 /* DVB-T (terrestrial) */
235 add_integer( "dvb-code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT,
236 CODE_RATE_HP_LONGTEXT, true )
237 add_integer( "dvb-code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT,
238 CODE_RATE_LP_LONGTEXT, true )
239 add_integer( "dvb-bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
242 add_integer( "dvb-guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, true )
243 add_integer( "dvb-transmission", 0, NULL, TRANSMISSION_TEXT,
244 TRANSMISSION_LONGTEXT, true )
245 add_integer( "dvb-hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
248 /* MMI HTTP interface */
249 set_section( N_("HTTP server" ), 0 )
250 add_string( "dvb-http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT,
252 add_string( "dvb-http-user", NULL, NULL, USER_TEXT, USER_LONGTEXT,
254 add_password( "dvb-http-password", NULL, NULL, PASSWORD_TEXT,
255 PASSWORD_LONGTEXT, true )
256 add_string( "dvb-http-acl", NULL, NULL, ACL_TEXT, ACL_LONGTEXT,
258 add_string( "dvb-http-intf-cert", NULL, NULL, CERT_TEXT, CERT_LONGTEXT,
260 add_string( "dvb-http-intf-key", NULL, NULL, KEY_TEXT, KEY_LONGTEXT,
262 add_string( "dvb-http-intf-ca", NULL, NULL, CA_TEXT, CA_LONGTEXT,
264 add_string( "dvb-http-intf-crl", NULL, NULL, CRL_TEXT, CRL_LONGTEXT,
268 set_capability( "access", 0 )
269 add_shortcut( "dvb", /* Generic name */
270 "dvb-s", "qpsk", "satellite", /* Satellite */
271 "dvb-c", "cable", /* Cable */
272 "dvb-t", "terrestrial", /* Terrestrial */
274 add_shortcut( "usdigital" )
276 set_callbacks( Open, Close )
281 /*****************************************************************************
283 *****************************************************************************/
284 static block_t *Block( access_t * );
285 static int Control( access_t *, int, va_list );
287 static block_t *BlockScan( access_t * );
289 #define DVB_READ_ONCE 20
290 #define DVB_READ_ONCE_START 2
291 #define DVB_READ_ONCE_SCAN 1
292 #define TS_PACKET_SIZE 188
294 #define DVB_SCAN_MAX_SIGNAL_TIME (1000*1000)
295 #define DVB_SCAN_MAX_LOCK_TIME (5000*1000)
296 #define DVB_SCAN_MAX_PROBE_TIME (45000*1000)
298 static void FilterUnset( access_t *, int i_max );
299 static void FilterUnsetPID( access_t *, int i_pid );
300 static void FilterSet( access_t *, int i_pid, int i_type );
302 static void VarInit( access_t * );
303 static int ParseMRL( access_t * );
305 /*****************************************************************************
306 * Open: open the frontend device
307 *****************************************************************************/
308 static int Open( vlc_object_t *p_this )
310 access_t *p_access = (access_t*)p_this;
313 /* Only if selected */
314 if( *p_access->psz_access == '\0' )
318 p_access->pf_read = NULL;
319 p_access->pf_block = Block;
320 p_access->pf_control = Control;
321 p_access->pf_seek = NULL;
323 access_InitFields( p_access );
325 p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
329 /* Create all variables */
332 /* Parse the command line */
333 if( ParseMRL( p_access ) )
339 /* Getting frontend info */
340 if( FrontendOpen( p_access) )
347 p_sys->b_scan_mode = var_GetInteger( p_access, "dvb-frequency" ) == 0;
348 if( p_sys->b_scan_mode )
350 msg_Dbg( p_access, "DVB scan mode selected" );
351 p_access->pf_block = BlockScan;
355 /* Setting frontend parameters for tuning the hardware */
356 msg_Dbg( p_access, "trying to tune the frontend...");
357 if( FrontendSet( p_access ) < 0 )
359 FrontendClose( p_access );
365 /* Opening DVR device */
366 if( DVROpen( p_access ) < 0 )
368 FrontendClose( p_access );
373 if( p_sys->b_scan_mode )
375 scan_parameter_t parameter;
377 msg_Dbg( p_access, "setting filter on PAT/NIT/SDT (DVB only)" );
378 FilterSet( p_access, 0x00, OTHER_TYPE ); // PAT
379 FilterSet( p_access, 0x10, OTHER_TYPE ); // NIT
380 FilterSet( p_access, 0x11, OTHER_TYPE ); // SDT
382 if( FrontendGetScanParameter( p_access, ¶meter ) ||
383 scan_Init( VLC_OBJECT(p_access), &p_sys->scan, ¶meter ) )
385 Close( VLC_OBJECT(p_access) );
391 p_sys->b_budget_mode = var_GetBool( p_access, "dvb-budget-mode" );
392 if( p_sys->b_budget_mode )
394 msg_Dbg( p_access, "setting filter on all PIDs" );
395 FilterSet( p_access, 0x2000, OTHER_TYPE );
399 msg_Dbg( p_access, "setting filter on PAT" );
400 FilterSet( p_access, 0x0, OTHER_TYPE );
406 HTTPOpen( p_access );
410 if( p_sys->b_scan_mode )
411 p_sys->i_read_once = DVB_READ_ONCE_SCAN;
412 else if( p_sys->b_budget_mode )
413 p_sys->i_read_once = DVB_READ_ONCE;
415 p_sys->i_read_once = DVB_READ_ONCE_START;
417 free( p_access->psz_demux );
418 p_access->psz_demux = strdup( p_sys->b_scan_mode ? "m3u8" : "ts" );
422 /*****************************************************************************
423 * Close : Close the device
424 *****************************************************************************/
425 static void Close( vlc_object_t *p_this )
427 access_t *p_access = (access_t*)p_this;
428 access_sys_t *p_sys = p_access->p_sys;
430 FilterUnset( p_access, p_sys->b_budget_mode && !p_sys->b_scan_mode ? 1 : MAX_DEMUX );
432 DVRClose( p_access );
433 FrontendClose( p_access );
434 if( p_sys->b_scan_mode )
435 scan_Clean( &p_sys->scan );
437 CAMClose( p_access );
440 if( !p_sys->b_scan_mode )
441 HTTPClose( p_access );
447 /*****************************************************************************
449 *****************************************************************************/
450 static block_t *Block( access_t *p_access )
452 access_sys_t *p_sys = p_access->p_sys;
457 struct pollfd ufds[2];
460 /* Initialize file descriptor sets */
461 memset (ufds, 0, sizeof (ufds));
462 ufds[0].fd = p_sys->i_handle;
463 ufds[0].events = POLLIN;
464 ufds[1].fd = p_sys->i_frontend_handle;
465 ufds[1].events = POLLPRI;
467 /* We'll wait 0.5 second if nothing happens */
468 /* Find if some data is available */
469 i_ret = poll( ufds, 2, 500 );
471 if ( !vlc_object_alive (p_access) )
479 msg_Err( p_access, "poll error: %m" );
483 if ( p_sys->i_ca_handle && mdate() > p_sys->i_ca_next_event )
486 p_sys->i_ca_next_event = mdate() + p_sys->i_ca_timeout;
489 if ( ufds[1].revents )
491 FrontendPoll( p_access );
495 if ( p_sys->i_httpd_timeout && mdate() > p_sys->i_httpd_timeout )
497 vlc_mutex_lock( &p_sys->httpd_mutex );
498 if ( p_sys->b_request_frontend_info )
500 msg_Warn( p_access, "frontend timeout for HTTP interface" );
501 p_sys->b_request_frontend_info = false;
502 p_sys->psz_frontend_info = strdup( "Timeout getting info\n" );
504 if ( p_sys->b_request_mmi_info )
506 msg_Warn( p_access, "MMI timeout for HTTP interface" );
507 p_sys->b_request_mmi_info = false;
508 p_sys->psz_mmi_info = strdup( "Timeout getting info\n" );
510 vlc_cond_signal( &p_sys->httpd_cond );
511 vlc_mutex_unlock( &p_sys->httpd_mutex );
514 if ( p_sys->b_request_frontend_info )
516 FrontendStatus( p_access );
519 if ( p_sys->b_request_mmi_info )
521 CAMStatus( p_access );
525 if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout )
527 msg_Warn( p_access, "no lock, tuning again" );
528 FrontendSet( p_access );
531 if ( ufds[0].revents )
533 p_block = block_New( p_access,
534 p_sys->i_read_once * TS_PACKET_SIZE );
535 if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer,
536 p_sys->i_read_once * TS_PACKET_SIZE ) ) <= 0 )
538 msg_Warn( p_access, "read failed (%m)" );
539 block_Release( p_block );
542 p_block->i_buffer = i_ret;
547 if( p_sys->i_read_once < DVB_READ_ONCE )
548 p_sys->i_read_once++;
550 /* Update moderatly the signal properties */
551 if( (p_sys->i_stat_counter++ % 100) == 0 )
552 p_access->info.i_update |= INPUT_UPDATE_SIGNAL;
557 /*****************************************************************************
559 *****************************************************************************/
560 static block_t *BlockScan( access_t *p_access )
562 access_sys_t *p_sys = p_access->p_sys;
563 scan_t *p_scan = &p_sys->scan;
564 scan_configuration_t cfg;
565 scan_session_t session;
568 if( scan_Next( p_scan, &cfg ) )
570 const bool b_first_eof = !p_access->info.b_eof;
573 msg_Warn( p_access, "Scanning finished" );
576 p_access->info.b_eof = true;
577 return b_first_eof ? scan_GetM3U( p_scan ) : NULL;
582 if( scan_session_Init( VLC_OBJECT(p_access), &session, &cfg ) )
586 msg_Dbg( p_access, "Scanning frequency %d", cfg.i_frequency );
587 var_SetInteger( p_access, "dvb-frequency", cfg.i_frequency );
588 var_SetInteger( p_access, "dvb-bandwidth", cfg.i_bandwidth );
590 /* Setting frontend parameters for tuning the hardware */
591 if( FrontendSet( p_access ) < 0 )
593 msg_Err( p_access, "Failed to tune the frontend" );
594 p_access->info.b_eof = true;
599 int64_t i_scan_start = mdate();
601 bool b_has_dvb_signal = false;
602 bool b_has_lock = false;
607 struct pollfd ufds[2];
610 /* Initialize file descriptor sets */
611 memset (ufds, 0, sizeof (ufds));
612 ufds[0].fd = p_sys->i_handle;
613 ufds[0].events = POLLIN;
614 ufds[1].fd = p_sys->i_frontend_handle;
615 ufds[1].events = POLLPRI;
617 /* We'll wait 0.1 second if nothing happens */
618 /* Find if some data is available */
619 i_ret = poll( ufds, 2, 100 );
621 if( !vlc_object_alive (p_access) || scan_IsCancelled( p_scan ) )
626 const mtime_t i_scan_time = mdate() - i_scan_start;
627 frontend_status_t status;
629 FrontendGetStatus( p_access, &status );
631 b_has_dvb_signal |= status.b_has_carrier;
632 b_has_lock |= status.b_has_lock;
634 if( ( !b_has_dvb_signal && i_scan_time > DVB_SCAN_MAX_SIGNAL_TIME ) ||
635 ( !b_has_lock && i_scan_time > DVB_SCAN_MAX_LOCK_TIME ) ||
636 ( i_scan_time > DVB_SCAN_MAX_PROBE_TIME ) )
638 msg_Dbg( p_access, "timed out scanning current frequency (s=%d l=%d)", b_has_dvb_signal, b_has_lock );
648 msg_Err( p_access, "poll error: %m" );
649 scan_session_Clean( p_scan, &session );
651 p_access->info.b_eof = true;
655 if( ufds[1].revents )
657 frontend_statistic_t stat;
659 FrontendPoll( p_access );
661 if( !FrontendGetStatistic( p_access, &stat ) )
663 if( stat.i_snr > i_best_snr )
664 i_best_snr = stat.i_snr;
668 if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout )
670 msg_Warn( p_access, "no lock, tuning again" );
671 FrontendSet( p_access );
674 if ( ufds[0].revents )
676 const int i_read_once = 1;
677 block_t *p_block = block_New( p_access, i_read_once * TS_PACKET_SIZE );
679 if( ( i_ret = read( p_sys->i_handle, p_block->p_buffer,
680 i_read_once * TS_PACKET_SIZE ) ) <= 0 )
682 msg_Warn( p_access, "read failed (%m)" );
683 block_Release( p_block );
686 p_block->i_buffer = i_ret;
689 if( scan_session_Push( &session, p_block ) )
691 msg_Dbg( p_access, "finished scanning current frequency" );
699 scan_service_SetSNR( &session, i_best_snr );
701 scan_session_Clean( p_scan, &session );
705 /*****************************************************************************
707 *****************************************************************************/
708 static int Control( access_t *p_access, int i_query, va_list args )
710 access_sys_t *p_sys = p_access->p_sys;
711 bool *pb_bool, b_bool;
716 frontend_statistic_t stat;
721 case ACCESS_CAN_SEEK:
722 case ACCESS_CAN_FASTSEEK:
723 case ACCESS_CAN_PAUSE:
724 case ACCESS_CAN_CONTROL_PACE:
725 pb_bool = (bool*)va_arg( args, bool* );
729 case ACCESS_GET_PTS_DELAY:
730 pi_64 = (int64_t*)va_arg( args, int64_t * );
731 *pi_64 = var_GetInteger( p_access, "dvb-caching" ) * 1000;
735 case ACCESS_SET_PAUSE_STATE:
736 case ACCESS_GET_TITLE_INFO:
737 case ACCESS_SET_TITLE:
738 case ACCESS_SET_SEEKPOINT:
739 case ACCESS_GET_CONTENT_TYPE:
742 case ACCESS_GET_SIGNAL:
743 pf1 = (double*)va_arg( args, double * );
744 pf2 = (double*)va_arg( args, double * );
747 if( !FrontendGetStatistic( p_access, &stat ) )
749 *pf1 = (double)stat.i_snr / 65535.0;
750 *pf2 = (double)stat.i_signal_strenth / 65535.0;
754 case ACCESS_SET_PRIVATE_ID_STATE:
755 if( p_sys->b_scan_mode )
758 i_int = (int)va_arg( args, int ); /* Private data (pid for now)*/
759 b_bool = (bool)va_arg( args, int ); /* b_selected */
760 if( !p_sys->b_budget_mode )
762 /* FIXME we may want to give the real type (me ?, I don't ;) */
764 FilterSet( p_access, i_int, OTHER_TYPE );
766 FilterUnsetPID( p_access, i_int );
770 case ACCESS_SET_PRIVATE_ID_CA:
771 if( p_sys->b_scan_mode )
774 p_pmt = (dvbpsi_pmt_t *)va_arg( args, dvbpsi_pmt_t * );
776 CAMSet( p_access, p_pmt );
780 msg_Warn( p_access, "unimplemented query in control" );
787 /*****************************************************************************
788 * FilterSet/FilterUnset:
789 *****************************************************************************/
790 static void FilterSet( access_t *p_access, int i_pid, int i_type )
792 access_sys_t *p_sys = p_access->p_sys;
795 /* Find first free slot */
796 for( i = 0; i < MAX_DEMUX; i++ )
798 if( !p_sys->p_demux_handles[i].i_type )
801 if( p_sys->p_demux_handles[i].i_pid == i_pid )
802 return; /* Already set */
807 msg_Err( p_access, "no free p_demux_handles !" );
811 if( DMXSetFilter( p_access, i_pid,
812 &p_sys->p_demux_handles[i].i_handle, i_type ) )
814 msg_Err( p_access, "DMXSetFilter failed" );
817 p_sys->p_demux_handles[i].i_type = i_type;
818 p_sys->p_demux_handles[i].i_pid = i_pid;
820 if( p_sys->i_read_once < DVB_READ_ONCE )
821 p_sys->i_read_once++;
824 static void FilterUnset( access_t *p_access, int i_max )
826 access_sys_t *p_sys = p_access->p_sys;
829 for( i = 0; i < i_max; i++ )
831 if( p_sys->p_demux_handles[i].i_type )
833 DMXUnsetFilter( p_access, p_sys->p_demux_handles[i].i_handle );
834 p_sys->p_demux_handles[i].i_type = 0;
839 static void FilterUnsetPID( access_t *p_access, int i_pid )
841 access_sys_t *p_sys = p_access->p_sys;
844 for( i = 0; i < MAX_DEMUX; i++ )
846 if( p_sys->p_demux_handles[i].i_type &&
847 p_sys->p_demux_handles[i].i_pid == i_pid )
849 DMXUnsetFilter( p_access, p_sys->p_demux_handles[i].i_handle );
850 p_sys->p_demux_handles[i].i_type = 0;
855 /*****************************************************************************
857 *****************************************************************************/
858 static void VarInit( access_t *p_access )
861 var_Create( p_access, "dvb-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
864 var_Create( p_access, "dvb-adapter", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
865 var_Create( p_access, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
866 var_Create( p_access, "dvb-frequency", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
867 var_Create( p_access, "dvb-inversion", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
868 var_Create( p_access, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
869 var_Create( p_access, "dvb-budget-mode", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
872 var_Create( p_access, "dvb-satno", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
873 var_Create( p_access, "dvb-voltage", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
874 var_Create( p_access, "dvb-high-voltage", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
875 var_Create( p_access, "dvb-tone", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
876 var_Create( p_access, "dvb-fec", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
877 var_Create( p_access, "dvb-srate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
878 var_Create( p_access, "dvb-lnb-lof1", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
879 var_Create( p_access, "dvb-lnb-lof2", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
880 var_Create( p_access, "dvb-lnb-slof", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
883 var_Create( p_access, "dvb-modulation", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
886 var_Create( p_access, "dvb-code-rate-hp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
887 var_Create( p_access, "dvb-code-rate-lp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
888 var_Create( p_access, "dvb-bandwidth", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
889 var_Create( p_access, "dvb-transmission", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
890 var_Create( p_access, "dvb-guard", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
891 var_Create( p_access, "dvb-hierarchy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
894 var_Create( p_access, "dvb-http-host", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
895 var_Create( p_access, "dvb-http-user", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
896 var_Create( p_access, "dvb-http-password", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
897 var_Create( p_access, "dvb-http-acl", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
898 var_Create( p_access, "dvb-http-intf-cert", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
899 var_Create( p_access, "dvb-http-intf-key", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
900 var_Create( p_access, "dvb-http-intf-ca", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
901 var_Create( p_access, "dvb-http-intf-crl", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
906 static int ParseMRL( access_t *p_access )
908 char *psz_dup = strdup( p_access->psz_location );
909 char *psz_parser = psz_dup;
913 #define GET_OPTION_INT( option ) \
914 if ( !strncmp( psz_parser, option "=", strlen(option "=") ) ) \
916 val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser, \
918 var_Set( p_access, "dvb-" option, val ); \
921 #define GET_OPTION_BOOL( option ) \
922 if ( !strncmp( psz_parser, option "=", strlen(option "=") ) ) \
924 val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser, \
926 var_Set( p_access, "dvb-" option, val ); \
929 /* Test for old syntax */
930 strtol( psz_parser, &psz_next, 10 );
931 if( psz_next != psz_parser )
933 msg_Err( p_access, "the DVB input old syntax is deprecated, use vlc "
934 "-p dvb to see an explanation of the new syntax" );
935 dialog_FatalWait( p_access, _("Input syntax is deprecated"), "%s",
936 _("The given syntax is deprecated. Run \"vlc -p dvb\" to see an " \
937 "explanation of the new syntax.") );
944 GET_OPTION_INT("adapter")
945 else GET_OPTION_INT("device")
946 else GET_OPTION_INT("frequency")
947 else GET_OPTION_INT("inversion")
948 else GET_OPTION_BOOL("probe")
949 else GET_OPTION_BOOL("budget-mode")
951 else GET_OPTION_INT("voltage")
952 else GET_OPTION_BOOL("high-voltage")
953 else GET_OPTION_INT("tone")
954 else GET_OPTION_INT("satno")
955 else GET_OPTION_INT("fec")
956 else GET_OPTION_INT("srate")
957 else GET_OPTION_INT("lnb-lof1")
958 else GET_OPTION_INT("lnb-lof2")
959 else GET_OPTION_INT("lnb-slof")
961 else GET_OPTION_INT("modulation")
963 else GET_OPTION_INT("code-rate-hp")
964 else GET_OPTION_INT("code-rate-lp")
965 else GET_OPTION_INT("bandwidth")
966 else GET_OPTION_INT("transmission")
967 else GET_OPTION_INT("guard")
968 else GET_OPTION_INT("hierarchy")
970 /* Redundant with voltage but much easier to use */
971 else if( !strncmp( psz_parser, "polarization=",
972 strlen( "polarization=" ) ) )
974 psz_parser += strlen( "polarization=" );
975 if ( *psz_parser == 'V' || *psz_parser == 'v' )
977 else if ( *psz_parser == 'H' || *psz_parser == 'h' )
981 msg_Err( p_access, "illegal polarization %c", *psz_parser );
982 dialog_Fatal( p_access, _("Invalid polarization"),
983 _("The provided polarization \"%c\" is not valid."),
988 var_Set( p_access, "dvb-voltage", val );
992 msg_Err( p_access, "unknown option (%s)", psz_parser );
1000 #undef GET_OPTION_INT
1001 #undef GET_OPTION_BOOL