[vlc-commits] [Git][videolan/vlc][master] stream: make `GetPtsDelay` impossible to fail
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Jul 21 08:59:14 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
e72a19a7 by Alaric Senat at 2023-07-21T08:35:16+00:00
stream: make `GetPtsDelay` impossible to fail
The documentation and code-usage state that streams cannot have that
control fail, only some types of demuxes can.
>From the demuxer documentation:
> /** Retrieves the PTS delay (roughly the default buffer duration).
> * Can fail only if synchronous and <b>not</b> an access-demuxer. The
> * underlying input stream then determines the PTS delay.
> *
> * arg1= vlc_tick_t * */
> DEMUX_GET_PTS_DELAY = 0x101,
>From the stream documentation:
> STREAM_GET_PTS_DELAY = 0x101,/**< arg1= vlc_tick_t* res=cannot fail */
This patch reflects this behavior in the stream API.
- - - - -
5 changed files:
- include/vlc_stream.h
- modules/stream_filter/decomp.c
- modules/stream_filter/prefetch.c
- src/input/demux.c
- src/input/stream.c
Changes:
=====================================
include/vlc_stream.h
=====================================
@@ -46,7 +46,6 @@ struct vlc_stream_operations {
bool (*can_pause)(stream_t *);
bool (*can_control_pace)(stream_t *);
- int (*get_pts_delay)(stream_t *, vlc_tick_t *);
int (*get_signal)(stream_t *, double *, double *);
int (*get_meta)(stream_t *, vlc_meta_t *);
int (*get_type)(stream_t *, int *);
@@ -74,6 +73,7 @@ struct vlc_stream_operations {
int (*get_content_type)(stream_t *, char **);
int (*get_tags)(stream_t *, const block_t **);
int (*get_private_id_state)(stream_t *, int, bool *);
+ vlc_tick_t (*get_pts_delay)(stream_t *);
int (*set_record_state)(stream_t *, bool, const char *, const char *);
int (*set_private_id_state)(stream_t *, int, bool);
@@ -97,6 +97,7 @@ struct vlc_stream_operations {
int (*get_title_info)(demux_t *, input_title_t ***, int *, int *, int *);
int (*get_fps)(demux_t *, double *);
int (*get_attachments)(demux_t *, input_attachment_t ***);
+ int (*get_pts_delay)(stream_t *, vlc_tick_t *);
int (*set_position)(demux_t *, double, bool);
int (*set_time)(demux_t *, vlc_tick_t, bool);
@@ -462,9 +463,11 @@ VLC_USED static inline bool vlc_stream_CanPace(stream_t *s)
return can_control_pace;
}
-VLC_USED static inline int vlc_stream_GetPtsDelay(stream_t *s, vlc_tick_t *pts_delay)
+VLC_USED static inline vlc_tick_t vlc_stream_GetPtsDelay(stream_t *s)
{
- return vlc_stream_Control(s, STREAM_GET_PTS_DELAY, pts_delay);
+ vlc_tick_t pts_delay;
+ vlc_stream_Control(s, STREAM_GET_PTS_DELAY, &pts_delay);
+ return pts_delay;
}
VLC_USED static inline int vlc_stream_GetSeekpoint(stream_t *s, unsigned *seekpoint)
=====================================
modules/stream_filter/decomp.c
=====================================
@@ -259,7 +259,7 @@ static int Open (stream_t *stream, const char *path)
p_sys->pid = -1;
p_sys->can_pause = vlc_stream_CanPause(stream->s);
p_sys->can_pace = vlc_stream_CanPace(stream->s);
- vlc_stream_GetPtsDelay(stream->s, &p_sys->pts_delay);
+ p_sys->pts_delay = vlc_stream_GetPtsDelay(stream->s);
if (vlc_stream_GetMTime(stream->s, &p_sys->mtime) != VLC_SUCCESS)
p_sys->mtime = -1;
=====================================
modules/stream_filter/prefetch.c
=====================================
@@ -460,7 +460,7 @@ static int Open(vlc_object_t *obj)
if (vlc_stream_GetMTime(stream->s, &sys->mtime) != VLC_SUCCESS)
sys->mtime = -1;
- vlc_stream_GetPtsDelay(stream->s, &sys->pts_delay);
+ sys->pts_delay = vlc_stream_GetPtsDelay(stream->s);
if (vlc_stream_GetContentType(stream->s, &sys->content_type) != VLC_SUCCESS)
sys->content_type = NULL;
=====================================
src/input/demux.c
=====================================
@@ -308,9 +308,9 @@ int demux_vaControl( demux_t *demux, int query, va_list args )
return VLC_SUCCESS;
}
case DEMUX_GET_PTS_DELAY:
- if (demux->ops->get_pts_delay != NULL) {
+ if (demux->ops->demux.get_pts_delay != NULL) {
vlc_tick_t *pts_delay = va_arg(args, vlc_tick_t *);
- return demux->ops->get_pts_delay(demux, pts_delay);
+ return demux->ops->demux.get_pts_delay(demux, pts_delay);
}
return VLC_EGENERIC;
case DEMUX_GET_TITLE_INFO:
=====================================
src/input/stream.c
=====================================
@@ -802,11 +802,15 @@ int vlc_stream_vaControl(stream_t *s, int cmd, va_list args)
}
return VLC_EGENERIC;
case STREAM_GET_PTS_DELAY:
- if (s->ops->get_pts_delay != NULL) {
- vlc_tick_t *pts_delay = va_arg(args, vlc_tick_t *);
- return s->ops->get_pts_delay(s, pts_delay);
+ {
+ vlc_tick_t *pts_delay = va_arg(args, vlc_tick_t *);
+ if (s->ops->stream.get_pts_delay != NULL) {
+ *pts_delay = s->ops->stream.get_pts_delay(s);
+ } else {
+ *pts_delay = DEFAULT_PTS_DELAY;
}
- return VLC_EGENERIC;
+ return VLC_SUCCESS;
+ }
case STREAM_GET_TITLE_INFO:
if (s->ops->stream.get_title_info != NULL) {
input_title_t ***title_info = va_arg(args, input_title_t ***);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e72a19a7149d027d540c542f4b49b0b86464f623
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e72a19a7149d027d540c542f4b49b0b86464f623
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list