VLC  4.0.0-dev
fetcher.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * fetcher.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_FETCHER_H
25 #define _INPUT_FETCHER_H 1
26 
27 #include <vlc_input_item.h>
28 
29 /**
30  * Fetcher opaque structure.
31  *
32  * The fetcher object will retrieve the art album data for any given input
33  * item in an asynchronous way.
34  */
36 
37 /**
38  * This function creates the fetcher object and thread.
39  */
41 
42 /**
43  * This function enqueues the provided item to be art fetched.
44  *
45  * The input item is retained until the art fetching is done or until the
46  * fetcher object is destroyed.
47  */
50  const input_fetcher_callbacks_t *, void * );
51 
52 /**
53  * This function destroys the fetcher object and thread.
54  *
55  * All pending input items will be released.
56  */
58 
59 #endif
60 
RunSearchLocal
static void RunSearchLocal(void *)
Definition: fetcher.c:380
vlc_dictionary_insert
static void vlc_dictionary_insert(vlc_dictionary_t *p_dict, const char *psz_key, void *p_value)
Definition: vlc_arrays.h:587
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
ReadAlbumCache
static int ReadAlbumCache(input_fetcher_t *fetcher, input_item_t *item)
Definition: fetcher.c:183
vlc_executor.h
input_item_t::p_meta
vlc_meta_t * p_meta
Definition: vlc_input_item.h:99
vlc_memstream
In-memory stream object.
Definition: vlc_memstream.h:41
input_fetcher_callbacks_t
Definition: vlc_input_item.h:489
vlc_meta_Get
const char * vlc_meta_Get(const vlc_meta_t *p_meta, vlc_meta_type_t meta_type)
Definition: meta.c:129
var_InheritBool
static bool var_InheritBool(vlc_object_t *obj, const char *name)
Definition: vlc_variables.h:675
SearchByScope
static int SearchByScope(struct task *task, int scope)
Definition: fetcher.c:269
meta_fetcher_t::p_item
input_item_t * p_item
Definition: vlc_meta_fetcher.h:35
task::userdata
void * userdata
Definition: fetcher.c:60
fetcher.h
input_fetcher_t::album_cache
vlc_dictionary_t album_cache
Definition: fetcher.c:65
FETCHER_SCOPE_LOCAL
@ FETCHER_SCOPE_LOCAL
Definition: vlc_meta_fetcher.h:45
task
Definition: fetcher.c:54
vlc_meta_Album
@ vlc_meta_Album
Definition: vlc_meta.h:39
vlc_memstream::ptr
char * ptr
Buffer start address.
Definition: vlc_memstream.h:48
vlc_input_item.h
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
FetcherRemoveTask
static void FetcherRemoveTask(input_fetcher_t *fetcher, struct task *task)
Definition: fetcher.c:124
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_memstream::error
int error
Definition: vlc_memstream.h:46
vlc_common.h
input_item_SetArtFetched
void input_item_SetArtFetched(input_item_t *p_i, bool b_art_fetched)
Definition: item.c:112
vlc_meta_fetcher.h
vlc_memstream::length
size_t length
Buffer length in bytes.
Definition: vlc_memstream.h:49
vlc_interrupt.h
input_item_t
Describes an input and is used to spawn input_thread_t objects.
Definition: vlc_input_item.h:77
vlc_dictionary_t
Definition: vlc_arrays.h:407
input_fetcher_t::owner
vlc_object_t * owner
Definition: fetcher.c:66
vlc_dictionary_clear
static void vlc_dictionary_clear(vlc_dictionary_t *p_dict, void(*pf_free)(void *p_data, void *p_obj), void *p_obj)
Definition: vlc_arrays.h:428
FreeCacheEntry
static void FreeCacheEntry(void *data, void *obj)
Definition: fetcher.c:177
vlc_executor
The executor (also vlc_executor_t, exposed as opaque type in the public header).
Definition: executor.c:55
input_SaveArt
int input_SaveArt(vlc_object_t *obj, input_item_t *p_item, const void *data, size_t length, const char *psz_type)
Definition: art.c:286
input_item_SetArtURL
#define input_item_SetArtURL
Definition: vlc_input_item.h:330
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
input_fetcher_t::executor_downloader
vlc_executor_t * executor_downloader
Definition: fetcher.c:63
FetcherAddTask
static void FetcherAddTask(input_fetcher_t *fetcher, struct task *task)
Definition: fetcher.c:116
input_fetcher_t::executor_network
vlc_executor_t * executor_network
Definition: fetcher.c:62
vlc_executor_New
vlc_executor_t * vlc_executor_New(unsigned max_threads)
Create a new executor.
Definition: executor.c:173
input_fetcher_t::executor_local
vlc_executor_t * executor_local
Definition: fetcher.c:61
vlc_stream_NewURL
#define vlc_stream_NewURL(a, b)
Definition: vlc_stream.h:422
vlc_threads.h
VLC_EGENERIC
#define VLC_EGENERIC
Unspecified error.
Definition: vlc_common.h:474
vlc_memstream_open
int vlc_memstream_open(struct vlc_memstream *ms)
Initializes a byte stream object.
Definition: memstream.c:105
FETCHER_SCOPE_NETWORK
@ FETCHER_SCOPE_NETWORK
Definition: vlc_meta_fetcher.h:46
vlc_memstream_close
int vlc_memstream_close(struct vlc_memstream *ms)
Closes a byte stream object.
Definition: memstream.c:120
vlc_list
Doubly-linked list node.
Definition: vlc_list.h:43
asprintf
int asprintf(char **, const char *,...)
vlc_runnable
A Runnable encapsulates a task to be run from an executor thread.
Definition: vlc_executor.h:38
CancelAllTasks
static void CancelAllTasks(input_fetcher_t *fetcher)
Definition: fetcher.c:489
vlc_mutex_t
Mutex.
Definition: vlc_threads.h:225
AddAlbumCache
static void AddAlbumCache(input_fetcher_t *fetcher, input_item_t *item, bool overwrite)
Definition: fetcher.c:201
vlc_meta_Title
@ vlc_meta_Title
Definition: vlc_meta.h:35
input_item_SetArtNotFound
void input_item_SetArtNotFound(input_item_t *p_i, bool b_not_found)
Definition: item.c:96
input_item_GetArtURL
#define input_item_GetArtURL
Definition: vlc_input_item.h:331
TaskDelete
static void TaskDelete(struct task *task)
Definition: fetcher.c:108
input_fetcher_New
input_fetcher_t * input_fetcher_New(vlc_object_t *)
This function creates the fetcher object and thread.
Definition: fetcher.c:430
interrupt.h
vlc_meta_Artist
@ vlc_meta_Artist
Definition: vlc_meta.h:36
vlc_runnable::run
void(* run)(void *userdata)
This function is to be executed by a vlc_executor_t.
Definition: vlc_executor.h:55
input_fetcher_t::lock
vlc_mutex_t lock
Definition: fetcher.c:68
input_fetcher_t
Definition: fetcher.c:42
module_t
Internal module descriptor.
Definition: modules.h:78
vlc_atomic.h
vlc_memstream.h
NotifyArtFetchEnded
static void NotifyArtFetchEnded(struct task *task, bool fetched)
Definition: fetcher.c:296
vlc_list_remove
static void vlc_list_remove(struct vlc_list *restrict node)
Removes an element from a list.
Definition: vlc_list.h:135
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
vlc_dictionary_value_for_key
static void * vlc_dictionary_value_for_key(const vlc_dictionary_t *p_dict, const char *psz_key)
Definition: vlc_arrays.h:471
input_fetcher_Delete
void input_fetcher_Delete(input_fetcher_t *)
This function destroys the fetcher object and thread.
Definition: fetcher.c:509
vlc_meta_ArtworkURL
@ vlc_meta_ArtworkURL
Definition: vlc_meta.h:51
vlc_meta_Date
@ vlc_meta_Date
Definition: vlc_meta.h:43
META_REQUEST_OPTION_FETCH_LOCAL
@ META_REQUEST_OPTION_FETCH_LOCAL
Definition: vlc_input_item.h:469
meta_fetcher_t::e_scope
meta_fetcher_scope_t e_scope
Definition: vlc_meta_fetcher.h:36
meta_fetcher_t
Definition: vlc_meta_fetcher.h:32
SearchArt
static int SearchArt(input_fetcher_t *fetcher, input_item_t *item, int scope)
Definition: fetcher.c:263
input_item_meta_request_option_t
input_item_meta_request_option_t
Definition: vlc_input_item.h:463
task::item
input_item_t * item
Definition: fetcher.c:57
TaskNew
static struct task * TaskNew(input_fetcher_t *fetcher, vlc_executor_t *executor, input_item_t *item, input_item_meta_request_option_t options, const input_fetcher_callbacks_t *cbs, void *userdata)
Definition: fetcher.c:73
vlc_interrupt_deinit
void vlc_interrupt_deinit(vlc_interrupt_t *ctx)
Deinitializes an interruption context.
Definition: interrupt.c:71
stream_t
stream_t definition
Definition: vlc_stream.h:46
META_REQUEST_OPTION_FETCH_ANY
@ META_REQUEST_OPTION_FETCH_ANY
Definition: vlc_input_item.h:471
vlc_killed
bool vlc_killed(void)
Checks if the interruption context was "killed".
Definition: interrupt.c:185
RunSearchNetwork
static void RunSearchNetwork(void *)
Definition: fetcher.c:411
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
vlc_interrupt
Definition: interrupt.h:32
input_fetcher_t::submitted_tasks
struct vlc_list submitted_tasks
list of struct task
Definition: fetcher.c:69
vlc_stream_Read
ssize_t vlc_stream_Read(stream_t *s, void *buf, size_t len)
Reads data from a byte stream.
Definition: stream.c:485
art.h
CheckMeta
static int CheckMeta(input_item_t *item)
Definition: fetcher.c:243
vlc_dictionary_has_key
static int vlc_dictionary_has_key(const vlc_dictionary_t *p_dict, const char *psz_key)
Definition: vlc_arrays.h:455
vlc_interrupt_set
vlc_interrupt_t * vlc_interrupt_set(vlc_interrupt_t *newctx)
Sets the interruption context for the calling thread.
Definition: interrupt.c:98
vlc_object_t
VLC object common members.
Definition: vlc_objects.h:43
input_FindArtInCacheUsingItemUID
int input_FindArtInCacheUsingItemUID(input_item_t *p_item)
Definition: art.c:249
VLC_ENOMEM
#define VLC_ENOMEM
Not enough memory.
Definition: vlc_common.h:476
VLC_UNUSED
#define VLC_UNUSED(x)
Definition: vlc_common.h:1105
vlc_stream.h
input_interface.h
VLC_SUCCESS
#define VLC_SUCCESS
No error.
Definition: vlc_common.h:472
FREENULL
#define FREENULL(a)
Definition: vlc_common.h:961
var_InheritInteger
static int64_t var_InheritInteger(vlc_object_t *obj, const char *name)
Definition: vlc_variables.h:685
input_FindArtInCache
int input_FindArtInCache(input_item_t *p_item)
Definition: art.c:180
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_custom_create
#define vlc_custom_create(o, s, n)
Definition: libvlc.h:117
vlc_mutex_lock
void vlc_mutex_lock(vlc_mutex_t *mtx)
Acquires a mutex.
Definition: threads.c:158
task::cbs
const input_fetcher_callbacks_t * cbs
Definition: fetcher.c:59
META_REQUEST_OPTION_FETCH_NETWORK
@ META_REQUEST_OPTION_FETCH_NETWORK
Definition: vlc_input_item.h:470
task::runnable
struct vlc_runnable runnable
to be passed to the executor
Definition: fetcher.c:64
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
vlc_stream_Delete
void vlc_stream_Delete(stream_t *s)
Destroy a stream.
Definition: stream.c:133
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
libvlc.h
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
vlc_object_delete
#define vlc_object_delete(obj)
Definition: vlc_objects.h:136
vlc_dictionary_init
static void vlc_dictionary_init(vlc_dictionary_t *p_dict, int i_size)
Definition: vlc_arrays.h:415
var_SetAddress
static int var_SetAddress(vlc_object_t *p_obj, const char *psz_name, void *ptr)
Set the value of a pointer variable.
Definition: vlc_variables.h:360
vlc_arrays.h
vlc_interrupt_init
void vlc_interrupt_init(vlc_interrupt_t *ctx)
Initializes an interruption context.
Definition: interrupt.c:51
task::executor
vlc_executor_t * executor
Definition: fetcher.c:56
input_item_Hold
input_item_t * input_item_Hold(input_item_t *p_item)
Holds an input item, i.e.
Definition: item.c:442
module_unneed
#define module_unneed(a, b)
Definition: vlc_modules.h:126
RunDownloader
static void RunDownloader(void *)
Definition: fetcher.c:302
vlc_memstream_write
size_t vlc_memstream_write(struct vlc_memstream *ms, const void *ptr, size_t len)
Appends a binary blob to a byte stream.
Definition: memstream.c:127
InvokeModule
static int InvokeModule(input_fetcher_t *fetcher, input_item_t *item, int scope, char const *type)
Definition: fetcher.c:222
CreateCacheKey
static char * CreateCacheKey(input_item_t *item)
Definition: fetcher.c:147
vlc_mutex_unlock
void vlc_mutex_unlock(vlc_mutex_t *mtx)
Releases a mutex.
Definition: threads.c:209
CheckArt
static int CheckArt(input_item_t *item)
Definition: fetcher.c:254
Submit
static int Submit(input_fetcher_t *fetcher, vlc_executor_t *executor, input_item_t *item, input_item_meta_request_option_t options, const input_fetcher_callbacks_t *cbs, void *userdata)
Definition: fetcher.c:132
input_fetcher_Push
int input_fetcher_Push(input_fetcher_t *, input_item_t *, input_item_meta_request_option_t, const input_fetcher_callbacks_t *, void *)
This function enqueues the provided item to be art fetched.
Definition: fetcher.c:475
module_need
#define module_need(a, b, c, d)
Definition: vlc_modules.h:111
vlc_modules.h
task::interrupt
vlc_interrupt_t interrupt
Definition: fetcher.c:62