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
3c12dc17
Commit
3c12dc17
authored
Nov 02, 2010
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua_sd: Implement the descriptor request.
parent
8d9c9164
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
4 deletions
+85
-4
modules/misc/lua/services_discovery.c
modules/misc/lua/services_discovery.c
+85
-4
No files found.
modules/misc/lua/services_discovery.c
View file @
3c12dc17
...
...
@@ -34,8 +34,9 @@
* Local prototypes
*****************************************************************************/
static
void
*
Run
(
void
*
);
static
int
DoSearch
(
services_discovery_t
*
p_sd
,
const
char
*
psz_query
);
static
int
Control
(
services_discovery_t
*
p_sd
,
int
i_command
,
va_list
args
);
static
int
DoSearch
(
services_discovery_t
*
p_sd
,
const
char
*
psz_query
);
static
int
FillDescriptor
(
services_discovery_t
*
,
services_discovery_descriptor_t
*
);
static
int
Control
(
services_discovery_t
*
p_sd
,
int
i_command
,
va_list
args
);
static
const
char
*
const
ppsz_sd_options
[]
=
{
"sd"
,
"longname"
,
NULL
};
...
...
@@ -263,8 +264,12 @@ static int Control( services_discovery_t *p_sd, int i_command, va_list args )
break
;
}
case
SD_CMD_CAPABILITIES
:
return
VLC_EGENERIC
;
case
SD_CMD_DESCRIPTOR
:
{
services_discovery_descriptor_t
*
p_desc
=
va_arg
(
args
,
services_discovery_descriptor_t
*
);
return
FillDescriptor
(
p_sd
,
p_desc
);
}
}
return
VLC_SUCCESS
;
...
...
@@ -299,3 +304,79 @@ static int DoSearch( services_discovery_t *p_sd, const char *psz_query )
return
VLC_SUCCESS
;
}
/** List of capabilities */
static
const
char
*
const
ppsz_capabilities
[]
=
{
"search"
,
NULL
};
static
int
FillDescriptor
(
services_discovery_t
*
p_sd
,
services_discovery_descriptor_t
*
p_desc
)
{
services_discovery_sys_t
*
p_sys
=
p_sd
->
p_sys
;
int
i_ret
=
VLC_EGENERIC
;
lua_State
*
L
=
luaL_newstate
();
if
(
luaL_dofile
(
L
,
p_sys
->
psz_filename
)
)
{
msg_Err
(
p_sd
,
"Error loading script %s: %s"
,
p_sys
->
psz_filename
,
lua_tostring
(
L
,
-
1
)
);
goto
end
;
}
/* Call the "descriptor" function */
lua_getglobal
(
L
,
"descriptor"
);
if
(
!
lua_isfunction
(
L
,
-
1
)
||
lua_pcall
(
L
,
0
,
1
,
0
)
)
{
msg_Warn
(
p_sd
,
"Error getting the descriptor in '%s': %s"
,
p_sys
->
psz_filename
,
lua_tostring
(
L
,
-
1
)
);
goto
end
;
}
/* Get the different fields of the returned table */
lua_getfield
(
L
,
-
1
,
"short_description"
);
p_desc
->
psz_short_desc
=
luaL_strdupornull
(
L
,
-
1
);
lua_pop
(
L
,
1
);
lua_getfield
(
L
,
-
1
,
"icon"
);
p_desc
->
psz_icon_url
=
luaL_strdupornull
(
L
,
-
1
);
lua_pop
(
L
,
1
);
lua_getfield
(
L
,
-
1
,
"url"
);
p_desc
->
psz_url
=
luaL_strdupornull
(
L
,
-
1
);
lua_pop
(
L
,
1
);
lua_getfield
(
L
,
-
1
,
"capabilities"
);
p_desc
->
i_capabilities
=
0
;
if
(
lua_istable
(
L
,
-
1
)
)
{
lua_pushnil
(
L
);
while
(
lua_next
(
L
,
-
2
)
!=
0
)
{
/* Key is at index -2 and value at index -1 */
const
char
*
psz_cap
=
luaL_checkstring
(
L
,
-
1
);
int
i_cap
=
0
;
const
char
*
psz_iter
;
for
(
psz_iter
=
*
ppsz_capabilities
;
psz_iter
;
psz_iter
=
ppsz_capabilities
[
++
i_cap
]
)
{
if
(
!
strcmp
(
psz_iter
,
psz_cap
)
)
{
p_desc
->
i_capabilities
|=
1
<<
i_cap
;
break
;
}
}
if
(
!
psz_iter
)
msg_Warn
(
p_sd
,
"Services discovery capability '%s' unknown in "
"script '%s'"
,
psz_cap
,
p_sys
->
psz_filename
);
}
}
lua_pop
(
L
,
1
);
i_ret
=
VLC_SUCCESS
;
end:
lua_close
(
L
);
return
i_ret
;
}
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