⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 access.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * access.c: Satellite card input ***************************************************************************** * Copyright (C) 1998-2003 VideoLAN * * Authors: Johan Bilien <jobi@via.ecp.fr> *          Christophe Massiot <massiot@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., 59 Temple Place - Suite 330, Boston, MA  02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdio.h>#include <stdlib.h>#include <vlc/vlc.h>#include <vlc/input.h>#include "../../demux/mpeg/system.h"#ifdef HAVE_UNISTD_H#   include <unistd.h>#endif#include <fcntl.h>#include <sys/types.h>#include <string.h>#include <errno.h>#ifdef STRNCASECMP_IN_STRINGS_H#   include <strings.h>#endif#include "dvb.h"/* These are for the Dreambox port. I have no idea whether they're correct * for other DVB adapters. --Meuuh */#define SATELLITE_READ_ONCE (64 * 1024)#define DMX_BUFFER_SIZE (1024 * 1024)/***************************************************************************** * Local prototypes *****************************************************************************/static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,                                     size_t i_len );static int     SatelliteSetArea    ( input_thread_t *, input_area_t * );static int     SatelliteSetProgram ( input_thread_t *, pgrm_descriptor_t * );static void    SatelliteSeek       ( input_thread_t *, off_t );typedef struct demux_handle_t{    int i_pid;    int i_handle;    int i_type;} demux_handle_t;#define PAT_TYPE 1#define PMT_TYPE 2#define ES_TYPE 3#define MAX_DEMUX 8 typedef struct thread_sat_data_t{    int i_handle;    demux_handle_t p_demux_handles[MAX_DEMUX];} thread_sat_data_t;static void AllocateDemux( input_thread_t * p_input, int i_pid,                           int i_type ){    thread_sat_data_t * p_satellite = (thread_sat_data_t *)p_input->p_access_data;    int                 i_demux;    int                 i;    i_demux = config_GetInt( p_input, "dvb-dmx" );    /* Find first free slot */    for ( i = 0; i < MAX_DEMUX; i++ )    {        if ( !p_satellite->p_demux_handles[i].i_type )        {            if (ioctl_SetDMXFilter( i_demux, i_pid, &p_satellite->p_demux_handles[i].i_handle, 3) < 0)            {                msg_Warn(p_input, "ioctl_SetDMXFilter failed (%d)", i_pid);                break;            }            p_satellite->p_demux_handles[i].i_type = i_type;            p_satellite->p_demux_handles[i].i_pid = i_pid;            break;        }    }}static void CloseProgram( input_thread_t * p_input ){    thread_sat_data_t * p_satellite = (thread_sat_data_t *)p_input->p_access_data;    int i;    for ( i = 1; i < MAX_DEMUX; i++ )    {        if ( p_satellite->p_demux_handles[i].i_type )        {            ioctl_UnsetDMXFilter( p_satellite->p_demux_handles[i].i_handle );            p_satellite->p_demux_handles[i].i_type = 0;        }    }}/***************************************************************************** * Open: open the dvr device *****************************************************************************/int E_(Open) ( vlc_object_t *p_this ){    input_thread_t *    p_input = (input_thread_t *)p_this;    thread_sat_data_t * p_satellite;    char *              psz_parser;    char *              psz_next;    int                 i_freq = 0;    int                 i_srate = 0;    vlc_bool_t          b_pol = 0;    int                 i_fec = 0;    float               f_fec = 1./2;    vlc_bool_t          b_diseqc;    int                 i_lnb_lof1;    int                 i_lnb_lof2;    int                 i_lnb_slof;    int                 i_demux;    char                psz_dvr[255];    i_demux = config_GetInt( p_input, "dvb-dmx" );    snprintf(psz_dvr, sizeof(psz_dvr), DVR "%d", i_demux);    /* parse the options passed in command line : */    psz_parser = strdup( p_input->psz_name );    if( !psz_parser )    {        return( -1 );    }    p_input->pf_read = SatelliteRead;    p_input->pf_set_program = SatelliteSetProgram;    p_input->pf_set_area = SatelliteSetArea;    p_input->pf_seek = SatelliteSeek;    i_freq = (int)strtol( psz_parser, &psz_next, 10 );    if( *psz_next )    {        psz_parser = psz_next + 1;        b_pol = (vlc_bool_t)strtol( psz_parser, &psz_next, 10 );            if( *psz_next )            {                psz_parser = psz_next + 1;                i_fec = (int)strtol( psz_parser, &psz_next, 10 );                if( *psz_next )                {                    psz_parser = psz_next + 1;                    i_srate = (int)strtol( psz_parser, &psz_next, 10 );                }            }    }    if( i_freq > (12999*1000) || i_freq < (10000*1000) )    {        msg_Warn( p_input, "invalid frequency, using default one" );        i_freq = config_GetInt( p_input, "frequency" );        if( i_freq && (i_freq > (12999*1000) || i_freq < (10000*1000)) )        {            msg_Err( p_input, "invalid default frequency" );            return -1;        }    }    if( i_freq && (i_srate > (30000*1000) || i_srate < (1000*1000)) )    {        msg_Warn( p_input, "invalid symbol rate, using default one" );        i_srate = config_GetInt( p_input, "symbol-rate" );        if( i_srate > (30000*1000) || i_srate < (1000*1000) )        {            msg_Err( p_input, "invalid default symbol rate" );            return -1;        }    }    if( i_freq && b_pol && b_pol != 1 )    {        msg_Warn( p_input, "invalid polarization, using default one" );        b_pol = config_GetInt( p_input, "polarization" );        if( b_pol && b_pol != 1 )        {            msg_Err( p_input, "invalid default polarization" );            return -1;        }    }    if( i_freq && (i_fec > 7 || i_fec < 1) )    {        msg_Warn( p_input, "invalid FEC, using default one" );        i_fec = config_GetInt( p_input, "fec" );        if( i_fec > 7 || i_fec < 1 )        {            msg_Err( p_input, "invalid default FEC" );            return -1;        }    }    if ( i_freq )    {        switch( i_fec )        {            case 1:                f_fec = 1./2;                break;            case 2:                f_fec = 2./3;                break;            case 3:                f_fec = 3./4;                break;            case 4:                f_fec = 4./5;                break;            case 5:                f_fec = 5./6;                break;            case 6:                f_fec = 6./7;                break;            case 7:                f_fec = 7./8;                break;            default:                /* cannot happen */                break;        }    }    /* Initialise structure */    p_satellite = malloc( sizeof( thread_sat_data_t ) );    if( p_satellite == NULL )    {        msg_Err( p_input, "out of memory" );        return -1;    }    memset( p_satellite, 0, sizeof( thread_sat_data_t ) );    p_input->p_access_data = (void *)p_satellite;    /* Open the DVR device */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -