Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
a0cbc6ed
Commit
a0cbc6ed
authored
Sep 29, 2006
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve meta/art logic
parent
71079c79
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
84 deletions
+88
-84
include/vlc_input.h
include/vlc_input.h
+5
-5
include/vlc_meta.h
include/vlc_meta.h
+1
-1
include/vlc_symbols.h
include/vlc_symbols.h
+8
-12
src/input/meta.c
src/input/meta.c
+57
-49
src/playlist/engine.c
src/playlist/engine.c
+17
-17
No files found.
include/vlc_input.h
View file @
a0cbc6ed
...
...
@@ -474,10 +474,11 @@ VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
VLC_EXPORT
(
void
,
input_DestroyThread
,
(
input_thread_t
*
)
);
#define input_MetaFetch(a,b) __input_MetaFetch(VLC_OBJECT(a),b)
VLC_EXPORT
(
int
,
__input_MetaFetch
,
(
vlc_object_t
*
,
input_item_t
*
)
);
#define input_ArtFetch(a,b) __input_ArtFetch(VLC_OBJECT(a),b)
VLC_EXPORT
(
int
,
__input_ArtFetch
,
(
vlc_object_t
*
,
input_item_t
*
)
);
int
input_MetaFetch
(
playlist_t
*
,
input_item_t
*
);
int
input_ArtFetch
(
playlist_t
*
,
input_item_t
*
);
vlc_bool_t
input_MetaSatisfied
(
playlist_t
*
,
input_item_t
*
,
uint32_t
*
,
uint32_t
*
,
vlc_bool_t
);
int
input_DownloadAndCacheArt
(
playlist_t
*
,
input_item_t
*
);
enum
input_query_e
{
...
...
@@ -540,7 +541,6 @@ VLC_EXPORT( void, input_DecoderDecode,( decoder_t *, block_t * ) );
VLC_EXPORT
(
vlc_bool_t
,
input_AddSubtitles
,
(
input_thread_t
*
,
char
*
,
vlc_bool_t
)
);
VLC_EXPORT
(
int
,
input_DownloadAndCacheArt
,
(
vlc_object_t
*
p_parent
,
input_item_t
*
p_item
)
);
#endif
include/vlc_meta.h
View file @
a0cbc6ed
...
...
@@ -225,6 +225,6 @@ struct meta_engine_t
input_item_t
*
p_item
;
};
VLC_EXPORT
(
uint32_t
,
input_GetMetaEngineFlags
,
(
vlc_meta_t
*
p_meta
)
);
uint32_t
input_CurrentMetaFlags
(
vlc_meta_t
*
p_meta
);
#endif
include/vlc_symbols.h
View file @
a0cbc6ed
...
...
@@ -543,10 +543,10 @@ struct module_symbols_t
char
*
(
*
input_ItemGetInfo_inner
)
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
);
int
(
*
input_ItemAddInfo_inner
)
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
,
const
char
*
psz_format
,
...);
void
(
*
input_ItemAddOptionNoDup_inner
)
(
input_item_t
*
,
const
char
*
);
int
(
*
__input_MetaFetch_inner
)
(
vlc_object_t
*
,
input_item_t
*
)
;
int
(
*
input_DownloadAndCacheArt_inner
)
(
vlc_object_t
*
p_parent
,
input_item_t
*
p_item
)
;
uint32_t
(
*
input_GetMetaEngineFlags_inner
)
(
vlc_meta_t
*
p_meta
)
;
int
(
*
__input_ArtFetch_inner
)
(
vlc_object_t
*
,
input_item_t
*
)
;
void
*
__input_MetaFetch_deprecated
;
void
*
input_DownloadAndCacheArt_deprecated
;
void
*
input_GetMetaEngineFlags_deprecated
;
void
*
__input_ArtFetch_deprecated
;
void
*
input_AskForArt_deprecated
;
int
(
*
playlist_AskForArtEnqueue_inner
)
(
playlist_t
*
,
input_item_t
*
);
};
...
...
@@ -1022,10 +1022,6 @@ struct module_symbols_t
# define input_ItemGetInfo (p_symbols)->input_ItemGetInfo_inner
# define input_ItemAddInfo (p_symbols)->input_ItemAddInfo_inner
# define input_ItemAddOptionNoDup (p_symbols)->input_ItemAddOptionNoDup_inner
# define __input_MetaFetch (p_symbols)->__input_MetaFetch_inner
# define input_DownloadAndCacheArt (p_symbols)->input_DownloadAndCacheArt_inner
# define input_GetMetaEngineFlags (p_symbols)->input_GetMetaEngineFlags_inner
# define __input_ArtFetch (p_symbols)->__input_ArtFetch_inner
# define playlist_AskForArtEnqueue (p_symbols)->playlist_AskForArtEnqueue_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
...
...
@@ -1503,10 +1499,6 @@ struct module_symbols_t
((p_symbols)->input_ItemGetInfo_inner) = input_ItemGetInfo; \
((p_symbols)->input_ItemAddInfo_inner) = input_ItemAddInfo; \
((p_symbols)->input_ItemAddOptionNoDup_inner) = input_ItemAddOptionNoDup; \
((p_symbols)->__input_MetaFetch_inner) = __input_MetaFetch; \
((p_symbols)->input_DownloadAndCacheArt_inner) = input_DownloadAndCacheArt; \
((p_symbols)->input_GetMetaEngineFlags_inner) = input_GetMetaEngineFlags; \
((p_symbols)->__input_ArtFetch_inner) = __input_ArtFetch; \
((p_symbols)->playlist_AskForArtEnqueue_inner) = playlist_AskForArtEnqueue; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->vlc_input_item_GetInfo_deprecated = NULL; \
...
...
@@ -1561,6 +1553,10 @@ struct module_symbols_t
(p_symbols)->__intf_IntfProgress_deprecated = NULL; \
(p_symbols)->streaming_ChainToPsz_deprecated = NULL; \
(p_symbols)->__input_SecondaryPreparse_deprecated = NULL; \
(p_symbols)->__input_MetaFetch_deprecated = NULL; \
(p_symbols)->input_DownloadAndCacheArt_deprecated = NULL; \
(p_symbols)->input_GetMetaEngineFlags_deprecated = NULL; \
(p_symbols)->__input_ArtFetch_deprecated = NULL; \
(p_symbols)->input_AskForArt_deprecated = NULL; \
# endif
/* __PLUGIN__ */
...
...
src/input/meta.c
View file @
a0cbc6ed
...
...
@@ -32,48 +32,50 @@
# include <sys/stat.h>
#endif
int
input_FindArtInCache
(
vlc_object_t
*
p_paren
t
,
input_item_t
*
p_item
);
int
input_FindArtInCache
(
playlist_t
*
p_playlis
t
,
input_item_t
*
p_item
);
int
__input_MetaFetch
(
vlc_object_t
*
p_parent
,
input_item_t
*
p_item
)
vlc_bool_t
input_MetaSatisfied
(
playlist_t
*
p_playlist
,
input_item_t
*
p_item
,
uint32_t
*
pi_mandatory
,
uint32_t
*
pi_optional
,
vlc_bool_t
b_check_cache
)
{
// FIXME don't var_Stuff at each loop
int
i_policy
=
var_CreateGetInteger
(
p_playlist
,
"album-art"
);
if
(
b_check_cache
)
input_FindArtInCache
(
p_playlist
,
p_item
);
*
pi_mandatory
=
VLC_META_ENGINE_TITLE
|
VLC_META_ENGINE_ARTIST
|
(
i_policy
==
ALBUM_ART_ALL
?
VLC_META_ENGINE_ART_URL
:
0
);
uint32_t
i_meta
=
input_CurrentMetaFlags
(
p_item
->
p_meta
);
*
pi_mandatory
&=
~
i_meta
;
*
pi_optional
=
0
;
/// Todo
return
*
pi_mandatory
?
VLC_FALSE
:
VLC_TRUE
;
}
int
input_MetaFetch
(
playlist_t
*
p_playlist
,
input_item_t
*
p_item
)
{
struct
meta_engine_t
*
p_me
;
uint32_t
i_mandatory
=
0
,
i_optional
=
0
,
i_meta
;
int
i_policy
;
uint32_t
i_mandatory
,
i_optional
;
if
(
!
p_item
->
p_meta
)
return
VLC_EGENERIC
;
i_policy
=
var_CreateGetInteger
(
p_parent
,
"album-art"
);
i_mandatory
=
VLC_META_ENGINE_TITLE
|
VLC_META_ENGINE_ARTIST
;
if
(
i_policy
==
ALBUM_ART_ALL
)
{
i_mandatory
|=
VLC_META_ENGINE_ART_URL
;
}
else
{
i_optional
|=
VLC_META_ENGINE_ART_URL
;
}
input_FindArtInCache
(
p_parent
,
p_item
);
i_meta
=
input_GetMetaEngineFlags
(
p_item
->
p_meta
);
i_mandatory
&=
~
i_meta
;
i_optional
&=
~
i_meta
;
input_MetaSatisfied
(
p_playlist
,
p_item
,
&
i_mandatory
,
&
i_optional
,
VLC_FALSE
);
if
(
!
i_mandatory
)
return
VLC_SUCCESS
;
// Meta shouldn't magically appear
assert
(
i_mandatory
);
p_me
=
vlc_object_create
(
p_p
aren
t
,
VLC_OBJECT_META_ENGINE
);
p_me
=
vlc_object_create
(
p_p
laylis
t
,
VLC_OBJECT_META_ENGINE
);
p_me
->
i_flags
|=
OBJECT_FLAGS_NOINTERACT
;
p_me
->
i_mandatory
=
i_mandatory
;
p_me
->
i_optional
=
i_optional
;
p_me
->
p_item
=
p_item
;
p_me
->
p_module
=
module_Need
(
p_me
,
"meta fetcher"
,
0
,
VLC_FALSE
);
vlc_object_attach
(
p_me
,
p_p
aren
t
);
vlc_object_attach
(
p_me
,
p_p
laylis
t
);
if
(
!
p_me
->
p_module
)
{
msg_
Err
(
p_parent
,
"no suitable meta fetcher module
"
);
msg_
Dbg
(
p_playlist
,
"unable to fetch meta
"
);
vlc_object_detach
(
p_me
);
vlc_object_destroy
(
p_me
);
return
VLC_EGENERIC
;
...
...
@@ -87,27 +89,34 @@ int __input_MetaFetch( vlc_object_t *p_parent, input_item_t *p_item )
return
VLC_SUCCESS
;
}
int
__input_ArtFetch
(
vlc_object_t
*
p_paren
t
,
input_item_t
*
p_item
)
int
input_ArtFetch
(
playlist_t
*
p_playlis
t
,
input_item_t
*
p_item
)
{
if
(
!
p_item
->
p_meta
)
return
VLC_EGENERIC
;
/* TODO: call art fetcher modules */
if
(
!
p_item
->
p_meta
)
return
VLC_EGENERIC
;
if
(
!
p_item
->
p_meta
->
psz_arturl
||
!*
p_item
->
p_meta
->
psz_arturl
)
return
VLC_EGENERIC
;
if
(
strncmp
(
"file://"
,
p_item
->
p_meta
->
psz_arturl
,
7
)
)
{
return
input_DownloadAndCacheArt
(
p_parent
,
p_item
);
module_t
*
p_module
;
PL_LOCK
;
p_playlist
->
p_private
=
p_item
;
p_module
=
module_Need
(
p_playlist
,
"art finder"
,
0
,
VLC_FALSE
);
if
(
!
p_module
)
{
msg_Dbg
(
p_playlist
,
"unable to find art"
);
return
VLC_EGENERIC
;
}
module_Unneed
(
p_playlist
,
p_module
);
p_playlist
->
p_private
=
NULL
;
if
(
!
p_item
->
p_meta
->
psz_arturl
||
!*
p_item
->
p_meta
->
psz_arturl
)
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
return
input_DownloadAndCacheArt
(
p_playlist
,
p_item
)
;
}
#ifndef MAX_PATH
# define MAX_PATH 250
#endif
int
input_FindArtInCache
(
vlc_object_t
*
p_paren
t
,
input_item_t
*
p_item
)
int
input_FindArtInCache
(
playlist_t
*
p_playlis
t
,
input_item_t
*
p_item
)
{
char
*
psz_artist
;
char
*
psz_album
;
...
...
@@ -126,20 +135,19 @@ int input_FindArtInCache( vlc_object_t *p_parent, input_item_t *p_item )
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"%s"
DIR_SEP
"%s"
DIR_SEP
"art%s"
,
p_p
aren
t
->
p_libvlc
->
psz_homedir
,
p_p
laylis
t
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
,
ppsz_type
[
i
]
);
/* Check if file exists */
if
(
utf8_stat
(
psz_filename
+
7
,
&
a
)
==
0
)
{
msg_Dbg
(
p_p
aren
t
,
"album art %s already exists in cache"
msg_Dbg
(
p_p
laylis
t
,
"album art %s already exists in cache"
,
psz_filename
);
vlc_meta_SetArtURL
(
p_item
->
p_meta
,
psz_filename
);
return
VLC_SUCCESS
;
}
}
/* Use a art finder module to find the URL */
return
VLC_EGENERIC
;
}
...
...
@@ -147,7 +155,7 @@ int input_FindArtInCache( vlc_object_t *p_parent, input_item_t *p_item )
* Download the art using the URL or an art downloaded
* This function should be called only if data is not already in cache
*/
int
input_DownloadAndCacheArt
(
vlc_object_t
*
p_paren
t
,
input_item_t
*
p_item
)
int
input_DownloadAndCacheArt
(
playlist_t
*
p_playlis
t
,
input_item_t
*
p_item
)
{
int
i_status
=
VLC_EGENERIC
;
stream_t
*
p_stream
;
...
...
@@ -169,27 +177,27 @@ int input_DownloadAndCacheArt( vlc_object_t *p_parent, input_item_t *p_item )
snprintf
(
psz_filename
,
MAX_PATH
,
"file://%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"%s"
DIR_SEP
"%s"
DIR_SEP
"art%s"
,
p_p
aren
t
->
p_libvlc
->
psz_homedir
,
p_p
laylis
t
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
,
psz_type
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
,
p_p
aren
t
->
p_libvlc
->
psz_homedir
);
p_p
laylis
t
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
,
p_p
aren
t
->
p_libvlc
->
psz_homedir
);
p_p
laylis
t
->
p_libvlc
->
psz_homedir
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"%s"
,
p_p
aren
t
->
p_libvlc
->
psz_homedir
,
psz_artist
);
p_p
laylis
t
->
p_libvlc
->
psz_homedir
,
psz_artist
);
utf8_mkdir
(
psz_dir
);
snprintf
(
psz_dir
,
MAX_PATH
,
"%s"
DIR_SEP
CONFIG_DIR
DIR_SEP
"art"
DIR_SEP
"%s"
DIR_SEP
"%s"
,
p_p
aren
t
->
p_libvlc
->
psz_homedir
,
p_p
laylis
t
->
p_libvlc
->
psz_homedir
,
psz_artist
,
psz_album
);
utf8_mkdir
(
psz_dir
);
/* Todo: check for stuff that needs a downloader module */
p_stream
=
stream_UrlNew
(
p_p
aren
t
,
p_item
->
p_meta
->
psz_arturl
);
p_stream
=
stream_UrlNew
(
p_p
laylis
t
,
p_item
->
p_meta
->
psz_arturl
);
if
(
p_stream
)
{
...
...
@@ -203,7 +211,7 @@ int input_DownloadAndCacheArt( vlc_object_t *p_parent, input_item_t *p_item )
free
(
p_buffer
);
fclose
(
p_file
);
stream_Delete
(
p_stream
);
msg_Dbg
(
p_p
aren
t
,
"Album art saved to %s
\n
"
,
psz_filename
);
msg_Dbg
(
p_p
laylis
t
,
"Album art saved to %s
\n
"
,
psz_filename
);
free
(
p_item
->
p_meta
->
psz_arturl
);
p_item
->
p_meta
->
psz_arturl
=
strdup
(
psz_filename
);
i_status
=
VLC_SUCCESS
;
...
...
@@ -211,7 +219,7 @@ int input_DownloadAndCacheArt( vlc_object_t *p_parent, input_item_t *p_item )
return
i_status
;
}
uint32_t
input_
GetMetaEngine
Flags
(
vlc_meta_t
*
p_meta
)
uint32_t
input_
CurrentMeta
Flags
(
vlc_meta_t
*
p_meta
)
{
uint32_t
i_meta
=
0
;
...
...
src/playlist/engine.c
View file @
a0cbc6ed
...
...
@@ -447,6 +447,7 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
{
playlist_t
*
p_playlist
=
(
playlist_t
*
)
p_obj
->
p_parent
;
int
i_activity
;
uint32_t
i_m
,
i_o
;
vlc_mutex_lock
(
&
p_obj
->
object_lock
);
...
...
@@ -459,7 +460,6 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
if
(
p_current
)
{
vlc_bool_t
b_preparsed
=
VLC_FALSE
;
preparse_item_t
p
;
if
(
strncmp
(
p_current
->
psz_uri
,
"http:"
,
5
)
&&
strncmp
(
p_current
->
psz_uri
,
"rtsp:"
,
5
)
&&
strncmp
(
p_current
->
psz_uri
,
"udp:"
,
4
)
&&
...
...
@@ -484,17 +484,16 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
var_SetInteger
(
p_playlist
,
"item-change"
,
p_current
->
i_id
);
}
PL_LOCK
;
/*
W
e haven't retrieved enough meta, add to secondary queue
/*
If w
e haven't retrieved enough meta, add to secondary queue
* which will run the "meta fetchers"
* TODO: - use i_mandatory stuff here instead of hardcoded T/A
* - don't do this for things we won't get meta for, like
* videos
* -> done in input_MetaFetch atm
* TODO:
* don't do this for things we won't get meta for, like
* videos
*/
/*if( !(p_current->p_meta->psz_title && *p_current->p_meta->psz_title
&& p_current->p_meta->psz_artist &&
*p_current->p_meta->psz_artist) )
{*/
if
(
!
input_MetaSatisfied
(
p_playlist
,
p_current
,
&
i_m
,
&
i_o
,
VLC_TRUE
)
)
{
preparse_item_t
p
;
p
.
p_item
=
p_current
;
p
.
b_fetch_art
=
VLC_FALSE
;
vlc_mutex_lock
(
&
p_playlist
->
p_secondary_preparse
->
object_lock
);
...
...
@@ -504,9 +503,9 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
p
);
vlc_mutex_unlock
(
&
p_playlist
->
p_secondary_preparse
->
object_lock
);
/*
}
}
else
vlc_gc_decref( p_current );
*/
vlc_gc_decref
(
p_current
);
PL_UNLOCK
;
}
else
...
...
@@ -537,9 +536,12 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
vlc_mutex_unlock
(
&
p_obj
->
object_lock
);
if
(
p_item
)
{
input_MetaFetch
(
p_playlist
,
p_item
);
p_item
->
p_meta
->
i_status
|=
ITEM_META_FETCHED
;
if
(
b_fetch_art
==
VLC_TRUE
)
if
(
!
b_fetch_art
)
{
input_MetaFetch
(
p_playlist
,
p_item
);
p_item
->
p_meta
->
i_status
|=
ITEM_META_FETCHED
;
}
else
{
input_ArtFetch
(
p_playlist
,
p_item
);
p_item
->
p_meta
->
i_status
|=
ITEM_ART_FETCHED
;
...
...
@@ -547,8 +549,6 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
var_SetInteger
(
p_playlist
,
"item-change"
,
p_item
->
i_id
);
vlc_gc_decref
(
p_item
);
}
else
PL_UNLOCK
;
return
;
}
vlc_mutex_unlock
(
&
p_obj
->
object_lock
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment