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
63af7c78
Commit
63af7c78
authored
Jan 07, 2012
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added stream_BlockRemaining() helper.
It is usefull to load a whole file to memory.
parent
ea6be118
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
include/vlc_stream.h
include/vlc_stream.h
+1
-0
src/input/stream.c
src/input/stream.c
+45
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
No files found.
include/vlc_stream.h
View file @
63af7c78
...
@@ -119,6 +119,7 @@ VLC_API int stream_vaControl( stream_t *s, int i_query, va_list args );
...
@@ -119,6 +119,7 @@ VLC_API int stream_vaControl( stream_t *s, int i_query, va_list args );
VLC_API
void
stream_Delete
(
stream_t
*
s
);
VLC_API
void
stream_Delete
(
stream_t
*
s
);
VLC_API
int
stream_Control
(
stream_t
*
s
,
int
i_query
,
...
);
VLC_API
int
stream_Control
(
stream_t
*
s
,
int
i_query
,
...
);
VLC_API
block_t
*
stream_Block
(
stream_t
*
s
,
int
i_size
);
VLC_API
block_t
*
stream_Block
(
stream_t
*
s
,
int
i_size
);
VLC_API
block_t
*
stream_BlockRemaining
(
stream_t
*
s
,
int
i_max_size
);
VLC_API
char
*
stream_ReadLine
(
stream_t
*
);
VLC_API
char
*
stream_ReadLine
(
stream_t
*
);
/**
/**
...
...
src/input/stream.c
View file @
63af7c78
...
@@ -1942,3 +1942,48 @@ block_t *stream_Block( stream_t *s, int i_size )
...
@@ -1942,3 +1942,48 @@ block_t *stream_Block( stream_t *s, int i_size )
}
}
return
NULL
;
return
NULL
;
}
}
/**
* Read the remaining of the data if there is less than i_max_size bytes, otherwise
* return NULL.
*
* The stream position is unknown after the call.
*/
block_t
*
stream_BlockRemaining
(
stream_t
*
s
,
int
i_max_size
)
{
int
i_allocate
=
__MIN
(
1000000
,
i_max_size
);
int64_t
i_size
=
stream_Size
(
s
);
if
(
i_size
>
0
)
{
int64_t
i_position
=
stream_Tell
(
s
);
if
(
i_position
+
i_max_size
<
i_size
)
{
msg_Err
(
s
,
"Remaining stream size is greater than %d bytes"
,
i_max_size
);
return
NULL
;
}
i_allocate
=
i_size
-
i_position
;
}
if
(
i_allocate
<=
0
)
return
NULL
;
block_t
*
p_block
=
block_New
(
s
,
i_allocate
);
int
i_index
=
0
;
while
(
p_block
)
{
int
i_read
=
stream_Read
(
s
,
&
p_block
->
p_buffer
[
i_index
],
p_block
->
i_buffer
-
i_index
);
if
(
i_read
<=
0
)
break
;
i_index
+=
i_read
;
i_max_size
-=
i_read
;
if
(
i_max_size
<=
0
)
break
;
p_block
=
block_Realloc
(
p_block
,
0
,
p_block
->
i_buffer
+
__MIN
(
1000000
,
i_max_size
)
);
}
if
(
p_block
)
p_block
->
i_buffer
=
i_index
;
return
p_block
;
}
src/libvlccore.sym
View file @
63af7c78
...
@@ -405,6 +405,7 @@ spu_ClearChannel
...
@@ -405,6 +405,7 @@ spu_ClearChannel
sql_Create
sql_Create
sql_Destroy
sql_Destroy
stream_Block
stream_Block
stream_BlockRemaining
stream_Control
stream_Control
stream_Delete
stream_Delete
stream_DemuxNew
stream_DemuxNew
...
...
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