VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_preparser.h
Go to the documentation of this file.
1/*****************************************************************************
2 * preparser.h
3 *****************************************************************************
4 * Copyright (C) 1999-2023 VLC authors and VideoLAN
5 *
6 * Authors: Samuel Hocevar <sam@zoy.org>
7 * Clément Stenac <zorglub@videolan.org>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
23
24#ifndef VLC_PREPARSER_H
25#define VLC_PREPARSER_H 1
26
27#include <vlc_input_item.h>
28
29/**
30 * @defgroup vlc_preparser Preparser
31 * @ingroup input
32 * @{
33 * @file
34 * VLC Preparser API
35 */
36
37/**
38 * Preparser opaque structure.
39 *
40 * The preparser object will retrieve the meta data of any given input item in
41 * an asynchronous way.
42 * It will also issue art fetching requests.
43 */
44typedef struct vlc_preparser_t vlc_preparser_t;
45typedef size_t vlc_preparser_req_id;
47#define VLC_PREPARSER_REQ_ID_INVALID 0
49#define VLC_PREPARSER_TYPE_PARSE 0x01
50#define VLC_PREPARSER_TYPE_FETCHMETA_LOCAL 0x02
51#define VLC_PREPARSER_TYPE_FETCHMETA_NET 0x04
52#define VLC_PREPARSER_TYPE_THUMBNAIL 0x08
53#define VLC_PREPARSER_TYPE_FETCHMETA_ALL \
54 (VLC_PREPARSER_TYPE_FETCHMETA_LOCAL|VLC_PREPARSER_TYPE_FETCHMETA_NET)
55
56#define VLC_PREPARSER_OPTION_INTERACT 0x1000
57#define VLC_PREPARSER_OPTION_SUBITEMS 0x2000
59/** Preparser thumbnailer callbacks */
62 /**
63 * Event received on thumbnailing completion or error
64 *
65 * This callback will always be called, provided
66 * vlc_preparser_GenerateThumbnail() returned a valid request, and provided
67 * the request is not cancelled before its completion.
68 *
69 * @note This callback is mandatory if calling
70 * vlc_preparser_GenerateThumbnail()
71 *
72 * In case of failure, timeout or cancellation, p_thumbnail will be NULL.
73 * The picture, if any, is owned by the thumbnailer, and must be acquired
74 * by using \link picture_Hold \endlink to use it pass the callback's
75 * scope.
76 *
77 * @param item item used for the thumbnailer
78 * @param status VLC_SUCCESS in case of success, VLC_ETIMEOUT in case of
79 * timeout, -EINTR if cancelled, an error otherwise
80 * @param thumbnail The generated thumbnail, or NULL in case of failure or
81 * timeout
82 * @param data opaque pointer passed by
83 * vlc_preparser_GenerateThumbnail()
84 *
85 */
86 void (*on_ended)(input_item_t *item, int status, picture_t* thumbnail,
87 void *data);
88};
89
90/**
91 * Thumbnailer argument
92 */
95 /** Seek argument */
96 struct seek
97 {
98 enum
99 {
100 /** Don't seek */
102 /** Seek by time */
104 /** Seek by position */
107 union
108 {
109 /** Seek time if type == VLC_THUMBNAILER_SEEK_TIME */
111 /** Seek position if type == VLC_THUMBNAILER_SEEK_POS */
112 double pos;
113 };
114 enum
115 {
116 /** Precise, but potentially slow */
118 /** Fast, but potentially imprecise */
123 /** True to enable hardware decoder */
124 bool hw_dec;
126
127/**
128 * Preparser creation configuration
129 */
132 /**
133 * A combination of VLC_PREPARSER_TYPE_* flags, it is used to
134 * setup the executors for each domain. Its possible to select more than
135 * one type
136 */
137 int types;
139 /**
140 * The maximum number of threads used by the parser, 0 for default
141 * (1 thread)
142 */
143 unsigned max_parser_threads;
145 /**
146 * The maximum number of threads used by the thumbnailer, 0 for default
147 * (1 thread)
148 */
151 /**
152 * Timeout of the preparser and/or thumbnailer, 0 for no limits.
153 */
156
157/**
158 * This function creates the preparser object and thread.
159 *
160 * @param obj the parent object
161 * @param cfg a pointer to a valid confiuration struct
162 * @return a valid preparser object or NULL in case of error
163 */
165 const struct vlc_preparser_cfg *cfg );
166
167/**
168 * This function enqueues the provided item to be preparsed or fetched.
169 *
170 * The input item is retained until the preparsing is done or until the
171 * preparser object is deleted.
172 *
173 * @param preparser the preparser object
174 * @param item a valid item to preparse
175 * @param type_option a combination of VLC_PREPARSER_TYPE_* and
176 * VLC_PREPARSER_OPTION_* flags. The type must be in the set specified in
177 * vlc_preparser_New() (it is possible to select less types).
178 * @param cbs callback to listen to events (can't be NULL)
179 * @param cbs_userdata opaque pointer used by the callbacks
180 * @param id unique id provided by the caller. This is can be used to cancel
181 * the request with vlc_preparser_Cancel()
182 * @return VLC_PREPARSER_REQ_ID_INVALID in case of error, or a valid id if the
183 * item was scheduled for preparsing. If this returns an
184 * error, the on_preparse_ended will *not* be invoked
185 */
187vlc_preparser_Push( vlc_preparser_t *preparser, input_item_t *item, int type_option,
188 const input_item_parser_cbs_t *cbs, void *cbs_userdata );
189
190/**
191 * This function enqueues the provided item for generating a thumbnail
192 *
193 * @param preparser the preparser object
194 * @param item a valid item to generate the thumbnail for
195 * @param arg pointer to a seek struct, that tell at which time the
196 * thumbnail should be taken, NULL to disable seek
197 * @param timeout A timeout value, or VLC_TICK_INVALID to disable timeout
198 * @param cbs callback to listen to events (can't be NULL)
199 * @param cbs_userdata opaque pointer used by the callbacks
200 * @return VLC_PREPARSER_REQ_ID_INVALID in case of error, or a valid id if the
201 * item was scheduled for thumbnailing. If this returns an
202 * error, the thumbnailer.on_ended callback will *not* be invoked
203 *
204 * The provided input_item will be held by the thumbnailer and can safely be
205 * released safely after calling this function.
206 */
209 const struct vlc_thumbnailer_arg *arg,
210 const struct vlc_thumbnailer_cbs *cbs,
211 void *cbs_userdata );
212
213/**
214 * This function cancel all preparsing requests for a given id
215 *
216 * @param preparser the preparser object
217 * @param id unique id returned by vlc_preparser_Push(),
218 * VLC_PREPARSER_REQ_ID_INVALID to cancels all tasks
219 * @return number of tasks cancelled
220 */
223
224/**
225 * This function destroys the preparser object and thread.
226 *
227 * @param preparser the preparser object
228 * All pending input items will be released.
229 */
231
232/**
233 * Do not use, libVLC only fonction, will be removed soon
234 */
236 vlc_tick_t timeout ) VLC_DEPRECATED;
237
238/** @} vlc_preparser */
239
240#endif
241
#define VLC_API
Definition fourcc_gen.c:31
#define VLC_DEPRECATED
Definition vlc_common.h:158
size_t vlc_preparser_Cancel(vlc_preparser_t *preparser, vlc_preparser_req_id id)
This function cancel all preparsing requests for a given id.
Definition preparser.c:554
void vlc_preparser_SetTimeout(vlc_preparser_t *preparser, vlc_tick_t timeout)
Do not use, libVLC only fonction, will be removed soon.
Definition preparser.c:599
vlc_preparser_req_id vlc_preparser_Push(vlc_preparser_t *preparser, input_item_t *item, int type_option, const input_item_parser_cbs_t *cbs, void *cbs_userdata)
This function enqueues the provided item to be preparsed or fetched.
Definition preparser.c:483
vlc_preparser_t * vlc_preparser_New(vlc_object_t *obj, const struct vlc_preparser_cfg *cfg)
This function creates the preparser object and thread.
Definition preparser.c:415
size_t vlc_preparser_req_id
Definition vlc_preparser.h:46
void vlc_preparser_Delete(vlc_preparser_t *preparser)
This function destroys the preparser object and thread.
Definition preparser.c:605
vlc_preparser_req_id vlc_preparser_GenerateThumbnail(vlc_preparser_t *preparser, input_item_t *item, const struct vlc_thumbnailer_arg *arg, const struct vlc_thumbnailer_cbs *cbs, void *cbs_userdata)
This function enqueues the provided item for generating a thumbnail.
Definition preparser.c:529
void * arg
Definition sort.c:32
input item parser callbacks
Definition vlc_input_item.h:431
Describes an input and is used to spawn input_thread_t objects.
Definition vlc_input_item.h:98
Video picture.
Definition vlc_picture.h:130
VLC object common members.
Definition vlc_objects.h:53
Preparser creation configuration.
Definition vlc_preparser.h:132
vlc_tick_t timeout
Timeout of the preparser and/or thumbnailer, 0 for no limits.
Definition vlc_preparser.h:155
int types
A combination of VLC_PREPARSER_TYPE_* flags, it is used to setup the executors for each domain.
Definition vlc_preparser.h:138
unsigned max_parser_threads
The maximum number of threads used by the parser, 0 for default (1 thread)
Definition vlc_preparser.h:144
unsigned max_thumbnailer_threads
The maximum number of threads used by the thumbnailer, 0 for default (1 thread)
Definition vlc_preparser.h:150
Definition preparser.c:41
Seek argument.
Definition vlc_preparser.h:98
enum vlc_thumbnailer_arg::seek::@276 type
enum vlc_thumbnailer_arg::seek::@279 speed
vlc_tick_t time
Seek time if type == VLC_THUMBNAILER_SEEK_TIME.
Definition vlc_preparser.h:111
@ VLC_THUMBNAILER_SEEK_POS
Seek by position.
Definition vlc_preparser.h:106
@ VLC_THUMBNAILER_SEEK_TIME
Seek by time.
Definition vlc_preparser.h:104
@ VLC_THUMBNAILER_SEEK_NONE
Don't seek.
Definition vlc_preparser.h:102
double pos
Seek position if type == VLC_THUMBNAILER_SEEK_POS.
Definition vlc_preparser.h:113
@ VLC_THUMBNAILER_SEEK_FAST
Fast, but potentially imprecise.
Definition vlc_preparser.h:120
@ VLC_THUMBNAILER_SEEK_PRECISE
Precise, but potentially slow.
Definition vlc_preparser.h:118
Thumbnailer argument.
Definition vlc_preparser.h:95
bool hw_dec
True to enable hardware decoder.
Definition vlc_preparser.h:125
Preparser thumbnailer callbacks.
Definition vlc_preparser.h:62
void(* on_ended)(input_item_t *item, int status, picture_t *thumbnail, void *data)
Event received on thumbnailing completion or error.
Definition vlc_preparser.h:87
This file is a collection of common definitions and types.
This file defines functions, structures and enums for input items in vlc.
int64_t vlc_tick_t
High precision date or time interval.
Definition vlc_tick.h:48