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
3660164b
Commit
3660164b
authored
Jul 22, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
access: add vlc_access_NewMRL() and vlc_access_Delete() helpers
parent
1a923e14
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
0 deletions
+120
-0
include/vlc_access.h
include/vlc_access.h
+97
-0
src/input/access.c
src/input/access.c
+21
-0
src/libvlccore.sym
src/libvlccore.sym
+2
-0
No files found.
include/vlc_access.h
View file @
3660164b
...
@@ -124,6 +124,103 @@ struct access_t
...
@@ -124,6 +124,103 @@ struct access_t
input_thread_t
*
p_input
;
input_thread_t
*
p_input
;
};
};
/**
* Opens a new read-only byte stream.
*
* This function might block.
* The initial offset is of course always zero.
*
* \param obj parent VLC object
* \param mrl media resource location to read
* \return a new access object on success, NULL on failure
*/
VLC_API
access_t
*
vlc_access_NewMRL
(
vlc_object_t
*
obj
,
const
char
*
mrl
);
/**
* Closes a byte stream.
* \param access byte stream to close
*/
VLC_API
void
vlc_access_Delete
(
access_t
*
access
);
/**
* Sets the read byte offset.
*/
static
inline
int
vlc_access_Seek
(
access_t
*
access
,
uint64_t
offset
)
{
if
(
access
->
pf_seek
==
NULL
)
return
VLC_EGENERIC
;
return
access
->
pf_seek
(
access
,
offset
);
}
/**
* Gets the read byte offset.
*/
static
inline
uint64_t
vlc_access_Tell
(
const
access_t
*
access
)
{
return
access
->
info
.
i_pos
;
}
/**
* Checks if end-of-stream is reached.
*/
static
inline
bool
vlc_access_Eof
(
const
access_t
*
access
)
{
return
access
->
info
.
b_eof
;
}
/**
* Reads a byte stream.
*
* This function waits for some data to be available (if necessary) and returns
* available data (up to the requested size). Not all byte streams support
* this. Some streams must be read with vlc_access_Block() instead.
*
* \note
* A short read does <b>not</b> imply the end of the stream. It merely implies
* that enough data is not immediately available.
* To detect the end of the stream, either check if the function returns zero,
* or call vlc_access_Eof().
*
* \note
* The function may return a negative value spuriously. Negative error values
* should be ignored; they do not necessarily indicate a fatal error.
*
* \param buf buffer to read data into
* \param len size of the buffer in bytes
* \return the number of bytes read (possibly less than requested),
* zero at end-of-stream, or -1 on <b>transient</b> errors
*/
static
inline
ssize_t
vlc_access_Read
(
access_t
*
access
,
void
*
buf
,
size_t
len
)
{
if
(
access
->
pf_read
==
NULL
)
return
-
1
;
return
access
->
pf_read
(
access
,
(
unsigned
char
*
)
buf
,
len
);
}
/**
* Dequeues one block of data.
*
* This function waits for a block of data to be available (if necessary) and
* returns a reference to it. Not all byte streams support this. Some streams
* must be read with vlc_access_Read() instead.
*
* \note
* The returned block may be of any size. The size is dependent on the
* underlying implementation of the byte stream.
*
* \note
* The function may return NULL spuriously. A NULL return is not indicative of
* a fatal error.
*
* \return a data block (free with block_Release()) or NULL
*/
static
inline
block_t
*
vlc_access_Block
(
access_t
*
access
)
{
if
(
access
->
pf_block
==
NULL
)
return
NULL
;
return
access
->
pf_block
(
access
);
}
static
inline
int
access_vaControl
(
access_t
*
p_access
,
int
i_query
,
va_list
args
)
static
inline
int
access_vaControl
(
access_t
*
p_access
,
int
i_query
,
va_list
args
)
{
{
if
(
!
p_access
)
return
VLC_EGENERIC
;
if
(
!
p_access
)
return
VLC_EGENERIC
;
...
...
src/input/access.c
View file @
3660164b
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <assert.h>
#include <assert.h>
#include "access.h"
#include "access.h"
#include "input_internal.h"
#include <libvlc.h>
#include <libvlc.h>
#include <vlc_url.h>
#include <vlc_url.h>
#include <vlc_modules.h>
#include <vlc_modules.h>
...
@@ -119,6 +120,26 @@ void access_Delete( access_t *p_access )
...
@@ -119,6 +120,26 @@ void access_Delete( access_t *p_access )
vlc_object_release
(
p_access
);
vlc_object_release
(
p_access
);
}
}
access_t
*
vlc_access_NewMRL
(
vlc_object_t
*
parent
,
const
char
*
mrl
)
{
char
*
buf
=
strdup
(
mrl
);
if
(
unlikely
(
buf
==
NULL
))
return
NULL
;
const
char
*
access
,
*
demux
,
*
location
,
*
anchor
;
input_SplitMRL
(
&
access
,
&
demux
,
&
location
,
&
anchor
,
buf
);
/* Both demux and anchor are ignored, since they are of no use here. */
access_t
*
obj
=
access_New
(
parent
,
NULL
,
access
,
""
,
location
);
free
(
buf
);
return
obj
;
}
void
vlc_access_Delete
(
access_t
*
access
)
{
access_Delete
(
access
);
}
/*****************************************************************************
/*****************************************************************************
* access_GetParentInput:
* access_GetParentInput:
...
...
src/libvlccore.sym
View file @
3660164b
access_GetParentInput
access_GetParentInput
access_vaDirectoryControlHelper
access_vaDirectoryControlHelper
vlc_access_NewMRL
vlc_access_Delete
AddMD5
AddMD5
aout_BitsPerSample
aout_BitsPerSample
aout_ChannelExtract
aout_ChannelExtract
...
...
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