/***************************************************************************** * DirInit: Init the directory access with a directory stream *****************************************************************************/ int DirInit (stream_t *access, DIR *dir) { access_sys_t *sys = vlc_malloc(VLC_OBJECT(access), sizeof (*sys)); if (unlikely(sys == NULL)) goto error; if (!strcmp(access->psz_name, "fd")) { if (unlikely(asprintf(&sys->base_uri, "fd://%s", access->psz_location) == -1)) sys->base_uri = NULL; } else sys->base_uri = vlc_path2uri(access->psz_filepath, "file"); if (unlikely(sys->base_uri == NULL)) goto error; sys->dir = dir; access->p_sys = sys; access->pf_readdir = DirRead; access->pf_control = access_vaDirectoryControlHelper; return VLC_SUCCESS; error: closedir(dir); return VLC_ENOMEM; }
static int Open (vlc_object_t *obj) { demux_t *demux = (demux_t *)obj; demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; es_format_t fmt; es_format_Init (&fmt, SPU_ES, VLC_CODEC_ITU_T140); sys->es = es_out_Add (demux->out, &fmt); unsigned num, den; if (var_InheritURational (demux, &num, &den, "timecode-fps") || !num || !den) { msg_Err (demux, "invalid frame rate"); return VLC_EGENERIC; } date_Init (&sys->date, num, den); date_Set (&sys->date, VLC_TS_0); sys->next_time = VLC_TS_INVALID; demux->p_sys = sys; demux->pf_demux = Demux; demux->pf_control = Control; return VLC_SUCCESS; }
static int Open(vlc_object_t *object) { access_t *access = (access_t *)object; input_thread_t *input = access->p_input; if (!input) return VLC_EGENERIC; access_sys_t *sys = vlc_malloc(object, sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; if (input_Control(input, INPUT_GET_ATTACHMENT, &sys->attachment, access->psz_location)) sys->attachment = NULL; if (sys->attachment == NULL) { msg_Err(access, "Failed to find the attachment '%s'", access->psz_location); return VLC_EGENERIC; } sys->offset = 0; /* */ access->pf_read = Read; access->pf_block = NULL; access->pf_control = Control; access->pf_seek = Seek; access->p_sys = sys; return VLC_SUCCESS; }