예제 #1
0
파일: dvb.c 프로젝트: danielkucera/dvblast
/*****************************************************************************
 * dvb_Open
 *****************************************************************************/
void dvb_Open( void )
{
    char psz_tmp[128];

    msg_Dbg( NULL, "compiled with DVB API version %d.%d", DVB_API_VERSION, DVB_API_VERSION_MINOR );

    if ( i_frequency )
    {
        sprintf( psz_tmp, "/dev/dvb/adapter%d/frontend%d", i_adapter, i_fenum );
        if( (i_frontend = open(psz_tmp, O_RDWR | O_NONBLOCK)) < 0 )
        {
            msg_Err( NULL, "opening device %s failed (%s)", psz_tmp,
                     strerror(errno) );
            exit(1);
        }

        FrontendSet(true);
    }
    else
    {
        i_frontend = -1;
    }

    sprintf( psz_tmp, "/dev/dvb/adapter%d/dvr%d", i_adapter, i_fenum );

    if( (i_dvr = open(psz_tmp, O_RDONLY | O_NONBLOCK)) < 0 )
    {
        msg_Err( NULL, "opening device %s failed (%s)", psz_tmp,
                 strerror(errno) );
        exit(1);
    }

    if ( ioctl( i_dvr, DMX_SET_BUFFER_SIZE, i_dvr_buffer_size ) < 0 )
    {
        msg_Warn( NULL, "couldn't set %s buffer size (%s)", psz_tmp,
                 strerror(errno) );
    }

    ev_io_init(&dvr_watcher, DVRRead, i_dvr, EV_READ);
    ev_io_start(event_loop, &dvr_watcher);

    if ( i_frontend != -1 )
    {
        ev_io_init(&frontend_watcher, FrontendRead, i_frontend, EV_READ);
        ev_io_start(event_loop, &frontend_watcher);
    }

    ev_timer_init(&lock_watcher, FrontendLockCb,
                  i_frontend_timeout_duration / 1000000.,
                  i_frontend_timeout_duration / 1000000.);
    ev_timer_init(&mute_watcher, DVRMuteCb,
                  DVR_READ_TIMEOUT / 1000000.,
                  DVR_READ_TIMEOUT / 1000000.);

    en50221_Init();
}
예제 #2
0
파일: dvb.c 프로젝트: wuzhenda/dvblast
/*****************************************************************************
 * dvb_Open
 *****************************************************************************/
void dvb_Open( void )
{
    char psz_tmp[128];

    msg_Dbg( NULL, "using linux-dvb API version %d.%d", DVB_API_VERSION, DVB_API_VERSION_MINOR );

    i_wallclock = mdate();

    sprintf( psz_tmp, "/dev/dvb/adapter%d/frontend%d", i_adapter, i_fenum );
    if( (i_frontend = open(psz_tmp, O_RDWR | O_NONBLOCK)) < 0 )
    {
        msg_Err( NULL, "opening device %s failed (%s)", psz_tmp,
                 strerror(errno) );
        exit(1);
    }

    FrontendSet(true);

    sprintf( psz_tmp, "/dev/dvb/adapter%d/dvr%d", i_adapter, i_fenum );

    if( (i_dvr = open(psz_tmp, O_RDONLY | O_NONBLOCK)) < 0 )
    {
        msg_Err( NULL, "opening device %s failed (%s)", psz_tmp,
                 strerror(errno) );
        exit(1);
    }

    if ( ioctl( i_dvr, DMX_SET_BUFFER_SIZE, DVR_BUFFER_SIZE ) < 0 )
    {
        msg_Warn( NULL, "couldn't set %s buffer size (%s)", psz_tmp,
                  strerror(errno) );
    }

    en50221_Init();
    i_ca_next_event = mdate() + CA_POLL_PERIOD;
}
예제 #3
0
파일: linux.c 프로젝트: sailfish009/vlc
/**
 * Opens the DVB tuner
 */
dvb_device_t *dvb_open (vlc_object_t *obj)
{
    dvb_device_t *d = malloc (sizeof (*d));
    if (unlikely(d == NULL))
        return NULL;

    d->obj = obj;

    uint8_t adapter = var_InheritInteger (obj, "dvb-adapter");
    d->device = var_InheritInteger (obj, "dvb-device");

    d->dir = dvb_open_adapter (adapter);
    if (d->dir == -1)
    {
        msg_Err (obj, "cannot access adapter %"PRIu8": %s", adapter,
                 vlc_strerror_c(errno));
        free (d);
        return NULL;
    }
    d->frontend = -1;
    d->cam = NULL;
    d->budget = var_InheritBool (obj, "dvb-budget-mode");

#ifndef USE_DMX
    if (d->budget)
#endif
    {
       d->demux = dvb_open_node (d, "demux", O_RDONLY);
       if (d->demux == -1)
       {
           msg_Err (obj, "cannot access demultiplexer: %s",
                    vlc_strerror_c(errno));
           vlc_close (d->dir);
           free (d);
           return NULL;
       }

       if (ioctl (d->demux, DMX_SET_BUFFER_SIZE, 1 << 20) < 0)
           msg_Warn (obj, "cannot expand demultiplexing buffer: %s",
                     vlc_strerror_c(errno));

       /* We need to filter at least one PID. The tap for TS demultiplexing
        * cannot be configured otherwise. So add the PAT. */
        struct dmx_pes_filter_params param;

        param.pid = d->budget ? 0x2000 : 0x000;
        param.input = DMX_IN_FRONTEND;
        param.output = DMX_OUT_TSDEMUX_TAP;
        param.pes_type = DMX_PES_OTHER;
        param.flags = DMX_IMMEDIATE_START;
        if (ioctl (d->demux, DMX_SET_PES_FILTER, &param) < 0)
        {
            msg_Err (obj, "cannot setup TS demultiplexer: %s",
                     vlc_strerror_c(errno));
            goto error;
        }
#ifndef USE_DMX
    }
    else
    {
        for (size_t i = 0; i < MAX_PIDS; i++)
            d->pids[i].pid = d->pids[i].fd = -1;
        d->demux = dvb_open_node (d, "dvr", O_RDONLY);
        if (d->demux == -1)
        {
            msg_Err (obj, "cannot access DVR: %s", vlc_strerror_c(errno));
            vlc_close (d->dir);
            free (d);
            return NULL;
        }
#endif
    }

    int ca = dvb_open_node (d, "ca", O_RDWR);
    if (ca != -1)
    {
        d->cam = en50221_Init (obj, ca);
        if (d->cam == NULL)
            vlc_close (ca);
    }
    else
        msg_Dbg (obj, "conditional access module not available: %s",
                 vlc_strerror_c(errno));
    return d;

error:
    dvb_close (d);
    return NULL;
}