VLC  4.0.0-dev
preparser.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * preparser.h
3  *****************************************************************************
4  * Copyright (C) 1999-2008 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 _INPUT_PREPARSER_H
25 #define _INPUT_PREPARSER_H 1
26 
27 #include <vlc_input_item.h>
28 /**
29  * Preparser opaque structure.
30  *
31  * The preparser object will retrieve the meta data of any given input item in
32  * an asynchronous way.
33  * It will also issue art fetching requests.
34  */
36 
37 /**
38  * This function creates the preparser object and thread.
39  */
41 
42 /**
43  * This function enqueues the provided item to be preparsed.
44  *
45  * The input item is retained until the preparsing is done or until the
46  * preparser object is deleted.
47  *
48  * @param timeout maximum time allowed to preparse the item. If -1, the default
49  * "preparse-timeout" option will be used as a timeout. If 0, it will wait
50  * indefinitely. If > 0, the timeout will be used (in milliseconds).
51  * @param id unique id provided by the caller. This is can be used to cancel
52  * the request with input_preparser_Cancel()
53  * @returns VLC_SUCCESS if the item was scheduled for preparsing, an error code
54  * otherwise
55  * If this returns an error, the on_preparse_ended will *not* be invoked
56  */
59  const input_preparser_callbacks_t *cbs,
60  void *cbs_userdata,
61  int timeout, void *id );
62 
65  const input_fetcher_callbacks_t *cbs,
66  void *cbs_userdata );
67 
68 /**
69  * This function cancel all preparsing requests for a given id
70  *
71  * @param id unique id given to input_preparser_Push()
72  */
73 void input_preparser_Cancel( input_preparser_t *, void *id );
74 
75 /**
76  * This function destroys the preparser object and thread.
77  *
78  * All pending input items will be released.
79  */
81 
82 /**
83  * This function deactivates the preparser
84  *
85  * All pending requests will be removed, and it will block until the currently
86  * running entity has finished (if any).
87  */
89 
90 #endif
91 
task::parser
input_item_parser_id_t * parser
Definition: preparser.c:56
task::id
void * id
Definition: preparser.c:53
vlc_runnable::userdata
void * userdata
Userdata passed back to run().
Definition: vlc_executor.h:60
vlc_mutex_init
void vlc_mutex_init(vlc_mutex_t *mtx)
Initializes a fast mutex.
Definition: threads.c:123
input_preparser_t::submitted_tasks
struct vlc_list submitted_tasks
list of struct task
Definition: preparser.c:61
input_preparser_t::owner
vlc_object_t * owner
Definition: preparser.c:54
input_preparser_t::default_timeout
vlc_tick_t default_timeout
Definition: preparser.c:57
vlc_executor.h
input_item_type_e
input_item_type_e
Definition: vlc_input_item.h:59
input_fetcher_callbacks_t
Definition: vlc_input_item.h:489
Interrupt
static void Interrupt(struct task *task)
Definition: preparser.c:289
Parse
static void Parse(struct task *task, vlc_tick_t deadline)
Definition: preparser.c:196
META_REQUEST_OPTION_SCOPE_NETWORK
@ META_REQUEST_OPTION_SCOPE_NETWORK
Definition: vlc_input_item.h:467
task::userdata
void * userdata
Definition: fetcher.c:60
ITEM_TYPE_PLAYLIST
@ ITEM_TYPE_PLAYLIST
Definition: vlc_input_item.h:67
fetcher.h
input_preparser_Delete
void input_preparser_Delete(input_preparser_t *preparser)
This function destroys the preparser object and thread.
Definition: preparser.c:420
task
Definition: fetcher.c:54
vlc_input_item.h
task::options
input_item_meta_request_option_t options
Definition: preparser.c:50
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
input_fetcher_Push
int input_fetcher_Push(input_fetcher_t *fetcher, input_item_t *item, input_item_meta_request_option_t options, const input_fetcher_callbacks_t *cbs, void *cbs_userdata)
This function enqueues the provided item to be art fetched.
Definition: fetcher.c:475
input_fetcher_Delete
void input_fetcher_Delete(input_fetcher_t *fetcher)
This function destroys the fetcher object and thread.
Definition: fetcher.c:509
vlc_common.h
RunnableRun
static void RunnableRun(void *)
Definition: preparser.c:259
PreparserRemoveTask
static void PreparserRemoveTask(input_preparser_t *preparser, struct task *task)
Definition: preparser.c:126
input_item_t
Describes an input and is used to spawn input_thread_t objects.
Definition: vlc_input_item.h:77
ITEM_TYPE_FILE
@ ITEM_TYPE_FILE
Definition: vlc_input_item.h:62
vlc_executor
The executor (also vlc_executor_t, exposed as opaque type in the public header).
Definition: executor.c:55
vlc_list_init
static void vlc_list_init(struct vlc_list *restrict head)
Initializes an empty list head.
Definition: vlc_list.h:57
input_item_t::lock
vlc_mutex_t lock
Lock for the item.
Definition: vlc_input_item.h:112
TaskDelete
static void TaskDelete(struct task *task)
Definition: preparser.c:111
vlc_cond_wait
void vlc_cond_wait(vlc_cond_t *cond, vlc_mutex_t *mutex)
Waits on a condition variable.
Definition: threads.c:340
input_item_t::i_type
enum input_item_type_e i_type
Type (file, disc, ...
Definition: vlc_input_item.h:114
vlc_executor_New
vlc_executor_t * vlc_executor_New(unsigned max_threads)
Create a new executor.
Definition: executor.c:173
PreparserAddTask
static void PreparserAddTask(input_preparser_t *preparser, struct task *task)
Definition: preparser.c:118
OnParserEnded
static void OnParserEnded(input_item_t *item, int status, void *task_)
Definition: preparser.c:142
input_preparser_fetcher_Push
void input_preparser_fetcher_Push(input_preparser_t *preparser, input_item_t *item, input_item_meta_request_option_t options, const input_fetcher_callbacks_t *cbs, void *cbs_userdata)
Definition: preparser.c:379
VLC_EGENERIC
#define VLC_EGENERIC
Unspecified error.
Definition: vlc_common.h:474
vlc_list
Doubly-linked list node.
Definition: vlc_list.h:43
input_item_SetPreparsed
void input_item_SetPreparsed(input_item_t *p_i, bool b_preparsed)
Definition: item.c:68
vlc_runnable
A Runnable encapsulates a task to be run from an executor thread.
Definition: vlc_executor.h:38
vlc_cond_signal
void vlc_cond_signal(vlc_cond_t *cond)
Wakes up one thread waiting on a condition variable.
Definition: threads.c:253
task::preparse_status
int preparse_status
Definition: preparser.c:61
vlc_mutex_t
Mutex.
Definition: vlc_threads.h:225
input_preparser_Cancel
void input_preparser_Cancel(input_preparser_t *, void *id)
This function cancel all preparsing requests for a given id.
Definition: preparser.c:388
ITEM_PREPARSE_FAILED
@ ITEM_PREPARSE_FAILED
Definition: vlc_input_item.h:479
msg_Warn
#define msg_Warn(p_this,...)
Definition: vlc_messages.h:104
input_preparser_Delete
void input_preparser_Delete(input_preparser_t *)
This function destroys the preparser object and thread.
Definition: preparser.c:420
vlc_tick_now
vlc_tick_t vlc_tick_now(void)
Precision monotonic clock.
Definition: thread.c:261
vlc_runnable::run
void(* run)(void *userdata)
This function is to be executed by a vlc_executor_t.
Definition: vlc_executor.h:55
i_type
int i_type
Definition: httpd.c:1269
task::preparse_ended
bool preparse_ended
Definition: preparser.c:60
input_preparser_New
input_preparser_t * input_preparser_New(vlc_object_t *parent)
This function creates the preparser object and thread.
Definition: preparser.c:301
input_fetcher_t
Definition: fetcher.c:42
vlc_atomic.h
vlc_tick_t
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
vlc_list_remove
static void vlc_list_remove(struct vlc_list *restrict node)
Removes an element from a list.
Definition: vlc_list.h:135
ITEM_PREPARSE_DONE
@ ITEM_PREPARSE_DONE
Definition: vlc_input_item.h:481
vlc_list_append
static void vlc_list_append(struct vlc_list *restrict node, struct vlc_list *head)
Appends an element into a list.
Definition: vlc_list.h:110
input_preparser_callbacks_t
Definition: vlc_input_item.h:484
input_item_t::b_preparse_interact
bool b_preparse_interact
Force interaction with the user when preparsing.
Definition: vlc_input_item.h:122
task::fetch_ended
bool fetch_ended
Definition: preparser.c:62
input_item_parser_id_t
Definition: item.c:1337
VLC_TICK_INVALID
#define VLC_TICK_INVALID
Definition: vlc_config.h:44
input_preparser_Deactivate
void input_preparser_Deactivate(input_preparser_t *)
This function deactivates the preparser.
Definition: preparser.c:414
input_item_meta_request_option_t
input_item_meta_request_option_t
Definition: vlc_input_item.h:463
TaskNew
static struct task * TaskNew(input_preparser_t *preparser, input_item_t *item, input_item_meta_request_option_t options, const input_preparser_callbacks_t *cbs, void *userdata, void *id, vlc_tick_t timeout)
Definition: preparser.c:74
task::item
input_item_t * item
Definition: fetcher.c:57
META_REQUEST_OPTION_FETCH_ANY
@ META_REQUEST_OPTION_FETCH_ANY
Definition: vlc_input_item.h:471
ITEM_TYPE_DIRECTORY
@ ITEM_TYPE_DIRECTORY
Definition: vlc_input_item.h:63
OnParserSubtreeAdded
static void OnParserSubtreeAdded(input_item_t *item, input_item_node_t *subtree, void *task_)
Definition: preparser.c:165
task::node
struct vlc_list node
node of input_fetcher_t.submitted_tasks
Definition: fetcher.c:65
input_item_Release
void input_item_Release(input_item_t *p_item)
Releases an input item, i.e.
Definition: item.c:450
task::options
int options
Definition: fetcher.c:58
task::preparser
input_preparser_t * preparser
Definition: preparser.c:48
input_preparser_Cancel
void input_preparser_Cancel(input_preparser_t *preparser, void *id)
This function cancel all preparsing requests for a given id.
Definition: preparser.c:388
input_item_parser_cbs_t
input item parser callbacks
Definition: vlc_input_item.h:399
input_preparser_Push
int input_preparser_Push(input_preparser_t *preparser, input_item_t *item, input_item_meta_request_option_t i_options, const input_preparser_callbacks_t *cbs, void *cbs_userdata, int timeout_ms, void *id)
This function enqueues the provided item to be preparsed.
Definition: preparser.c:336
META_REQUEST_OPTION_DO_INTERACT
@ META_REQUEST_OPTION_DO_INTERACT
Definition: vlc_input_item.h:472
vlc_object_t
VLC object common members.
Definition: vlc_objects.h:43
VLC_ENOMEM
#define VLC_ENOMEM
Not enough memory.
Definition: vlc_common.h:476
task::cbs
const input_preparser_callbacks_t * cbs
Definition: preparser.c:51
VLC_UNUSED
#define VLC_UNUSED(x)
Definition: vlc_common.h:1105
task::cond_ended
vlc_cond_t cond_ended
Definition: preparser.c:59
input_interface.h
VLC_SUCCESS
#define VLC_SUCCESS
No error.
Definition: vlc_common.h:472
input_preparser_Deactivate
void input_preparser_Deactivate(input_preparser_t *preparser)
This function deactivates the preparser.
Definition: preparser.c:414
var_InheritInteger
static int64_t var_InheritInteger(vlc_object_t *obj, const char *name)
Definition: vlc_variables.h:685
VLC_TICK_FROM_MS
#define VLC_TICK_FROM_MS(ms)
Definition: vlc_tick.h:122
input_preparser_Push
int input_preparser_Push(input_preparser_t *, input_item_t *, input_item_meta_request_option_t, const input_preparser_callbacks_t *cbs, void *cbs_userdata, int timeout, void *id)
This function enqueues the provided item to be preparsed.
Definition: preparser.c:336
vlc_executor_Cancel
bool vlc_executor_Cancel(vlc_executor_t *executor, struct vlc_runnable *runnable)
Cancel a runnable previously submitted.
Definition: executor.c:223
vlc_mutex_lock
void vlc_mutex_lock(vlc_mutex_t *mtx)
Acquires a mutex.
Definition: threads.c:158
input_preparser_t
Definition: preparser.c:34
ITEM_TYPE_NODE
@ ITEM_TYPE_NODE
Definition: vlc_input_item.h:68
input_item_t::b_net
bool b_net
Net: always true for TYPE_STREAM, it depends for others types.
Definition: vlc_input_item.h:115
vlc_cond_t
Condition variable.
Definition: vlc_threads.h:349
NotifyPreparseEnded
static void NotifyPreparseEnded(struct task *task)
Definition: preparser.c:134
input_preparser_fetcher_Push
void input_preparser_fetcher_Push(input_preparser_t *, input_item_t *, input_item_meta_request_option_t, const input_fetcher_callbacks_t *cbs, void *cbs_userdata)
Definition: preparser.c:379
task::cbs
const input_fetcher_callbacks_t * cbs
Definition: fetcher.c:59
Fetch
static void Fetch(struct task *task)
Definition: preparser.c:238
ITEM_PREPARSE_TIMEOUT
@ ITEM_PREPARSE_TIMEOUT
Definition: vlc_input_item.h:480
ITEM_PREPARSE_SKIPPED
@ ITEM_PREPARSE_SKIPPED
Definition: vlc_input_item.h:478
input_preparser_New
input_preparser_t * input_preparser_New(vlc_object_t *)
This function creates the preparser object and thread.
Definition: preparser.c:301
task::runnable
struct vlc_runnable runnable
to be passed to the executor
Definition: fetcher.c:64
input_preparser_t::lock
vlc_mutex_t lock
Definition: preparser.c:60
vlc_executor_Submit
void vlc_executor_Submit(vlc_executor_t *executor, struct vlc_runnable *runnable)
Submit a runnable for execution.
Definition: executor.c:206
vlc_list_foreach
#define vlc_list_foreach(pos, head, member)
List iteration macro.
Definition: vlc_list.h:261
input_fetcher_callbacks_t::on_art_fetch_ended
void(* on_art_fetch_ended)(input_item_t *, bool fetched, void *userdata)
Definition: vlc_input_item.h:490
vlc_executor_Delete
void vlc_executor_Delete(vlc_executor_t *executor)
Delete an executor.
Definition: executor.c:256
OnArtFetchEnded
static void OnArtFetchEnded(input_item_t *item, bool fetched, void *userdata)
Definition: preparser.c:176
input_preparser_t::executor
vlc_executor_t * executor
Definition: preparser.c:56
task::fetcher
input_fetcher_t * fetcher
Definition: fetcher.c:55
input_fetcher_New
input_fetcher_t * input_fetcher_New(vlc_object_t *owner)
This function creates the fetcher object and thread.
Definition: fetcher.c:430
task::interrupted
atomic_bool interrupted
Definition: preparser.c:64
input_fetcher_callbacks
static const input_fetcher_callbacks_t input_fetcher_callbacks
Definition: preparser.c:191
vlc_cond_init
void vlc_cond_init(vlc_cond_t *cond)
Initializes a condition variable.
Definition: threads.c:234
input_item_node_t
Definition: vlc_input_item.h:194
task::lock
vlc_mutex_t lock
Definition: preparser.c:58
input_preparser_t::deactivated
atomic_bool deactivated
Definition: preparser.c:58
vlc_cond_timedwait
int vlc_cond_timedwait(vlc_cond_t *cond, vlc_mutex_t *mutex, vlc_tick_t deadline)
Waits on a condition variable up to a certain date.
Definition: threads.c:349
input_item_Hold
input_item_t * input_item_Hold(input_item_t *p_item)
Holds an input item, i.e.
Definition: item.c:442
input_item_Parse
input_item_parser_id_t * input_item_Parse(input_item_t *item, vlc_object_t *obj, const input_item_parser_cbs_t *cbs, void *userdata)
Parse an item asynchronously.
Definition: item.c:1376
input_internal.h
preparser.h
vlc_mutex_unlock
void vlc_mutex_unlock(vlc_mutex_t *mtx)
Releases a mutex.
Definition: threads.c:209
input_preparser_t::fetcher
input_fetcher_t * fetcher
Definition: preparser.c:55
task::timeout
vlc_tick_t timeout
Definition: preparser.c:54
input_item_parser_id_Release
void input_item_parser_id_Release(input_item_parser_id_t *parser)
Release (and interrupt if needed) a parser.
Definition: item.c:1406