Skip to content

Commit 5da86db

Browse files
committed
player/command: add subrandr-version property
Allows script to detect the presence of subrandr at runtime, useful for determining whether this mpv instance can play SRV3 subtitles.
1 parent f8c8bf0 commit 5da86db

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

DOCS/man/input.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3886,6 +3886,12 @@ Property list
38863886
somewhat weird form (apparently "hex BCD"), indicating the release version
38873887
of the libass library linked to mpv.
38883888

3889+
``subrandr-version``
3890+
The value of ``sbr_library_version()`` as a string in the format
3891+
``<major>.<minor>.<patch>``, indicating the release version of the subrandr
3892+
library linked to mpv. This property is unavailable if mpv is not compiled
3893+
with subrandr enabled.
3894+
38893895
``platform``
38903896
Returns a string describing what target platform mpv was built for. The value
38913897
of this is dependent on what the underlying build system detects. Some of the

player/command.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
#include <math.h>
2626
#include <sys/types.h>
2727

28+
#include "config.h" // for HAVE_SUBRANDR
29+
2830
#include <ass/ass.h>
31+
#if HAVE_SUBRANDR
32+
#include <subrandr/subrandr.h>
33+
#endif
2934
#include <libavutil/avstring.h>
3035
#include <libavutil/common.h>
3136
#include <libavutil/timecode.h>
@@ -3665,6 +3670,19 @@ static int mp_property_libass_version(void *ctx, struct m_property *prop,
36653670
return m_property_int64_ro(action, arg, ass_library_version());
36663671
}
36673672

3673+
static int mp_property_subrandr_version(void *ctx, struct m_property *prop,
3674+
int action, void *arg)
3675+
{
3676+
#if HAVE_SUBRANDR
3677+
uint32_t major, minor, patch;
3678+
sbr_library_version(&major, &minor, &patch);
3679+
const char *result = mp_tprintf(32, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, major, minor, patch);
3680+
return m_property_strdup_ro(action, arg, result);
3681+
#else
3682+
return M_PROPERTY_UNAVAILABLE;
3683+
#endif
3684+
}
3685+
36683686
static int mp_property_platform(void *ctx, struct m_property *prop,
36693687
int action, void *arg)
36703688
{
@@ -4446,6 +4464,7 @@ static const struct m_property mp_properties_base[] = {
44464464
{"mpv-configuration", mp_property_configuration},
44474465
{"ffmpeg-version", mp_property_ffmpeg},
44484466
{"libass-version", mp_property_libass_version},
4467+
{"subrandr-version", mp_property_subrandr_version},
44494468
{"platform", mp_property_platform},
44504469

44514470
{"options", mp_property_options},

0 commit comments

Comments
 (0)