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
277d5f98
Commit
277d5f98
authored
Jun 17, 2007
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle custom meta data in lua playlist scripts.
parent
d77ec471
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
51 deletions
+127
-51
modules/demux/playlist/luaplaylist.c
modules/demux/playlist/luaplaylist.c
+127
-51
No files found.
modules/demux/playlist/luaplaylist.c
View file @
277d5f98
...
...
@@ -429,6 +429,125 @@ void E_(Close_LuaPlaylist)( vlc_object_t *p_this )
free
(
p_demux
->
p_sys
);
}
static
inline
void
read_options
(
demux_t
*
p_demux
,
lua_State
*
p_state
,
int
o
,
int
t
,
int
*
pi_options
,
char
***
pppsz_options
)
{
lua_getfield
(
p_state
,
o
,
"options"
);
if
(
lua_istable
(
p_state
,
t
)
)
{
lua_pushnil
(
p_state
);
while
(
lua_next
(
p_state
,
t
)
)
{
if
(
lua_isstring
(
p_state
,
t
+
2
)
)
{
char
*
psz_option
=
strdup
(
lua_tostring
(
p_state
,
t
+
2
)
);
msg_Dbg
(
p_demux
,
"Option: %s"
,
psz_option
);
INSERT_ELEM
(
*
pppsz_options
,
*
pi_options
,
*
pi_options
,
psz_option
);
}
else
{
msg_Warn
(
p_demux
,
"Option should be a string"
);
}
lua_pop
(
p_state
,
1
);
/* pop option */
}
}
lua_pop
(
p_state
,
1
);
/* pop "options" */
}
static
inline
void
read_meta_data
(
demux_t
*
p_demux
,
lua_State
*
p_state
,
int
o
,
int
t
,
input_item_t
*
p_input
)
{
const
char
*
psz_value
;
#define TRY_META( a, b ) \
lua_getfield( p_state, o, a ); \
if( lua_isstring( p_state, t ) ) \
{ \
psz_value = lua_tostring( p_state, t ); \
msg_Dbg( p_demux, #b ": %s", psz_value ); \
vlc_meta_Set ## b ( p_input->p_meta, psz_value ); \
} \
lua_pop( p_state, 1 );
/* pop a */
TRY_META
(
"title"
,
Title
);
TRY_META
(
"artist"
,
Artist
);
TRY_META
(
"genre"
,
Genre
);
TRY_META
(
"copyright"
,
Copyright
);
TRY_META
(
"album"
,
Album
);
TRY_META
(
"tracknum"
,
Tracknum
);
TRY_META
(
"description"
,
Description
);
TRY_META
(
"rating"
,
Rating
);
TRY_META
(
"date"
,
Date
);
TRY_META
(
"setting"
,
Setting
);
TRY_META
(
"url"
,
URL
);
TRY_META
(
"language"
,
Language
);
TRY_META
(
"nowplaying"
,
NowPlaying
);
TRY_META
(
"publisher"
,
Publisher
);
TRY_META
(
"encodedby"
,
EncodedBy
);
TRY_META
(
"arturl"
,
ArtURL
);
TRY_META
(
"trackid"
,
TrackID
);
}
static
inline
void
read_custom_meta_data
(
demux_t
*
p_demux
,
lua_State
*
p_state
,
int
o
,
int
t
,
input_item_t
*
p_input
)
{
lua_getfield
(
p_state
,
o
,
"meta"
);
if
(
lua_istable
(
p_state
,
t
)
)
{
lua_pushnil
(
p_state
);
while
(
lua_next
(
p_state
,
t
)
)
{
if
(
!
lua_isstring
(
p_state
,
t
+
1
)
)
{
msg_Warn
(
p_demux
,
"Custom meta data category name must be "
"a string"
);
}
else
if
(
!
lua_istable
(
p_state
,
t
+
2
)
)
{
msg_Warn
(
p_demux
,
"Custom meta data category contents "
"must be a table"
);
}
else
{
const
char
*
psz_meta_category
=
lua_tostring
(
p_state
,
t
+
1
);
msg_Dbg
(
p_demux
,
"Found custom meta data category: %s"
,
psz_meta_category
);
lua_pushnil
(
p_state
);
while
(
lua_next
(
p_state
,
t
+
2
)
)
{
if
(
!
lua_isstring
(
p_state
,
t
+
3
)
)
{
msg_Warn
(
p_demux
,
"Custom meta category item name "
"must be a string."
);
}
else
if
(
!
lua_isstring
(
p_state
,
t
+
4
)
)
{
msg_Warn
(
p_demux
,
"Custom meta category item value "
"must be a string."
);
}
else
{
const
char
*
psz_meta_name
=
lua_tostring
(
p_state
,
t
+
3
);
const
char
*
psz_meta_value
=
lua_tostring
(
p_state
,
t
+
4
);
msg_Dbg
(
p_demux
,
"Custom meta %s, %s: %s"
,
psz_meta_category
,
psz_meta_name
,
psz_meta_value
);
input_ItemAddInfo
(
p_input
,
psz_meta_category
,
psz_meta_name
,
psz_meta_value
);
}
lua_pop
(
p_state
,
1
);
/* pop item */
}
}
lua_pop
(
p_state
,
1
);
/* pop category */
}
}
lua_pop
(
p_state
,
1
);
/* pop "meta" */
}
static
int
Demux
(
demux_t
*
p_demux
)
{
input_item_t
*
p_input
;
...
...
@@ -461,7 +580,7 @@ static int Demux( demux_t *p_demux )
/* Check that the Lua stack is big enough and grow it if needed.
* Should be ok since LUA_MINSTACK is 20 but we never know. */
lua_checkstack
(
p_state
,
7
);
lua_checkstack
(
p_state
,
8
);
if
(
(
t
=
lua_gettop
(
p_state
)
)
)
{
...
...
@@ -506,30 +625,8 @@ static int Demux( demux_t *p_demux )
lua_pop
(
p_state
,
1
);
/* pop "duration" */
/* Read options */
lua_getfield
(
p_state
,
t
+
2
,
"options"
);
if
(
lua_istable
(
p_state
,
t
+
5
)
)
{
lua_pushnil
(
p_state
);
while
(
lua_next
(
p_state
,
t
+
5
)
)
{
if
(
lua_isstring
(
p_state
,
t
+
7
)
)
{
char
*
psz_option
=
strdup
(
lua_tostring
(
p_state
,
t
+
7
)
);
msg_Dbg
(
p_demux
,
"Option: %s"
,
psz_option
);
INSERT_ELEM
(
ppsz_options
,
i_options
,
i_options
,
psz_option
);
}
else
{
msg_Warn
(
p_demux
,
"Option should be a string"
);
}
lua_pop
(
p_state
,
1
);
/* pop option */
}
}
lua_pop
(
p_state
,
1
);
/* pop "options" */
read_options
(
p_demux
,
p_state
,
t
+
2
,
t
+
5
,
&
i_options
,
&
ppsz_options
);
/* Create input item */
p_input
=
input_ItemNewExt
(
p_playlist
,
psz_path
,
...
...
@@ -540,32 +637,11 @@ static int Demux( demux_t *p_demux )
/* Read meta data */
p_input
->
p_meta
=
vlc_meta_New
();
#define TRY_META( a, b ) \
lua_getfield( p_state, t+2, a ); \
if( lua_isstring( p_state, t+4 ) ) \
{ \
psz_name = lua_tostring( p_state, t+4 ); \
msg_Dbg( p_demux, #b ": %s", psz_name ); \
vlc_meta_Set ## b ( p_input->p_meta, psz_name ); \
} \
lua_pop( p_state, 1 );
/* pop a */
TRY_META
(
"title"
,
Title
);
TRY_META
(
"artist"
,
Artist
);
TRY_META
(
"genre"
,
Genre
);
TRY_META
(
"copyright"
,
Copyright
);
TRY_META
(
"album"
,
Album
);
TRY_META
(
"tracknum"
,
Tracknum
);
TRY_META
(
"description"
,
Description
);
TRY_META
(
"rating"
,
Rating
);
TRY_META
(
"date"
,
Date
);
TRY_META
(
"setting"
,
Setting
);
TRY_META
(
"url"
,
URL
);
TRY_META
(
"language"
,
Language
);
TRY_META
(
"nowplaying"
,
NowPlaying
);
TRY_META
(
"publisher"
,
Publisher
);
TRY_META
(
"encodedby"
,
EncodedBy
);
TRY_META
(
"arturl"
,
ArtURL
);
TRY_META
(
"trackid"
,
TrackID
);
read_meta_data
(
p_demux
,
p_state
,
t
+
2
,
t
+
4
,
p_input
);
/* Read custom meta data */
read_custom_meta_data
(
p_demux
,
p_state
,
t
+
2
,
t
+
4
,
p_input
);
/* Append item to playlist */
playlist_BothAddInput
(
...
...
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