Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
8fa822f7
Commit
8fa822f7
authored
May 30, 2012
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flag some input_item with uid to speed up cached elements based on lua retrievals
parent
ac5631c7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
2 deletions
+109
-2
modules/lua/libs/sd.c
modules/lua/libs/sd.c
+22
-0
share/lua/sd/icecast.lua
share/lua/sd/icecast.lua
+2
-0
src/playlist/art.c
src/playlist/art.c
+80
-1
src/playlist/art.h
src/playlist/art.h
+1
-0
src/playlist/fetcher.c
src/playlist/fetcher.c
+4
-1
No files found.
modules/lua/libs/sd.c
View file @
8fa822f7
...
...
@@ -37,6 +37,7 @@
#include <vlc_services_discovery.h>
#include <vlc_playlist.h>
#include <vlc_charset.h>
#include <vlc_md5.h>
#include "../vlc.h"
#include "../libs.h"
...
...
@@ -256,6 +257,27 @@ static int vlclua_sd_add_item( lua_State *L )
else
services_discovery_AddItem
(
p_sd
,
p_input
,
NULL
);
lua_pop
(
L
,
1
);
/* string to build the input item uid */
lua_getfield
(
L
,
-
1
,
"uiddata"
);
if
(
lua_isstring
(
L
,
-
1
)
)
{
char
*
s
=
strdup
(
luaL_checkstring
(
L
,
-
1
)
);
if
(
s
)
{
struct
md5_s
md5
;
InitMD5
(
&
md5
);
AddMD5
(
&
md5
,
s
,
strlen
(
s
)
);
EndMD5
(
&
md5
);
free
(
s
);
s
=
psz_md5_hash
(
&
md5
);
if
(
s
)
input_item_AddInfo
(
p_input
,
"uid"
,
"md5"
,
"%s"
,
s
);
free
(
s
);
}
}
lua_pop
(
L
,
1
);
input_item_t
**
udata
=
(
input_item_t
**
)
lua_newuserdata
(
L
,
sizeof
(
input_item_t
*
)
);
*
udata
=
p_input
;
...
...
share/lua/sd/icecast.lua
View file @
8fa822f7
...
...
@@ -43,6 +43,8 @@ function main()
title
=
station_name
,
genre
=
station
.
children_map
[
"genre"
][
1
].
children
[
1
],
nowplaying
=
station
.
children_map
[
"current_song"
][
1
].
children
[
1
],
uiddata
=
station
.
children_map
[
"listen_url"
][
1
].
children
[
1
]
..
station
.
children_map
[
"listen_url"
][
1
].
children
[
1
],
meta
=
{
[
"Listing Source"
]
=
"dir.xiph.org"
,
[
"Icecast Bitrate"
]
=
station
.
children_map
[
"bitrate"
][
1
].
children
[
1
],
...
...
src/playlist/art.c
View file @
8fa822f7
...
...
@@ -204,6 +204,61 @@ int playlist_FindArtInCache( input_item_t *p_item )
return
b_found
?
VLC_SUCCESS
:
VLC_EGENERIC
;
}
static
char
*
GetDirByItemUIDs
(
char
*
psz_uid
)
{
char
*
psz_cachedir
=
config_GetUserDir
(
VLC_CACHE_DIR
);
char
*
psz_dir
;
if
(
asprintf
(
&
psz_dir
,
"%s"
DIR_SEP
"by-iiuid"
DIR_SEP
"%s"
,
psz_cachedir
,
psz_uid
)
==
-
1
)
{
psz_dir
=
NULL
;
}
free
(
psz_cachedir
);
return
psz_dir
;
}
static
char
*
GetFileByItemUID
(
char
*
psz_dir
,
const
char
*
psz_type
)
{
char
*
psz_file
;
if
(
asprintf
(
&
psz_file
,
"%s"
DIR_SEP
"%s"
,
psz_dir
,
psz_type
)
==
-
1
)
{
psz_file
=
NULL
;
}
return
psz_file
;
}
int
playlist_FindArtInCacheUsingItemUID
(
input_item_t
*
p_item
)
{
char
*
uid
=
input_item_GetInfo
(
p_item
,
"uid"
,
"md5"
);
if
(
!
uid
)
return
VLC_EGENERIC
;
/* we have an input item uid set */
bool
b_done
=
false
;
char
*
psz_byuiddir
=
GetDirByItemUIDs
(
uid
);
char
*
psz_byuidfile
=
GetFileByItemUID
(
psz_byuiddir
,
"arturl"
);
free
(
psz_byuiddir
);
if
(
psz_byuidfile
)
{
FILE
*
fd
=
vlc_fopen
(
psz_byuidfile
,
"rb"
);
if
(
fd
)
{
char
sz_cachefile
[
2049
];
/* read the cache hash url */
if
(
fgets
(
sz_cachefile
,
2048
,
fd
)
!=
NULL
)
{
input_item_SetArtURL
(
p_item
,
sz_cachefile
);
b_done
=
true
;
}
fclose
(
fd
);
}
free
(
psz_byuidfile
);
}
free
(
uid
);
if
(
b_done
)
return
VLC_SUCCESS
;
return
VLC_EGENERIC
;
}
/* */
int
playlist_SaveArt
(
playlist_t
*
p_playlist
,
input_item_t
*
p_item
,
...
...
@@ -246,8 +301,32 @@ int playlist_SaveArt( playlist_t *p_playlist, input_item_t *p_item,
}
fclose
(
f
);
}
free
(
psz_filename
);
free
(
psz_uri
);
/* save uid info */
char
*
uid
=
input_item_GetInfo
(
p_item
,
"uid"
,
"md5"
);
if
(
!
uid
)
goto
end
;
char
*
psz_byuiddir
=
GetDirByItemUIDs
(
uid
);
char
*
psz_byuidfile
=
GetFileByItemUID
(
psz_byuiddir
,
"arturl"
);
ArtCacheCreateDir
(
psz_byuiddir
);
free
(
psz_byuiddir
);
if
(
psz_byuidfile
)
{
f
=
vlc_fopen
(
psz_byuidfile
,
"wb"
);
if
(
f
)
{
if
(
fputs
(
"file://"
,
f
)
<
0
||
fputs
(
psz_filename
,
f
)
<
0
)
msg_Err
(
p_playlist
,
"Error writing %s: %m"
,
psz_byuidfile
);
fclose
(
f
);
}
free
(
psz_byuidfile
);
}
free
(
uid
);
/* !save uid info */
end:
free
(
psz_filename
);
return
VLC_SUCCESS
;
}
src/playlist/art.h
View file @
8fa822f7
...
...
@@ -35,6 +35,7 @@ typedef struct
}
playlist_album_t
;
int
playlist_FindArtInCache
(
input_item_t
*
);
int
playlist_FindArtInCacheUsingItemUID
(
input_item_t
*
);
int
playlist_SaveArt
(
playlist_t
*
,
input_item_t
*
,
const
uint8_t
*
p_buffer
,
int
i_buffer
,
const
char
*
psz_type
);
...
...
src/playlist/fetcher.c
View file @
8fa822f7
...
...
@@ -177,7 +177,10 @@ static int FindArt( playlist_fetcher_t *p_fetcher, input_item_t *p_item )
free
(
psz_artist
);
free
(
psz_album
);
playlist_FindArtInCache
(
p_item
);
if
(
playlist_FindArtInCacheUsingItemUID
(
p_item
)
!=
VLC_SUCCESS
)
playlist_FindArtInCache
(
p_item
);
else
msg_Dbg
(
p_fetcher
->
p_playlist
,
"successfully retrieved arturl by uid"
);
char
*
psz_arturl
=
input_item_GetArtURL
(
p_item
);
if
(
psz_arturl
)
...
...
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