📄 access.c
字号:
/***************************************************************************** * access.c: DVB card input v4l2 only ***************************************************************************** * Copyright (C) 1998-2005 the VideoLAN team * * Authors: Johan Bilien <jobi@via.ecp.fr> * Jean-Paul Saman <jpsaman _at_ videolan _dot_ org> * Christophe Massiot <massiot@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <vlc/vlc.h>#include <vlc/input.h>#ifdef HAVE_UNISTD_H# include <unistd.h>#endif#include <fcntl.h>#include <sys/types.h>#include <sys/poll.h>#include <errno.h>/* Include dvbpsi headers */#ifdef HAVE_DVBPSI_DR_H# include <dvbpsi/dvbpsi.h># include <dvbpsi/descriptor.h># include <dvbpsi/pat.h># include <dvbpsi/pmt.h># include <dvbpsi/dr.h># include <dvbpsi/psi.h>#else# include "dvbpsi.h"# include "descriptor.h"# include "tables/pat.h"# include "tables/pmt.h"# include "descriptors/dr.h"# include "psi.h"#endif#ifdef ENABLE_HTTPD# include "vlc_httpd.h"#endif#include "dvb.h"/***************************************************************************** * Module descriptor *****************************************************************************/static int Open( vlc_object_t *p_this );static void Close( vlc_object_t *p_this );#define CACHING_TEXT N_("Caching value in ms")#define CACHING_LONGTEXT N_( \ "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.")#define DEVICE_TEXT N_("Device number to use on adapter")#define DEVICE_LONGTEXT ""#define FREQ_TEXT N_("Transponder/multiplex frequency")#define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")#define INVERSION_TEXT N_("Inversion mode")#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, 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.")/* Satellite */#define SATNO_TEXT N_("Satellite number in the Diseqc system")#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 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 FEC_TEXT N_("Transponder FEC")#define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto].")#define SRATE_TEXT N_("Transponder symbol rate in kHz")#define SRATE_LONGTEXT ""#define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")#define LNB_LOF1_LONGTEXT ""#define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")#define LNB_LOF2_LONGTEXT ""#define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")#define LNB_SLOF_LONGTEXT ""/* Cable */#define MODULATION_TEXT N_("Modulation type")#define MODULATION_LONGTEXT N_("Modulation type for front-end device.")/* Terrestrial */#define CODE_RATE_HP_TEXT N_("Terrestrial high priority stream code rate (FEC)")#define CODE_RATE_HP_LONGTEXT ""#define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")#define CODE_RATE_LP_LONGTEXT ""#define BANDWIDTH_TEXT N_("Terrestrial bandwidth")#define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")#define GUARD_TEXT N_("Terrestrial guard interval")#define GUARD_LONGTEXT ""#define TRANSMISSION_TEXT N_("Terrestrial transmission mode")#define TRANSMISSION_LONGTEXT ""#define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")#define HIERARCHY_LONGTEXT ""#define HOST_TEXT N_( "HTTP Host address" )#define HOST_LONGTEXT N_( \ "To enable the internal HTTP server, set its address and port here." )#define USER_TEXT N_( "HTTP user name" )#define USER_LONGTEXT N_( \ "User name the administrator will use to log into " \ "the internal HTTP server." )#define PASSWORD_TEXT N_( "HTTP password" )#define PASSWORD_LONGTEXT N_( \ "Password the administrator will use to log into " \ "the internal HTTP server." )#define ACL_TEXT N_( "HTTP ACL" )#define ACL_LONGTEXT N_( \ "Access control list (equivalent to .hosts) file path, " \ "which will limit the range of IPs entitled to log into the internal " \ "HTTP server." )#define CERT_TEXT N_( "Certificate file" )#define CERT_LONGTEXT N_( "HTTP interface x509 PEM certificate file " \ "(enables SSL)" )#define KEY_TEXT N_( "Private key file" )#define KEY_LONGTEXT N_( "HTTP interface x509 PEM private key file" )#define CA_TEXT N_( "Root CA file" )#define CA_LONGTEXT N_( "HTTP interface x509 PEM trusted root CA " \ "certificates file" )#define CRL_TEXT N_( "CRL file" )#define CRL_LONGTEXT N_( "HTTP interface Certificates Revocation List file" )vlc_module_begin(); set_shortname( _("DVB") ); set_description( _("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 ); add_integer( "dvb-adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT, VLC_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 ); add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT, VLC_TRUE ); add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_TRUE ); add_bool( "dvb-budget-mode", 0, NULL, BUDGET_TEXT, BUDGET_LONGTEXT, VLC_TRUE ); /* DVB-S (satellite) */ add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT, VLC_TRUE ); add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT, VLC_TRUE ); add_bool( "dvb-high-voltage", 0, NULL, HIGH_VOLTAGE_TEXT, HIGH_VOLTAGE_LONGTEXT, VLC_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 ); add_integer( "dvb-srate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT, VLC_FALSE ); add_integer( "dvb-lnb-lof1", 0, NULL, LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT, VLC_TRUE ); add_integer( "dvb-lnb-lof2", 0, NULL, LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT, VLC_TRUE ); add_integer( "dvb-lnb-slof", 0, NULL, LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT, VLC_TRUE ); /* DVB-C (cable) */ add_integer( "dvb-modulation", 0, NULL, MODULATION_TEXT, MODULATION_LONGTEXT, VLC_TRUE ); /* DVB-T (terrestrial) */ add_integer( "dvb-code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT, CODE_RATE_HP_LONGTEXT, VLC_TRUE ); add_integer( "dvb-code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT, CODE_RATE_LP_LONGTEXT, VLC_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 ); add_integer( "dvb-transmission", 0, NULL, TRANSMISSION_TEXT, TRANSMISSION_LONGTEXT, VLC_TRUE ); add_integer( "dvb-hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT, VLC_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 ); add_string( "dvb-http-user", NULL, NULL, USER_TEXT, USER_LONGTEXT, VLC_TRUE ); add_string( "dvb-http-password", NULL, NULL, PASSWORD_TEXT, PASSWORD_LONGTEXT, VLC_TRUE ); add_string( "dvb-http-acl", NULL, NULL, ACL_TEXT, ACL_LONGTEXT, VLC_TRUE ); add_string( "dvb-http-intf-cert", NULL, NULL, CERT_TEXT, CERT_LONGTEXT, VLC_TRUE ); add_string( "dvb-http-intf-key", NULL, NULL, KEY_TEXT, KEY_LONGTEXT, VLC_TRUE ); add_string( "dvb-http-intf-ca", NULL, NULL, CA_TEXT, CA_LONGTEXT, VLC_TRUE ); add_string( "dvb-http-intf-crl", NULL, NULL, CRL_TEXT, CRL_LONGTEXT, VLC_TRUE );#endif set_capability( "access2", 0 ); add_shortcut( "dvb" ); add_shortcut( "dvb-s" ); add_shortcut( "qpsk" ); add_shortcut( "dvb-c" ); add_shortcut( "cable" ); add_shortcut( "dvb-t" ); add_shortcut( "terrestrial" ); add_shortcut( "satellite" ); /* compatibility with the interface. */ set_callbacks( Open, Close );vlc_module_end();/***************************************************************************** * Local prototypes *****************************************************************************/static block_t *Block( access_t * );static int Control( access_t *, int, va_list );#define DVB_READ_ONCE 20#define DVB_READ_ONCE_START 2#define TS_PACKET_SIZE 188static 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 );static void VarInit( access_t * );static int ParseMRL( access_t * );/***************************************************************************** * Open: open the frontend device *****************************************************************************/static int Open( vlc_object_t *p_this ){ access_t *p_access = (access_t*)p_this; access_sys_t *p_sys; /* Only if selected */ if( *p_access->psz_access == '\0' ) return VLC_EGENERIC; /* Set up access */ p_access->pf_read = NULL; 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; p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); memset( p_sys, 0, sizeof( access_sys_t ) ); /* Create all variables */ VarInit( p_access ); /* Parse the command line */ if( ParseMRL( p_access ) ) { free( p_sys ); return VLC_EGENERIC; } /* Getting frontend info */ if( E_(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 ) { E_(FrontendClose)( p_access ); free( p_sys ); return VLC_EGENERIC; } /* Opening DVR device */ if( E_(DVROpen)( p_access ) < 0 ) { E_(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 ) { 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 ); 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;}/***************************************************************************** * Close : Close the device *****************************************************************************/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 ); E_(DVRClose)( p_access ); E_(FrontendClose)( p_access ); E_(CAMClose)( p_access );#ifdef ENABLE_HTTPD E_(HTTPClose)( p_access );#endif free( p_sys );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -