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.
This commit is contained in:
Hubert Głuchowski authored and Kacper Michajłow committed 2025-12-23 07:01:29 +01:00
1 parent bb97882c9a
commit a330318592
2 files changed
+25

No files matched your search

+6
View File
@@ -3960,6 +3960,12 @@ Property list
somewhat weird form (apparently "hex BCD"), indicating the release version
of the libass library linked to mpv.
``subrandr-version``
The value of ``sbr_library_version()`` as a string in the format
``<major>.<minor>.<patch>``, indicating the release version of the subrandr
library at runtime. This property is unavailable if mpv is not compiled
with subrandr enabled.
``platform``
Returns a string describing what target platform mpv was built for. The value
of this is dependent on what the underlying build system detects. Some of the
+19
View File
@@ -25,7 +25,12 @@
#include <math.h>
#include <sys/types.h>
#include "config.h" // for HAVE_SUBRANDR
#include <ass/ass.h>
#if HAVE_SUBRANDR
#include <subrandr/subrandr.h>
#endif
#include <libavutil/avstring.h>
#include <libavutil/common.h>
#include <libavutil/timecode.h>
@@ -3757,6 +3762,19 @@ static int mp_property_libass_version(void *ctx, struct m_property *prop,
return m_property_int64_ro(action, arg, ass_library_version());
}
static int mp_property_subrandr_version(void *ctx, struct m_property *prop,
int action, void *arg)
{
#if HAVE_SUBRANDR
uint32_t major, minor, patch;
sbr_library_version(&major, &minor, &patch);
const char *result = mp_tprintf(33, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, major, minor, patch);
return m_property_strdup_ro(action, arg, result);
#else
return M_PROPERTY_UNAVAILABLE;
#endif
}
static int mp_property_platform(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -4540,6 +4558,7 @@ static const struct m_property mp_properties_base[] = {
{"mpv-configuration", mp_property_configuration},
{"ffmpeg-version", mp_property_ffmpeg},
{"libass-version", mp_property_libass_version},
{"subrandr-version", mp_property_subrandr_version},
{"platform", mp_property_platform},
{"options", mp_property_options},