VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_stream_extractor.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_stream_extractor.h
3 *****************************************************************************
4 * Copyright (C) 2016 VLC authors and VideoLAN
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20
21#ifndef VLC_STREAM_EXTRACTOR_H
22#define VLC_STREAM_EXTRACTOR_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * \defgroup stream_extractor Stream Extractor
30 * \ingroup input
31 *
32 * If a stream can be viewed as a directory, such as when opening a
33 * compressed archive, a \em stream-extractor is used to get access to
34 * the entities inside said stream.
35 *
36 * A \em stream-extractor can do one of two things;
37 *
38 * - lists the logical entries within a stream:
39 * - type = \ref stream_directory_t
40 * - capability = "stream_directory"
41 *
42 * - extract data associated with one specific entry within a stream:
43 * - type = \ref stream_extractor_t
44 * - capability = "stream_extractor"
45 *
46 * @{
47 *
48 **/
49
50typedef struct stream_extractor_t {
53 /**
54 * \name Callbacks for entity extraction
55 *
56 * The following members shall be populated as specified by the
57 * documentation associated with \ref stream_t for the equivalent name.
58 *
59 * @{
60 **/
61 ssize_t (*pf_read)(struct stream_extractor_t*, void* buf, size_t len);
62 block_t* (*pf_block)(struct stream_extractor_t*, bool* eof);
63 int (*pf_seek)(struct stream_extractor_t*, uint64_t);
64 int (*pf_control)(struct stream_extractor_t*, int request, va_list args);
65 /** @} */
66
67 char ** volumes;
69 char const* identifier; /**< the name of the entity to be extracted */
70 stream_t* source; /**< the source stream to be consumed */
71 void* p_sys; /**< private opaque handle to be used by the module */
75typedef struct stream_directory_t {
78 /**
79 * \name Callbacks for stream directories
80 *
81 * The following members shall be populated as specified by the
82 * documentation associated with \ref stream_t for the equivalent name.
83 *
84 * @{
85 **/
87 /** @} */
88
89 char ** volumes;
91 stream_t* source; /**< the source stream to be consumed */
92 void* p_sys; /**< private opaque handle to be used by the module */
96/**
97 * Create a stream for the data referred to by a \ref mrl
98 *
99 * This function will create a \ref stream that reads from the specified \ref
100 * mrl, potentially making use of \ref stream_extractor%s to access named
101 * entities within the data read from the original source.
102 *
103 * - See the \ref mrl specification for further information.
104 * - The returned resource shall be deleted through \ref vlc_stream_Delete.
105 *
106 * \warning This function is only to be used when \ref mrl functionality is
107 * explicitly needed. \ref vlc_stream_NewURL shall be used where
108 * applicable.
109 *
110 * \param obj the owner of the requested stream
111 * \param mrl the mrl for which the stream_t should be created
112 * \return `NULL` on error, a pointer to \ref stream_t on success.
113 **/
116#define vlc_stream_NewMRL(a, b) vlc_stream_NewMRL(VLC_OBJECT(a), b)
118/**
119 * Create a relative MRL for the associated entity
120 *
121 * This function shall be used by stream_directory_t's in order to
122 * generate an MRL that refers to an entity within the stream. Normally
123 * this function will only be invoked within `pf_readdir` in order to
124 * get the virtual path of the listed items.
125 *
126 * \warning The returned value is to be freed by the caller
127 *
128 * \param extractor the stream_directory_t for which the entity belongs
129 * \param subentry the name of the entity in question
130 * \param volumes media additional volumes MRLs
131 * \param volumes_count number of additional volumes
132 *
133 * \return a pointer to the resulting MRL on success, NULL on failure
134 **/
136 char const* subentry,
137 char const **volumes, size_t volumes_count );
138
139/**
140 * \name Attach a stream-extractor to the passed stream
141 *
142 * These functions are used to attach a stream extractor to an already existing
143 * stream. As hinted by their names, \ref vlc_stream_extractor_Attach will
144 * attach an \em entity-extractor, whereas \ref vlc_stream_directory_Attach
145 * will attach a \em stream-directory.
146 *
147 * \param[out] stream a pointer-to-pointer to stream, `*stream` will
148 * refer to the attached stream on success, and left
149 * untouched on failure.
150 * \param identifier (if present) NULL or a c-style string referring to the
151 * desired entity
152 * \param module_name NULL or an explicit stream-extractor module name
153 * \param volumes media additional volumes MRLs
154 * \param volumes_count number of additional volumes
155 *
156 * \return VLC_SUCCESS if a stream-extractor was successfully
157 * attached, an error-code on failure.
158 *
159 * @{
160 **/
161
163 char const* identifier,
164 char const* module_name,
165 const char **volumes, size_t volumes_count );
166
168 char const* module_name,
169 const char **volumes, size_t volumes_count );
170/**
171 * @}
172 */
173
174/**
175 * @}
176 */
177
178#ifdef __cplusplus
179} /* extern "C" */
180#endif
181#endif /* include-guard */
#define VLC_USED
Definition fourcc_gen.c:32
#define VLC_API
Definition fourcc_gen.c:31
int vlc_stream_directory_Attach(stream_t **source, char const *module_name, const char **volumes, size_t volumes_count)
Definition stream_extractor.c:374
int vlc_stream_extractor_Attach(stream_t **source, char const *identifier, char const *module_name, const char **volumes, size_t volumes_count)
Definition stream_extractor.c:381
char * vlc_stream_extractor_CreateMRL(stream_directory_t *extractor, char const *subentry, char const **volumes, size_t volumes_count)
Create a relative MRL for the associated entity.
Definition stream_extractor.c:409
#define vlc_stream_NewMRL(a, b)
Definition vlc_stream_extractor.h:117
Definition vlc_input_item.h:204
Definition vlc_stream_extractor.h:76
char ** volumes
Definition vlc_stream_extractor.h:90
int(* pf_readdir)(struct stream_directory_t *, input_item_node_t *)
Definition vlc_stream_extractor.h:87
size_t volumes_count
Definition vlc_stream_extractor.h:91
struct vlc_object_t obj
Definition vlc_stream_extractor.h:77
stream_t * source
the source stream to be consumed
Definition vlc_stream_extractor.h:92
void * p_sys
private opaque handle to be used by the module
Definition vlc_stream_extractor.h:93
Definition vlc_stream_extractor.h:51
struct vlc_object_t obj
Definition vlc_stream_extractor.h:52
ssize_t(* pf_read)(struct stream_extractor_t *, void *buf, size_t len)
Definition vlc_stream_extractor.h:62
size_t volumes_count
Definition vlc_stream_extractor.h:69
char const * identifier
the name of the entity to be extracted
Definition vlc_stream_extractor.h:70
int(* pf_control)(struct stream_extractor_t *, int request, va_list args)
Definition vlc_stream_extractor.h:65
char ** volumes
Definition vlc_stream_extractor.h:68
int(* pf_seek)(struct stream_extractor_t *, uint64_t)
Definition vlc_stream_extractor.h:64
void * p_sys
private opaque handle to be used by the module
Definition vlc_stream_extractor.h:72
stream_t * source
the source stream to be consumed
Definition vlc_stream_extractor.h:71
stream_t definition
Definition vlc_stream.h:135
Definition vlc_frame.h:123
VLC object common members.
Definition vlc_objects.h:53
This file is a collection of common definitions and types.