Пример #1
0
int AccessOpen( vlc_object_t *obj )
{
    access_t *access = (access_t *)obj;

    /* Only when selected */
    if( *access->psz_access == '\0' ) return VLC_EGENERIC;

    access_InitFields( access );

    demux_sys_t *sys = calloc( 1, sizeof( demux_sys_t ));
    if( unlikely(sys == NULL) )
        return VLC_ENOMEM;
    access->p_sys = (access_sys_t *)sys;

    ParseMRL( obj, access->psz_location );
    sys->i_fd = OpenVideo( obj, sys, false );
    if( sys->i_fd == -1 )
    {
        free( sys );
        return VLC_EGENERIC;
    }

    if( sys->io == IO_METHOD_READ )
        access->pf_read = AccessReadStream;
    else
        access->pf_block = AccessRead;
    access->pf_seek = NULL;
    access->pf_control = AccessControl;
    return VLC_SUCCESS;
}
Пример #2
0
int DemuxOpen( vlc_object_t *obj )
{
    demux_t *demux = (demux_t *)obj;

    demux_sys_t *sys = malloc (sizeof (*sys));
    if (unlikely(sys == NULL))
        return VLC_ENOMEM;
    demux->p_sys = sys;

    ParseMRL( obj, demux->psz_location );

    char *path = var_InheritString (obj, CFG_PREFIX"dev");
    if (unlikely(path == NULL))
        goto error; /* probably OOM */
    msg_Dbg (obj, "opening device '%s'", path);

    int rawfd = vlc_open (path, O_RDWR);
    if (rawfd == -1)
    {
        msg_Err (obj, "cannot open device '%s': %m", path);
        free (path);
        goto error;
    }
    free (path);

    int fd = v4l2_fd_open (rawfd, 0);
    if (fd == -1)
    {
        msg_Warn (obj, "cannot initialize user-space library: %m");
        /* fallback to direct kernel mode anyway */
        fd = rawfd;
    }
    sys->fd = fd;

    if (InitVideo (demux, fd))
    {
        v4l2_close (fd);
        goto error;
    }

    sys->controls = ControlsInit (VLC_OBJECT(demux), fd);
    demux->pf_demux = NULL;
    demux->pf_control = DemuxControl;
    demux->info.i_update = 0;
    demux->info.i_title = 0;
    demux->info.i_seekpoint = 0;
    return VLC_SUCCESS;
error:
    free (sys);
    return VLC_EGENERIC;
}
Пример #3
0
/**
 * It initializes the common part for imem access/access_demux.
 */
