Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
api: deprecate skip and trim_duration parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ubitux committed Mar 15, 2022
1 parent 1b2d7b9 commit b1b493c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for 4:2:2 and 4:4:4 pixel formats (8 and 10 bits) in VideoToolbox
decoder

### Deprecated
- `skip` and `trim_duration` are deprecated over `start_time` and `end_time`
parameters

## [9.11.1] - 2022-02-10
### Fixed
- Fix build with FFmpeg >= 5.0
Expand Down
11 changes: 9 additions & 2 deletions src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static const AVOption sxplayer_options[] = {
{ "avselect", NULL, OFFSET(avselect), AV_OPT_TYPE_INT, {.i64=SXPLAYER_SELECT_VIDEO}, 0, NB_SXPLAYER_MEDIA_SELECTION-1 },
{ "start_time", NULL, OFFSET(start_time), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "end_time", NULL, OFFSET(end_time), AV_OPT_TYPE_DOUBLE, {.dbl=-1}, -1, DBL_MAX },
{ "skip", NULL, OFFSET(start_time), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "skip", NULL, OFFSET(skip), AV_OPT_TYPE_DOUBLE, {.dbl= 0}, 0, DBL_MAX },
{ "trim_duration", NULL, OFFSET(trim_duration), AV_OPT_TYPE_DOUBLE, {.dbl=-1}, -1, DBL_MAX },
{ "dist_time_seek_trigger", NULL, OFFSET(dist_time_seek_trigger), AV_OPT_TYPE_DOUBLE, {.dbl=1.5}, -1, DBL_MAX },
{ "max_nb_packets", NULL, OFFSET(max_nb_packets), AV_OPT_TYPE_INT, {.i64=5}, 1, 100 },
Expand Down Expand Up @@ -292,15 +292,22 @@ static int set_context_fields(struct sxplayer_ctx *s)
o->max_nb_packets, o->max_nb_frames, o->max_nb_sink,
o->filters ? o->filters : "");

if (o->skip) {
LOG(s, WARNING, "The skip option is deprecated, use start_time instead");
o->start_time = o->skip;
}

o->start_time64 = TIME2INT64(o->start_time);
o->dist_time_seek_trigger64 = TIME2INT64(o->dist_time_seek_trigger);
o->end_time64 = o->end_time < 0 ? AV_NOPTS_VALUE : TIME2INT64(o->end_time);

/* Translate trim_duration to end_time */
if (o->end_time64 == AV_NOPTS_VALUE) {
const int64_t trim_duration64 = o->trim_duration < 0 ? AV_NOPTS_VALUE : TIME2INT64(o->trim_duration);
if (trim_duration64 != AV_NOPTS_VALUE)
if (trim_duration64 != AV_NOPTS_VALUE) {
LOG(s, WARNING, "The trim_duration option is deprecated, use end_time instead");
o->end_time64 = o->start_time64 + trim_duration64;
}
} else if (o->trim_duration >= 0) {
LOG(s, ERROR, "trim_duration and end_time parameter are mutually exclusive");
return AVERROR(EINVAL);
Expand Down
1 change: 1 addition & 0 deletions src/opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct sxplayer_opts {
int avselect; // select audio or video
double start_time; // see public header
double end_time; // see public header
double skip; // see public header
double trim_duration; // see public header
double dist_time_seek_trigger; // see public header
int max_nb_frames; // maximum number of frames in the queue
Expand Down
4 changes: 2 additions & 2 deletions src/sxplayer.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ SXAPI void sxplayer_set_log_callback(struct sxplayer_ctx *s, void *arg, sxplayer
* avselect integer select audio or video stream (see SXPLAYER_SELECT_*)
* start_time double start time of the video
* end_time double end time of the video
* skip double alias for start_time
* trim_duration double equivalent to end_time-start_time
* skip double alias for start_time (deprecated)
* trim_duration double equivalent to end_time-start_time (deprecated)
* dist_time_seek_trigger double how much time forward will trigger a seek
* max_nb_frames integer maximum number of frames in the queue
* filters string custom user filters (software decoding only)
Expand Down

0 comments on commit b1b493c

Please sign in to comment.