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

📄 linux_dvb.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 5 页
字号:
    fe_sec_voltage_t    fe_voltage;    var_Get( p_access, "dvb-voltage", &val );    msg_Dbg( p_access, "using voltage=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_voltage = SEC_VOLTAGE_OFF; break;        case 13: fe_voltage = SEC_VOLTAGE_13; break;        case 18: fe_voltage = SEC_VOLTAGE_18; break;        default:            fe_voltage = SEC_VOLTAGE_OFF;            msg_Err( p_access, "argument has invalid voltage (%d)", val.i_int );            break;    }    return fe_voltage;}static fe_sec_tone_mode_t DecodeTone( access_t *p_access ){    vlc_value_t         val;    fe_sec_tone_mode_t  fe_tone;    var_Get( p_access, "dvb-tone", &val );    msg_Dbg( p_access, "using tone=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_tone = SEC_TONE_OFF; break;        case 1: fe_tone = SEC_TONE_ON; break;        default:            fe_tone = SEC_TONE_OFF;            msg_Err( p_access, "argument has invalid tone mode (%d)", val.i_int);            break;    }    return fe_tone;}struct diseqc_cmd_t{    struct dvb_diseqc_master_cmd cmd;    uint32_t wait;};static int DoDiseqc( access_t *p_access ){    access_sys_t *p_sys = p_access->p_sys;    vlc_value_t val;    int i_frequency, i_lnb_slof;    fe_sec_voltage_t fe_voltage;    fe_sec_tone_mode_t fe_tone;    int i_err;    var_Get( p_access, "dvb-frequency", &val );    i_frequency = val.i_int;    var_Get( p_access, "dvb-lnb-slof", &val );    i_lnb_slof = val.i_int;    var_Get( p_access, "dvb-tone", &val );    if( val.i_int == -1 /* auto */ )    {        if( i_frequency >= i_lnb_slof )            val.i_int = 1;        else            val.i_int = 0;        var_Set( p_access, "dvb-tone", val );    }    fe_voltage = DecodeVoltage( p_access );    fe_tone = DecodeTone( p_access );    /* Switch off continuous tone. */    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_TONE, SEC_TONE_OFF )) < 0 )    {        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %m",                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err );        return i_err;    }    /* Configure LNB voltage. */    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_VOLTAGE, fe_voltage )) < 0 )    {        msg_Err( p_access, "ioctl FE_SET_VOLTAGE failed, voltage=%d (%d) %m",                 fe_voltage, i_err );        return i_err;    }    var_Get( p_access, "dvb-high-voltage", &val );    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_ENABLE_HIGH_LNB_VOLTAGE,                        val.b_bool )) < 0 && val.b_bool )    {        msg_Err( p_access,                 "ioctl FE_ENABLE_HIGH_LNB_VOLTAGE failed, val=%d (%d) %m",                 val.b_bool, i_err );    }    /* Wait for at least 15 ms. */    msleep(15000);    var_Get( p_access, "dvb-satno", &val );    if( val.i_int > 0 && val.i_int < 5 )    {        /* digital satellite equipment control,         * specification is available from http://www.eutelsat.com/         */        /* 1.x compatible equipment */        struct diseqc_cmd_t cmd =  { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };        /* param: high nibble: reset bits, low nibble set bits,         * bits are: option, position, polarization, band         */        cmd.cmd.msg[3] = 0xf0 /* reset bits */                          | (((val.i_int - 1) * 4) & 0xc)                          | (fe_voltage == SEC_VOLTAGE_13 ? 0 : 2)                          | (fe_tone == SEC_TONE_ON ? 1 : 0);        if( (i_err = ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_MASTER_CMD,                           &cmd.cmd )) < 0 )        {            msg_Err( p_access, "ioctl FE_SEND_MASTER_CMD failed (%d) %m",                     i_err );            return i_err;        }        msleep(15000 + cmd.wait * 1000);        /* A or B simple diseqc ("diseqc-compatible") */        if( (i_err = ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_BURST,                      ((val.i_int - 1) % 2) ? SEC_MINI_B : SEC_MINI_A )) < 0 )        {            msg_Err( p_access, "ioctl FE_SEND_BURST failed (%d) %m",                     i_err );            return i_err;        }        msleep(15000);    }    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_TONE, fe_tone )) < 0 )    {        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %m",                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err );        return i_err;    }    msleep(50000);    return 0;}static int FrontendSetQPSK( access_t *p_access ){    access_sys_t *p_sys = p_access->p_sys;    struct dvb_frontend_parameters fep;    int i_ret;    vlc_value_t val;    int i_frequency, i_lnb_slof = 0, i_lnb_lof1, i_lnb_lof2 = 0;    /* Prepare the fep structure */    var_Get( p_access, "dvb-frequency", &val );    i_frequency = val.i_int;    var_Get( p_access, "dvb-lnb-lof1", &val );    if ( val.i_int == 0 )    {        /* Automatic mode. */        if ( i_frequency >= 950000 && i_frequency <= 2150000 )        {            msg_Dbg( p_access, "frequency %d is in IF-band", i_frequency );            i_lnb_lof1 = 0;        }        else if ( i_frequency >= 2500000 && i_frequency <= 2700000 )        {            msg_Dbg( p_access, "frequency %d is in S-band", i_frequency );            i_lnb_lof1 = 3650000;        }        else if ( i_frequency >= 3400000 && i_frequency <= 4200000 )        {            msg_Dbg( p_access, "frequency %d is in C-band (lower)",                     i_frequency );            i_lnb_lof1 = 5150000;        }        else if ( i_frequency >= 4500000 && i_frequency <= 4800000 )        {            msg_Dbg( p_access, "frequency %d is in C-band (higher)",                     i_frequency );            i_lnb_lof1 = 5950000;        }        else if ( i_frequency >= 10700000 && i_frequency <= 13250000 )        {            msg_Dbg( p_access, "frequency %d is in Ku-band",                     i_frequency );            i_lnb_lof1 = 9750000;            i_lnb_lof2 = 10600000;            i_lnb_slof = 11700000;        }        else        {            msg_Err( p_access, "frequency %d is out of any known band",                     i_frequency );            msg_Err( p_access, "specify dvb-lnb-lof1 manually for the local "                     "oscillator frequency" );            return VLC_EGENERIC;        }        val.i_int = i_lnb_lof1;        var_Set( p_access, "dvb-lnb-lof1", val );        val.i_int = i_lnb_lof2;        var_Set( p_access, "dvb-lnb-lof2", val );        val.i_int = i_lnb_slof;        var_Set( p_access, "dvb-lnb-slof", val );    }    else    {        i_lnb_lof1 = val.i_int;        var_Get( p_access, "dvb-lnb-lof2", &val );        i_lnb_lof2 = val.i_int;        var_Get( p_access, "dvb-lnb-slof", &val );        i_lnb_slof = val.i_int;    }    if( i_lnb_slof && i_frequency >= i_lnb_slof )    {        i_frequency -= i_lnb_lof2;    }    else    {        i_frequency -= i_lnb_lof1;    }    fep.frequency = i_frequency >= 0 ? i_frequency : -i_frequency;    fep.inversion = DecodeInversion( p_access );    var_Get( p_access, "dvb-srate", &val );    fep.u.qpsk.symbol_rate = val.i_int;    var_Get( p_access, "dvb-fec", &val );    fep.u.qpsk.fec_inner = DecodeFEC( p_access, val.i_int );    if( DoDiseqc( p_access ) < 0 )    {        return VLC_EGENERIC;    }    /* Empty the event queue */    for( ; ; )    {        struct dvb_frontend_event event;        if ( ioctl( p_sys->i_frontend_handle, FE_GET_EVENT, &event ) < 0              && errno == EWOULDBLOCK )            break;    }    /* Now send it all to the frontend device */    if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )    {        msg_Err( p_access, "DVB-S: setting frontend failed (%d) %m", i_ret );        return VLC_EGENERIC;    }    return VLC_SUCCESS;}/***************************************************************************** * FrontendSetQAM : controls the FE device *****************************************************************************/static int FrontendSetQAM( access_t *p_access ){    access_sys_t *p_sys = p_access->p_sys;    struct dvb_frontend_parameters fep;    vlc_value_t val;    int i_ret;    /* Prepare the fep structure */    var_Get( p_access, "dvb-frequency", &val );    fep.frequency = val.i_int;    fep.inversion = DecodeInversion( p_access );    var_Get( p_access, "dvb-srate", &val );    fep.u.qam.symbol_rate = val.i_int;    var_Get( p_access, "dvb-fec", &val );    fep.u.qam.fec_inner = DecodeFEC( p_access, val.i_int );    fep.u.qam.modulation = DecodeModulationQAM( p_access );    /* Empty the event queue */    for( ; ; )    {        struct dvb_frontend_event event;        if ( ioctl( p_sys->i_frontend_handle, FE_GET_EVENT, &event ) < 0              && errno == EWOULDBLOCK )            break;    }    /* Now send it all to the frontend device */    if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )    {        msg_Err( p_access, "DVB-C: setting frontend failed (%d): %m", i_ret );        return VLC_EGENERIC;    }    return VLC_SUCCESS;}/***************************************************************************** * FrontendSetOFDM : controls the FE device *****************************************************************************/static fe_bandwidth_t DecodeBandwidth( access_t *p_access ){    vlc_value_t         val;    fe_bandwidth_t      fe_bandwidth = 0;    var_Get( p_access, "dvb-bandwidth", &val );    msg_Dbg( p_access, "using bandwidth=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_bandwidth = BANDWIDTH_AUTO; break;        case 6: fe_bandwidth = BANDWIDTH_6_MHZ; break;        case 7: fe_bandwidth = BANDWIDTH_7_MHZ; break;        case 8: fe_bandwidth = BANDWIDTH_8_MHZ; break;        default:            msg_Dbg( p_access, "terrestrial dvb has bandwidth not set, using auto" );            fe_bandwidth = BANDWIDTH_AUTO;            break;    }    return fe_bandwidth;}static fe_transmit_mode_t DecodeTransmission( access_t *p_access ){    vlc_value_t         val;    fe_transmit_mode_t  fe_transmission = 0;    var_Get( p_access, "dvb-transmission", &val );    msg_Dbg( p_access, "using transmission=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_transmission = TRANSMISSION_MODE_AUTO; break;        case 2: fe_transmission = TRANSMISSION_MODE_2K; break;        case 8: fe_transmission = TRANSMISSION_MODE_8K; break;        default:            msg_Dbg( p_access, "terrestrial dvb has transmission mode not set, using auto");            fe_transmission = TRANSMISSION_MODE_AUTO;            break;    }    return fe_transmission;}static fe_guard_interval_t DecodeGuardInterval( access_t *p_access ){    vlc_value_t         val;    fe_guard_interval_t fe_guard = 0;    var_Get( p_access, "dvb-guard", &val );    msg_Dbg( p_access, "using guard=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_guard = GUARD_INTERVAL_AUTO; break;        case 4: fe_guard = GUARD_INTERVAL_1_4; break;        case 8: fe_guard = GUARD_INTERVAL_1_8; break;        case 16: fe_guard = GUARD_INTERVAL_1_16; break;        case 32: fe_guard = GUARD_INTERVAL_1_32; break;        default:            msg_Dbg( p_access, "terrestrial dvb has guard interval not set, using auto");            fe_guard = GUARD_INTERVAL_AUTO;            break;

⌨️ 快捷键说明

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