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
9794aa06
Commit
9794aa06
authored
Feb 13, 2010
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lua wrapper for memory stream constructor.
parent
456b635e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
modules/misc/lua/libs/stream.c
modules/misc/lua/libs/stream.c
+21
-7
No files found.
modules/misc/lua/libs/stream.c
View file @
9794aa06
...
@@ -59,15 +59,10 @@ static const luaL_Reg vlclua_stream_reg[] = {
...
@@ -59,15 +59,10 @@ static const luaL_Reg vlclua_stream_reg[] = {
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
int
vlclua_stream_new
(
lua_State
*
L
)
static
int
vlclua_stream_new
_inner
(
lua_State
*
L
,
stream_t
*
p_stream
)
{
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
stream_t
*
p_stream
;
const
char
*
psz_url
;
psz_url
=
luaL_checkstring
(
L
,
1
);
p_stream
=
stream_UrlNew
(
p_this
,
psz_url
);
if
(
!
p_stream
)
if
(
!
p_stream
)
return
luaL_error
(
L
,
"Error when opening
url: `%s'"
,
psz_url
);
return
luaL_error
(
L
,
"Error when opening
stream"
);
stream_t
**
pp_stream
=
lua_newuserdata
(
L
,
sizeof
(
stream_t
*
)
);
stream_t
**
pp_stream
=
lua_newuserdata
(
L
,
sizeof
(
stream_t
*
)
);
*
pp_stream
=
p_stream
;
*
pp_stream
=
p_stream
;
...
@@ -85,6 +80,23 @@ static int vlclua_stream_new( lua_State *L )
...
@@ -85,6 +80,23 @@ static int vlclua_stream_new( lua_State *L )
return
1
;
return
1
;
}
}
static
int
vlclua_stream_new
(
lua_State
*
L
)
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
const
char
*
psz_url
=
luaL_checkstring
(
L
,
1
);
stream_t
*
p_stream
=
stream_UrlNew
(
p_this
,
psz_url
);
return
vlclua_stream_new_inner
(
L
,
p_stream
);
}
static
int
vlclua_memory_stream_new
(
lua_State
*
L
)
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
/* FIXME: duplicating the whole buffer is suboptimal. Keeping a reference to the string so that it doesn't get garbage collected would be better */
const
char
*
psz_content
=
strdup
(
luaL_checkstring
(
L
,
1
)
);
stream_t
*
p_stream
=
stream_MemoryNew
(
p_this
,
psz_content
,
strlen
(
psz_content
),
false
);
return
vlclua_stream_new_inner
(
L
,
p_stream
);
}
static
int
vlclua_stream_read
(
lua_State
*
L
)
static
int
vlclua_stream_read
(
lua_State
*
L
)
{
{
int
i_read
;
int
i_read
;
...
@@ -176,4 +188,6 @@ void luaopen_stream( lua_State *L )
...
@@ -176,4 +188,6 @@ void luaopen_stream( lua_State *L )
{
{
lua_pushcfunction
(
L
,
vlclua_stream_new
);
lua_pushcfunction
(
L
,
vlclua_stream_new
);
lua_setfield
(
L
,
-
2
,
"stream"
);
lua_setfield
(
L
,
-
2
,
"stream"
);
lua_pushcfunction
(
L
,
vlclua_memory_stream_new
);
lua_setfield
(
L
,
-
2
,
"memory_stream"
);
}
}
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