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
48786ae5
Commit
48786ae5
authored
Aug 31, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stream: provide a common implementation of stream_Tell()
parent
79b36fbb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
include/vlc_stream.h
include/vlc_stream.h
+7
-12
src/input/stream.c
src/input/stream.c
+18
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
No files found.
include/vlc_stream.h
View file @
48786ae5
...
@@ -142,6 +142,13 @@ VLC_API ssize_t stream_Read(stream_t *, void *, size_t) VLC_USED;
...
@@ -142,6 +142,13 @@ VLC_API ssize_t stream_Read(stream_t *, void *, size_t) VLC_USED;
*/
*/
VLC_API
ssize_t
stream_Peek
(
stream_t
*
,
const
uint8_t
**
,
size_t
)
VLC_USED
;
VLC_API
ssize_t
stream_Peek
(
stream_t
*
,
const
uint8_t
**
,
size_t
)
VLC_USED
;
/**
* Tells the current stream position.
*
* @return the byte offset from the beginning of the stream (cannot fail)
*/
VLC_API
uint64_t
stream_Tell
(
const
stream_t
*
)
VLC_USED
;
VLC_API
int
stream_vaControl
(
stream_t
*
s
,
int
i_query
,
va_list
args
);
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
,
...
);
...
@@ -149,18 +156,6 @@ VLC_API block_t * stream_Block( stream_t *s, size_t );
...
@@ -149,18 +156,6 @@ VLC_API block_t * stream_Block( stream_t *s, size_t );
VLC_API
char
*
stream_ReadLine
(
stream_t
*
);
VLC_API
char
*
stream_ReadLine
(
stream_t
*
);
VLC_API
input_item_t
*
stream_ReadDir
(
stream_t
*
);
VLC_API
input_item_t
*
stream_ReadDir
(
stream_t
*
);
/**
* Get the current position in a stream
*/
static
inline
int64_t
stream_Tell
(
stream_t
*
s
)
{
uint64_t
i_pos
;
stream_Control
(
s
,
STREAM_GET_POSITION
,
&
i_pos
);
if
(
i_pos
>>
62
)
return
(
int64_t
)
1
<<
62
;
return
i_pos
;
}
/**
/**
* Get the size of the stream.
* Get the size of the stream.
*/
*/
...
...
src/input/stream.c
View file @
48786ae5
...
@@ -45,6 +45,7 @@ typedef struct stream_priv_t
...
@@ -45,6 +45,7 @@ typedef struct stream_priv_t
{
{
stream_t
stream
;
stream_t
stream
;
block_t
*
peek
;
block_t
*
peek
;
uint64_t
offset
;
/* UTF-16 and UTF-32 file reading */
/* UTF-16 and UTF-32 file reading */
struct
{
struct
{
...
@@ -75,6 +76,7 @@ stream_t *stream_CommonNew(vlc_object_t *parent)
...
@@ -75,6 +76,7 @@ stream_t *stream_CommonNew(vlc_object_t *parent)
s
->
pf_destroy
=
NULL
;
s
->
pf_destroy
=
NULL
;
s
->
p_input
=
NULL
;
s
->
p_input
=
NULL
;
priv
->
peek
=
NULL
;
priv
->
peek
=
NULL
;
priv
->
offset
=
0
;
/* UTF16 and UTF32 text file conversion */
/* UTF16 and UTF32 text file conversion */
priv
->
text
.
conv
=
(
vlc_iconv_t
)(
-
1
);
priv
->
text
.
conv
=
(
vlc_iconv_t
)(
-
1
);
...
@@ -313,6 +315,7 @@ error:
...
@@ -313,6 +315,7 @@ error:
static
ssize_t
stream_ReadRaw
(
stream_t
*
s
,
void
*
buf
,
size_t
len
)
static
ssize_t
stream_ReadRaw
(
stream_t
*
s
,
void
*
buf
,
size_t
len
)
{
{
stream_priv_t
*
priv
=
(
stream_priv_t
*
)
s
;
size_t
copy
=
0
;
size_t
copy
=
0
;
ssize_t
ret
=
0
;
ssize_t
ret
=
0
;
...
@@ -333,6 +336,7 @@ static ssize_t stream_ReadRaw(stream_t *s, void *buf, size_t len)
...
@@ -333,6 +336,7 @@ static ssize_t stream_ReadRaw(stream_t *s, void *buf, size_t len)
buf
=
(
unsigned
char
*
)
buf
+
ret
;
buf
=
(
unsigned
char
*
)
buf
+
ret
;
len
-=
ret
;
len
-=
ret
;
copy
+=
ret
;
copy
+=
ret
;
priv
->
offset
+=
ret
;
}
}
return
(
copy
>
0
)
?
(
ssize_t
)
copy
:
ret
;
return
(
copy
>
0
)
?
(
ssize_t
)
copy
:
ret
;
...
@@ -430,6 +434,20 @@ ssize_t stream_Peek(stream_t *s, const uint8_t **restrict bufp, size_t len)
...
@@ -430,6 +434,20 @@ ssize_t stream_Peek(stream_t *s, const uint8_t **restrict bufp, size_t len)
return
len
;
return
len
;
}
}
uint64_t
stream_Tell
(
const
stream_t
*
s
)
{
const
stream_priv_t
*
priv
=
(
const
stream_priv_t
*
)
s
;
uint64_t
pos
=
priv
->
offset
;
if
(
priv
->
peek
!=
NULL
)
{
assert
(
pos
>=
priv
->
peek
->
i_buffer
);
pos
-=
priv
->
peek
->
i_buffer
;
}
return
pos
;
}
static
int
stream_ControlInternal
(
stream_t
*
s
,
int
cmd
,
...)
static
int
stream_ControlInternal
(
stream_t
*
s
,
int
cmd
,
...)
{
{
va_list
ap
;
va_list
ap
;
...
...
src/libvlccore.sym
View file @
48786ae5
...
@@ -403,6 +403,7 @@ stream_MemoryNew
...
@@ -403,6 +403,7 @@ stream_MemoryNew
stream_Peek
stream_Peek
stream_Read
stream_Read
stream_ReadLine
stream_ReadLine
stream_Tell
stream_UrlNew
stream_UrlNew
stream_vaControl
stream_vaControl
stream_ReadDir
stream_ReadDir
...
...
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