mirror of https://code.videolan.org/videolan/vlc
Merge branch 'meta-fetcher-attach' into 'master'
Draft: preparser: meta_fetcher: forward the artwork attachment See merge request videolan/vlc!4998
This commit is contained in:
commit
548679904b
|
@ -21,6 +21,8 @@
|
|||
#ifndef VLC_META_FETCHER_H
|
||||
#define VLC_META_FETCHER_H 1
|
||||
|
||||
#include <vlc_input.h>
|
||||
|
||||
typedef enum meta_fetcher_scope_t
|
||||
{
|
||||
FETCHER_SCOPE_LOCAL = 0x01,
|
||||
|
@ -33,6 +35,22 @@ typedef struct meta_fetcher_t
|
|||
struct vlc_object_t obj;
|
||||
input_item_t *p_item;
|
||||
meta_fetcher_scope_t e_scope;
|
||||
input_attachment_t *attachment_artwork;
|
||||
} meta_fetcher_t;
|
||||
|
||||
static inline int
|
||||
meta_fetcher_SetAttachmentArtwork(meta_fetcher_t *fetcher, const char *mime,
|
||||
const void *data, size_t data_size)
|
||||
{
|
||||
fetcher->attachment_artwork =
|
||||
vlc_input_attachment_New("meta_fetcher_artwork", mime, NULL, data,
|
||||
data_size);
|
||||
if (fetcher->attachment_artwork == NULL)
|
||||
return VLC_ENOMEM;
|
||||
|
||||
input_item_SetArtworkURL(fetcher->p_item, "attachment://meta_fetcher_artwork");
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -219,9 +219,10 @@ static void AddAlbumCache( input_fetcher_t* fetcher, input_item_t* item,
|
|||
free( key );
|
||||
}
|
||||
|
||||
static int InvokeModule( input_fetcher_t* fetcher, input_item_t* item,
|
||||
int scope, char const* type )
|
||||
static int InvokeModule(struct task *task, input_item_t* item,
|
||||
int scope, char const* type )
|
||||
{
|
||||
input_fetcher_t *fetcher = task->fetcher;
|
||||
meta_fetcher_t* mf = vlc_custom_create( fetcher->owner,
|
||||
sizeof( *mf ), type );
|
||||
if( unlikely( !mf ) )
|
||||
|
@ -232,6 +233,15 @@ static int InvokeModule( input_fetcher_t* fetcher, input_item_t* item,
|
|||
|
||||
module_t* mf_module = module_need( mf, type, NULL, false );
|
||||
|
||||
if (mf->attachment_artwork != NULL)
|
||||
{
|
||||
if (task->cbs != NULL && task->cbs->on_attachments_added != NULL)
|
||||
task->cbs->on_attachments_added(item, &mf->attachment_artwork, 1,
|
||||
task->userdata);
|
||||
|
||||
vlc_input_attachment_Release(mf->attachment_artwork);
|
||||
}
|
||||
|
||||
if( mf_module )
|
||||
module_unneed( mf, mf_module );
|
||||
|
||||
|
@ -260,9 +270,9 @@ static int CheckArt( input_item_t* item )
|
|||
return error;
|
||||
}
|
||||
|
||||
static int SearchArt( input_fetcher_t* fetcher, input_item_t* item, int scope)
|
||||
static int SearchArt(struct task *task, input_item_t* item, int scope)
|
||||
{
|
||||
InvokeModule( fetcher, item, scope, "art finder" );
|
||||
InvokeModule(task, item, scope, "art finder");
|
||||
return CheckArt( item );
|
||||
}
|
||||
|
||||
|
@ -272,7 +282,7 @@ static int SearchByScope(struct task *task, int scope)
|
|||
input_item_t* item = task->item;
|
||||
|
||||
if( CheckMeta( item ) &&
|
||||
InvokeModule( fetcher, item, scope, "meta fetcher" ) )
|
||||
InvokeModule( task, item, scope, "meta fetcher" ) )
|
||||
{
|
||||
return VLC_EGENERIC;
|
||||
}
|
||||
|
@ -281,7 +291,7 @@ static int SearchByScope(struct task *task, int scope)
|
|||
! ReadAlbumCache( fetcher, item ) ||
|
||||
! input_FindArtInCacheUsingItemUID( item ) ||
|
||||
! input_FindArtInCache( item ) ||
|
||||
! SearchArt( fetcher, item, scope ) )
|
||||
! SearchArt(task, item, scope ) )
|
||||
{
|
||||
AddAlbumCache( fetcher, task->item, false );
|
||||
int ret = Submit(fetcher, fetcher->executor_downloader, item,
|
||||
|
|
|
@ -36,6 +36,9 @@ typedef struct input_fetcher_t input_fetcher_t;
|
|||
|
||||
typedef struct input_fetcher_callbacks_t {
|
||||
void (*on_art_fetch_ended)(input_item_t *, bool fetched, void *userdata);
|
||||
void (*on_attachments_added)(input_item_t *item,
|
||||
input_attachment_t *const *array,
|
||||
size_t count, void *userdata);
|
||||
} input_fetcher_callbacks_t;
|
||||
|
||||
/**
|
||||
|
|
|
@ -209,6 +209,7 @@ OnArtFetchEnded(input_item_t *item, bool fetched, void *userdata)
|
|||
|
||||
static const input_fetcher_callbacks_t input_fetcher_callbacks = {
|
||||
.on_art_fetch_ended = OnArtFetchEnded,
|
||||
.on_attachments_added = OnParserAttachmentsAdded,
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue