Exemplo n.º 1
0
static access_t *GetAccess(access_t *access)
{
    access_sys_t *sys = access->p_sys;
    access_t *a = sys->access;

    if (a != NULL)
    {
        if (!vlc_access_Eof(a))
            return a;

        vlc_access_Delete(a);
        sys->access = NULL;
    }

    if (sys->next == NULL)
    {
error:
        access->info.b_eof = true;
        return NULL;
    }

    a = vlc_access_NewMRL(VLC_OBJECT(access), sys->next->mrl);
    if (a == NULL)
        goto error;

    sys->access = a;
    sys->next = sys->next->next;
    return a;
}
Exemplo n.º 2
0
static access_t *GetAccess(access_t *access)
{
    access_sys_t *sys = access->p_sys;
    access_t *a = sys->access;

    if (a != NULL)
    {
        if (!vlc_stream_Eof(a))
            return a;

        vlc_stream_Delete(a);
        sys->access = NULL;
    }

    if (sys->next == NULL)
        return NULL;

    a = vlc_access_NewMRL(VLC_OBJECT(access), sys->next->mrl);
    if (a == NULL)
        return NULL;

    sys->access = a;
    sys->next = sys->next->next;
    return a;
}
Exemplo n.º 3
0
/****************************************************************************
 * stream_UrlNew: create a stream from a access
 ****************************************************************************/
stream_t *stream_UrlNew( vlc_object_t *p_parent, const char *psz_url )
{
    if( !psz_url )
        return NULL;

    access_t *p_access = vlc_access_NewMRL( p_parent, psz_url );
    if( p_access == NULL )
    {
        msg_Err( p_parent, "no suitable access module for `%s'", psz_url );
        return NULL;
    }

    return stream_AccessNew( p_access );
}
Exemplo n.º 4
0
static int Open(vlc_object_t *obj)
{
    access_t *access = (access_t *)obj;

    char *list = var_CreateGetNonEmptyString(access, "concat-list");
    if (list == NULL)
        return VLC_EGENERIC;

    access_sys_t *sys = malloc(sizeof (*sys));
    if (unlikely(sys == NULL))
    {
        free(list);
        return VLC_ENOMEM;
    }

    var_SetString(access, "concat-list", ""); /* prevent recursion */

    bool read_cb = true;

    sys->access = NULL;
    sys->can_seek = true;
    sys->can_seek_fast = true;
    sys->can_pause = true;
    sys->can_control_pace = true;
    sys->size = 0;
    sys->caching = 0;

    struct access_entry **pp = &sys->first;

    for (char *buf, *mrl = strtok_r(list, ",", &buf);
         mrl != NULL;
         mrl = strtok_r(NULL, ",", &buf))
    {
        size_t mlen = strlen(mrl);
        struct access_entry *e = malloc(sizeof (*e) + mlen);
        if (unlikely(e == NULL))
            break;

        access_t *a = vlc_access_NewMRL(obj, mrl);
        if (a == NULL)
        {
            msg_Err(access, "cannot concatenate location %s", mrl);
            free(e);
            continue;
        }

        if (a->pf_read == NULL)
        {
            if (a->pf_block == NULL)
            {
                msg_Err(access, "cannot concatenate directory %s", mrl);
                vlc_access_Delete(a);
                free(e);
                continue;
            }
            read_cb = false;
        }

        *pp = e;
        e->next = NULL;
        memcpy(e->mrl, mrl, mlen + 1);

        if (sys->can_seek)
            access_Control(a, ACCESS_CAN_SEEK, &sys->can_seek);
        if (sys->can_seek_fast)
            access_Control(a, ACCESS_CAN_FASTSEEK, &sys->can_seek_fast);
        if (sys->can_pause)
            access_Control(a, ACCESS_CAN_PAUSE, &sys->can_pause);
        if (sys->can_control_pace)
            access_Control(a, ACCESS_CAN_CONTROL_PACE, &sys->can_control_pace);
        if (sys->size != UINT64_MAX)
        {
            uint64_t size;

            if (access_GetSize(a, &size))
                sys->size = UINT64_MAX;
            else
                sys->size += size;
        }

        int64_t caching;
        access_Control(a, ACCESS_GET_PTS_DELAY, &caching);
        if (caching > sys->caching)
            sys->caching = caching;

        vlc_access_Delete(a);
        pp = &e->next;
    }

    free(list);
    *pp = NULL;
    sys->next = sys->first;

    access_InitFields(access);
    access->pf_read = read_cb ? Read : NULL;
    access->pf_block = read_cb ? NULL : Block;
    access->pf_seek = Seek;
    access->pf_control = Control;
    access->p_sys = sys;

    return VLC_SUCCESS;
}