VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_preparser_ipc.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*****************************************************************************
3 * vlc_preparser_serializer.h: preparser serializer
4 *****************************************************************************
5 * Copyright © 2025 Videolabs, VideoLAN and VLC authors
6 *
7 * Authors: Gabriel Lafond Thenaille <gabriel@videolabs.io>
8 *****************************************************************************/
9
10#ifndef VLC_PREPARSER_IPC_H
11#define VLC_PREPARSER_IPC_H
12
13#include <vlc_common.h>
14#include <vlc_vector.h>
15#include <vlc_input.h>
16#include <vlc_input_item.h>
17#include <vlc_preparser.h>
18#include <vlc_interrupt.h>
19
20/**
21 * @defgroup preparser_ipc Preparser IPC
22 * @ingroup preparser
23 * @{
24 * @file
25 * VLC Preparser IPC API
26 *
27 * @defgroup preparser_msg preparser message api
28 * @ingroup preparser_ipc
29 * @{
30 */
31
32/**
33 * Request types
34 */
36 /**
37 * Type of the request emitted by a `vlc_preparser_Push` call.
38 */
40 /**
41 * Type of the request emitted by a `vlc_preparser_GenerateThumbnail`
42 * call.
43 */
45 /**
46 * Type of the request emitted by a
47 * `vlc_preparser_GenerateThumbnailToFiles` call.
48 */
50};
51
52/**
53 * Preparser request.
54 */
56 /**
57 * Type of the request.
58 */
61 /**
62 * Used only by request of type `VLC_PREPARSER_MSG_REQ_TYPE_PARSE`.
63 */
64 int options;
66 /**
67 * Used by both type `VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL` and
68 * `VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FILES`.
69 */
72 /**
73 * Used only by request of type
74 * `VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FILES`.
75 */
76 /* all `output_path` will be freed so they must be heap allocated or set to
77 * NULL before a `vlc_preparser_msg_Clean` call. */
78 struct VLC_VECTOR(char *) outputs_path;
81 /* `uri` will be freed so it must be heap allocated or set to
82 * NULL before a `vlc_preparser_msg_Clean` call. */
83 char *uri;
84};
85
86/**
87 * Preparser Response
88 */
90 /**
91 * Type of the response (As the response answering a request they share the
92 * same type).
93 */
96 /**
97 * Used only by request of type `VLC_PREPARSER_MSG_REQ_TYPE_PARSE`.
98 */
102 /**
103 * Used only by request of type `VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL`.
104 */
105 picture_t *pic;
107 /**
108 * Used only by request of type
109 * `VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FILES`.
110 */
111 struct VLC_VECTOR(bool) result;
113 /**
114 * Used by all types of request.
115 */
116 int status;
119
120/**
121 * Preparser message.
122 */
123struct vlc_preparser_msg {
124 /**
125 * Type of the message can be a request or a response.
126 */
127 enum {
130 } type;
132 /**
133 * Type of the underling request or response.
134 */
136 union {
139 };
140};
141
142/**
143 * Initialize a preparser message.
144 *
145 * @info All data specific to each request/response have to be initialized
146 * by hand.
147 *
148 * @param msg message to initialize.
149 * @param msg_type message type (request or response).
150 * @param req_type request/response type (see enum vlc_preparser_req_type
151 * for more information).
152 */
153VLC_API void
154vlc_preparser_msg_Init(struct vlc_preparser_msg *msg, int msg_type,
155 enum vlc_preparser_msg_req_type req_type);
156
157/**
158 * Clean all memory used by a message.
159 *
160 * @info This function don't free the `msg` pointer.
161 *
162 * @param msg message to release.
163 */
164VLC_API void
165vlc_preparser_msg_Clean(struct vlc_preparser_msg *msg);
166
167/**
168 * @} preparser_msg
169 *
170 * @defgroup preparser_serdes preparser serializer api
171 * @ingroup preparser_ipc
172 *
173 * @{
174 */
175#define VLC_PREPARSER_MSG_SERDES_TYPE_DATA 0x1
176#define VLC_PREPARSER_MSG_SERDES_TYPE_ATTACHMENT 0x2
177#define VLC_PREPARSER_MSG_SERDES_TYPE_END_DATA 0x4
178#define VLC_PREPARSER_MSG_SERDES_TYPE_END_ATTACHMENT 0x8
181 /**
182 * Write callback.
183 *
184 * @param [in] data buffer to write.
185 * @param [in] size number of bytes to write.
186 * @param [in] userdata callback userdata.
187 *
188 * @return the number of bytes writen or an error code on failure.
189 */
190 ssize_t (*write)(const void *data, size_t size, void *userdata);
192 /**
193 * Read callback.
194 *
195 * @param [out] data buffer to read into.
196 * @param [in] size number of bytes to read.
197 * @param [in] userdata callback userdata.
198 *
199 * @return the number of bytes read or an error code on failure.
200 */
201 ssize_t (*read)(void *data, size_t size, void *userdata);
203
205
207 /**
208 * Serialize `msg` and call the write callback with serialized data.
209 *
210 * @param [in] serdes serializer internal structure.
211 * @param [in] msg message to serialize.
212 * @param [in] userdata context for the write callbacks
213 *
214 * @return VLC_SUCCESS or an error code on failure.
215 */
216 int (*serialize)(struct vlc_preparser_msg_serdes *serdes,
217 const struct vlc_preparser_msg *msg,
218 void *userdata);
219
220 /**
221 * Deserialize `msg` and call the read callback to get data to deserialize.
222 *
223 * @param [in] serdes serializer internal structure.
224 * @param [out] msg message to deserialize.
225 * @param [in] userdata context for the read callbacks
226 *
227 * @return VLC_SUCCESS or an error code on failure.
228 */
229 int (*deserialize)(struct vlc_preparser_msg_serdes *serdes,
230 struct vlc_preparser_msg *msg,
231 void *userdata);
232
233 /**
234 * Close the serializer/deserialier and release all used memory.
235 *
236 * @param [in] serdes preparser msg serdes internal struture.
237 */
238 void (*close)(struct vlc_preparser_msg_serdes *serdes);
240
241/**
242 * Internal structure used by serializer.
243 */
245 /** Operations */
248 struct {
249 /** Callbacks */
250 const struct vlc_preparser_msg_serdes_cbs *cbs;
251 /** Used by the serializer module. */
252 void *sys;
253 } owner;
255
257 (struct vlc_preparser_msg_serdes *, bool);
258
259#define set_callback_preparser_msg_serdes(activate, priority) \
260 {\
261 vlc_preparser_msg_serdes_module open__ = activate;\
262 (void)open__;\
263 set_callback(activate)\
264 }\
265 set_capability("preparser msg serdes", priority)
266
267/**
268 * \copydoc vlc_preparser_msg_serdes_operations::serialize
269 */
270static inline int
272 const struct vlc_preparser_msg *msg,
273 void *userdata)
274{
275 assert(serdes != NULL);
276
277 if (serdes->ops != NULL && serdes->ops->serialize != NULL) {
278 return serdes->ops->serialize(serdes, msg, userdata);
279 }
280 return VLC_EGENERIC;
281}
282
283/**
284 * \copydoc vlc_preparser_msg_serdes_operations::deserialize
285 */
286static inline int
287vlc_preparser_msg_serdes_Deserialize(struct vlc_preparser_msg_serdes *serdes,
288 struct vlc_preparser_msg *msg,
289 void *userdata)
290{
291 assert(serdes!= NULL);
292
293 if (serdes->ops != NULL && serdes->ops->deserialize != NULL) {
294 return serdes->ops->deserialize(serdes, msg, userdata);
295 }
296 return VLC_EGENERIC;
297}
298
299/**
300 * Free the msg_serdes struct.
301 *
302 * @param [in] msg_serdes
303 */
304static inline void
305vlc_preparser_msg_serdes_Delete(struct vlc_preparser_msg_serdes *serdes)
307 assert(serdes != NULL);
308
309 if (serdes->ops != NULL && serdes->ops->close != NULL) {
310 serdes->ops->close(serdes);
311 }
312 free(serdes);
313}
314
315/**
316 * Create a vlc_preparser_msg_serdes object and load a preparser msg_serdes
317 * module.
318 *
319 * @param [in] obj vlc object
320 * @param [in] c serializer's callbacks
321 * @param [in] bin_data describe if the serializer and deserializer use
322 * binary data (intput_attachment_t or plane_t)
323 *
324 * @return a vlc_preparser_msg_serdes object or NULL on failure.
325 */
326VLC_API struct vlc_preparser_msg_serdes *
328 const struct vlc_preparser_msg_serdes_cbs *c,
329 bool bin_data);
330
331/**
332 * @} preparser_serdes
333 * @} preparser_ipc
334 */
335
336#endif /* VLC_PREPARSER_IPC */
#define VLC_API
Definition fourcc_gen.c:31
#define VLC_EGENERIC
Unspecified error.
Definition vlc_common.h:482
void vlc_preparser_msg_Clean(struct vlc_preparser_msg *msg)
Clean all memory used by a message.
Definition ipc.c:105
void vlc_preparser_msg_Init(struct vlc_preparser_msg *msg, int msg_type, enum vlc_preparser_msg_req_type req_type)
Initialize a preparser message.
Definition ipc.c:72
vlc_preparser_msg_req_type
Request types.
Definition vlc_preparser_ipc.h:36
@ VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FILES
Type of the request emitted by a vlc_preparser_GenerateThumbnailToFiles call.
Definition vlc_preparser_ipc.h:50
@ VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL
Type of the request emitted by a vlc_preparser_GenerateThumbnail call.
Definition vlc_preparser_ipc.h:45
@ VLC_PREPARSER_MSG_REQ_TYPE_PARSE
Type of the request emitted by a vlc_preparser_Push call.
Definition vlc_preparser_ipc.h:40
struct vlc_preparser_msg_serdes * vlc_preparser_msg_serdes_Create(vlc_object_t *obj, const struct vlc_preparser_msg_serdes_cbs *c, bool bin_data)
Create a vlc_preparser_msg_serdes object and load a preparser msg_serdes module.
Definition ipc.c:32
int(* vlc_preparser_msg_serdes_module)(struct vlc_preparser_msg_serdes *, bool)
Definition vlc_preparser_ipc.h:258
static void vlc_preparser_msg_serdes_Delete(struct vlc_preparser_msg_serdes *serdes)
Free the msg_serdes struct.
Definition vlc_preparser_ipc.h:306
static int vlc_preparser_msg_serdes_Deserialize(struct vlc_preparser_msg_serdes *serdes, struct vlc_preparser_msg *msg, void *userdata)
Deserialize msg and call the read callback to get data to deserialize.
Definition vlc_preparser_ipc.h:288
static int vlc_preparser_msg_serdes_Serialize(struct vlc_preparser_msg_serdes *serdes, const struct vlc_preparser_msg *msg, void *userdata)
Serialize msg and call the write callback with serialized data.
Definition vlc_preparser_ipc.h:272
#define VLC_VECTOR(type)
Vector struct body.
Definition vlc_vector.h:66
static const struct @256201157315064040063243024163273150022276102076 msg_type[]
Definition vlc_input.h:168
Definition vlc_input_item.h:201
Describes an input and is used to spawn input_thread_t objects.
Definition vlc_input_item.h:98
Video picture.
Definition vlc_picture.h:128
Preparser request.
Definition vlc_preparser_ipc.h:56
struct vlc_thumbnailer_arg arg
Used by both type VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL and VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FI...
Definition vlc_preparser_ipc.h:71
char * uri
Definition vlc_preparser_ipc.h:84
int options
Used only by request of type VLC_PREPARSER_MSG_REQ_TYPE_PARSE.
Definition vlc_preparser_ipc.h:65
enum vlc_preparser_msg_req_type type
Type of the request.
Definition vlc_preparser_ipc.h:60
struct vlc_preparser_msg_req::@166062001051325264025151355255232025075012350152 outputs_path
Used only by request of type VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FILES.
struct vlc_preparser_msg_req::@176274343022136274013140023353250327257015262010 outputs
Preparser Response.
Definition vlc_preparser_ipc.h:90
input_item_t * item
Definition vlc_preparser_ipc.h:118
enum vlc_preparser_msg_req_type type
Type of the response (As the response answering a request they share the same type).
Definition vlc_preparser_ipc.h:95
struct vlc_preparser_msg_res::@334245213060356153010225043021230000363116263006 attachments
Used only by request of type VLC_PREPARSER_MSG_REQ_TYPE_PARSE.
struct vlc_preparser_msg_res::@066002135152212101357220153113230106370346135247 result
Used only by request of type VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL_TO_FILES.
input_item_node_t * subtree
Definition vlc_preparser_ipc.h:101
int status
Used by all types of request.
Definition vlc_preparser_ipc.h:117
picture_t * pic
Used only by request of type VLC_PREPARSER_MSG_REQ_TYPE_THUMBNAIL.
Definition vlc_preparser_ipc.h:106
Definition vlc_preparser_ipc.h:181
ssize_t(* read)(void *data, size_t size, void *userdata)
Read callback.
Definition vlc_preparser_ipc.h:202
ssize_t(* write)(const void *data, size_t size, void *userdata)
Write callback.
Definition vlc_preparser_ipc.h:191
Definition vlc_preparser_ipc.h:207
int(* deserialize)(struct vlc_preparser_msg_serdes *serdes, struct vlc_preparser_msg *msg, void *userdata)
Deserialize msg and call the read callback to get data to deserialize.
Definition vlc_preparser_ipc.h:230
int(* serialize)(struct vlc_preparser_msg_serdes *serdes, const struct vlc_preparser_msg *msg, void *userdata)
Serialize msg and call the write callback with serialized data.
Definition vlc_preparser_ipc.h:217
void(* close)(struct vlc_preparser_msg_serdes *serdes)
Close the serializer/deserialier and release all used memory.
Definition vlc_preparser_ipc.h:239
Internal structure used by serializer.
Definition vlc_preparser_ipc.h:245
void * sys
Used by the serializer module.
Definition vlc_preparser_ipc.h:253
const struct vlc_preparser_msg_serdes_operations * ops
Operations.
Definition vlc_preparser_ipc.h:247
const struct vlc_preparser_msg_serdes_cbs * cbs
Callbacks.
Definition vlc_preparser_ipc.h:251
Preparser message.
Definition vlc_preparser_ipc.h:124
@ VLC_PREPARSER_MSG_TYPE_RES
Definition vlc_preparser_ipc.h:130
@ VLC_PREPARSER_MSG_TYPE_REQ
Definition vlc_preparser_ipc.h:129
struct vlc_preparser_msg_res res
Definition vlc_preparser_ipc.h:139
enum vlc_preparser_msg_req_type req_type
Type of the underling request or response.
Definition vlc_preparser_ipc.h:136
struct vlc_preparser_msg_req req
Definition vlc_preparser_ipc.h:138
Thumbnailer argument.
Definition vlc_preparser.h:193
Thumbnailer output argument.
Definition vlc_preparser.h:244
This file is a collection of common definitions and types.
struct vlc_object_t vlc_object_t
Definition vlc_common.h:363
Input thread interface.
This file defines functions, structures and enums for input items in vlc.
This file declares interruptible sleep functions.
VLC Preparser API.
This provides convenience helpers for vectors.