static int OpenCommon(vlc_object_t *object, imem_sys_t **sys_ptr, const char *psz_path)
{
    char *tmp;

	/* */
    imem_sys_t *sys = calloc(1, sizeof(*sys));
	if (!sys)
		return VLC_ENOMEM;

    /* Read the user functions */
    tmp = var_InheritString(object, "imem-get");
    if (tmp)
        sys->source.get = (imem_get_t)(intptr_t)strtoll(tmp, NULL, 0);
    free(tmp);

    tmp = var_InheritString(object, "imem-release");
    if (tmp)
        sys->source.release = (imem_release_t)(intptr_t)strtoll(tmp, NULL, 0);
    free(tmp);

    if (!sys->source.get || !sys->source.release) {
        msg_Err(object, "Invalid get/release function pointers");
        free(sys);
        return VLC_EGENERIC;
    }

    tmp = var_InheritString(object, "imem-data");
    if (tmp)
        sys->source.data = (void *)(uintptr_t)strtoull(tmp, NULL, 0);
    free(tmp);

    /* Now we can parse the MRL (get/release must not be parsed to avoid
     * security risks) */
    if (*psz_path)
        ParseMRL(object, psz_path);

    sys->source.cookie = var_InheritString(object, "imem-cookie");

    msg_Dbg(object, "Using get(%p), release(%p), data(%p), cookie(%s)",
            sys->source.get, sys->source.release, sys->source.data,
            sys->source.cookie ? sys->source.cookie : "(null)");

    /* */
    sys->pts_delay = var_InheritInteger(object, "imem-caching") * INT64_C(1000);
    sys->dts       = 0;
    sys->deadline  = VLC_TS_INVALID;

    *sys_ptr = sys;
    return VLC_SUCCESS;
}
Пример #4
0
int DemuxOpen( vlc_object_t *obj )
{
    demux_t *demux = (demux_t *)obj;

    demux_sys_t *sys = malloc (sizeof (*sys));
    if (unlikely(sys == NULL))
        return VLC_ENOMEM;
    demux->p_sys = sys;
#ifdef ZVBI_COMPILED
    sys->vbi = NULL;
#endif

    ParseMRL( obj, demux->psz_location );

    char *path = var_InheritString (obj, CFG_PREFIX"dev");
    if (unlikely(path == NULL))
        goto error; /* probably OOM */

    uint32_t caps;
    int fd = OpenDevice (obj, path, &caps);
    free (path);
    if (fd == -1)
        goto error;
    sys->fd = fd;

    if (InitVideo (demux, fd, caps))
    {
        v4l2_close (fd);
        goto error;
    }

    sys->controls = ControlsInit (VLC_OBJECT(demux), fd);
    sys->start = mdate ();
    demux->pf_demux = NULL;
    demux->pf_control = DemuxControl;
    demux->info.i_update = 0;
    demux->info.i_title = 0;
    demux->info.i_seekpoint = 0;
    return VLC_SUCCESS;
error:
    free (sys);
    return VLC_EGENERIC;
}
Пример #5
0
int AccessOpen( vlc_object_t *obj )
{
    access_t *access = (access_t *)obj;

    access_InitFields( access );

    access_sys_t *sys = calloc (1, sizeof (*sys));
    if( unlikely(sys == NULL) )
        return VLC_ENOMEM;
    access->p_sys = sys;

    ParseMRL( obj, access->psz_location );

    char *path = var_InheritString (obj, CFG_PREFIX"dev");
    if (unlikely(path == NULL))
        goto error; /* probably OOM */

    uint32_t caps;
    int fd = OpenDevice (obj, path, &caps);
    free (path);
    if (fd == -1)
        goto error;
    sys->fd = fd;

    if (InitVideo (access, fd, caps))
    {
        v4l2_close (fd);
        goto error;
    }

    sys->controls = ControlsInit (VLC_OBJECT(access), fd);
    access->pf_seek = NULL;
    access->pf_control = AccessControl;
    return VLC_SUCCESS;
error:
    free (sys);
    return VLC_EGENERIC;
}
Пример #6
0
int DemuxOpen( vlc_object_t *obj )
{
    demux_t *demux = (demux_t *)obj;
    demux_sys_t *sys = calloc( 1, sizeof( demux_sys_t ) );
    if( unlikely(sys == NULL) )
        return VLC_ENOMEM;
    demux->p_sys = sys;

    ParseMRL( obj, demux->psz_location );
    sys->i_fd = OpenVideo( obj, sys, true );
    if( sys->i_fd == -1 )
    {
        free( sys );
        return VLC_EGENERIC;
    }

    demux->pf_demux = Demux;
    demux->pf_control = DemuxControl;
    demux->info.i_update = 0;
    demux->info.i_title = 0;
    demux->info.i_seekpoint = 0;
    return VLC_SUCCESS;
}
Пример #7
0
Файл: access.c Проект: etix/vlc
/*****************************************************************************
 * 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;

    if( p_access->b_preparsing )
        return VLC_EGENERIC;

    p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
    if( !p_sys )
        return VLC_ENOMEM;

    /* Create all variables */
    VarInit( p_access );

    /* Parse the command line */
    if( ParseMRL( p_access ) )
    {
        free( p_sys );
        return VLC_EGENERIC;
    }

    bool b_scan_mode = var_GetInteger( p_access, "dvb-frequency" ) == 0;
    if( b_scan_mode )
    {
        msg_Dbg( p_access, "DVB scan mode selected" );
        p_access->pf_block = BlockScan;
    }
    else
        return VLC_EGENERIC; /* let the DTV plugin do the work */

    /* Getting frontend info */
    if( FrontendOpen( p_this, &p_sys->dvb, p_access->psz_name ) )
    {
        free( p_sys );
        return VLC_EGENERIC;
    }

    /* Opening DVR device */
    if( DVROpen( p_this, &p_sys->dvb ) < 0 )
    {
        FrontendClose( p_this, &p_sys->dvb );
        free( p_sys );
        return VLC_EGENERIC;
    }

    scan_parameter_t parameter;
    scan_t *p_scan;

    scan_parameter_Init( &parameter );

    parameter.b_use_nit = var_InheritBool( p_access, "dvb-scan-nit" );

    if( FrontendFillScanParameter( p_this, &p_sys->dvb, &parameter ) ||
            (p_scan = scan_New( VLC_OBJECT(p_access), &parameter,
                                ScanFrontendTuningHandler,
                                ScanStatsCallback,
                                ScanFilterHandler,
                                ScanReadCallback,
                                p_access )) == NULL )
    {
        scan_parameter_Clean( &parameter );
        Close( VLC_OBJECT(p_access) );
        return VLC_EGENERIC;
    }

    scan_parameter_Clean( &parameter );
    p_sys->scan = p_scan;


    /* Set up access */
    p_access->pf_control = Control;

    return VLC_SUCCESS;
}