player/command: remove codec-info and use track-list directly

Turns out that adding more medatata like HDR10+ and Dolby Vision would
produce a lot of duplication and it is better to centralize it around
the track-list property.

Fixes: e720159f72
This commit is contained in:
Kacper Michajłow 2024-04-16 20:29:17 +02:00
parent 68bcbf66ef
commit d23f641bb3
4 changed files with 14 additions and 89 deletions

View File

@ -1 +0,0 @@
add `video-codec-info` and `audio-codec-info` properties

View File

@ -2401,26 +2401,6 @@ Property list
Similar to ``ao-volume``, but controls the mute state. May be unimplemented
even if ``ao-volume`` works.
``audio-codec-info``
Audio codec information.
``audio-codec-info/name``
The codec name used by this track, for example ``aac``.
``audio-codec-info/desc``
The codec descriptive name used by this track.
``audio-codec-info/profile``
The codec profile used by this track. Available only if the track has
been already decoded.
::
MPV_FORMAT_NODE_MAP
"name" MPV_FORMAT_STRING
"desc" MPV_FORMAT_STRING
"profile" MPV_FORMAT_STRING
``audio-params``
Audio format as output by the audio decoder.
This has a number of sub-properties:
@ -2504,26 +2484,6 @@ Property list
multiple interop drivers for the same hardware decoder, depending on
platform and VO.
``video-codec-info``
Video codec information.
``video-codec-info/name``
The codec name used by this track, for example ``h264``.
``video-codec-info/desc``
The codec descriptive name used by this track.
``video-codec-info/profile``
The codec profile used by this track. Available only if the track has
been already decoded.
::
MPV_FORMAT_NODE_MAP
"name" MPV_FORMAT_STRING
"desc" MPV_FORMAT_STRING
"profile" MPV_FORMAT_STRING
``width``, ``height``
Video size. This uses the size of the video as decoded, or if no video
frame has been decoded yet, the (possibly incorrect) container indicated

View File

@ -1829,32 +1829,6 @@ static int mp_property_audio_delay(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
static int property_codec_info(MPContext *mpctx, struct m_property *prop,
int action, void *arg, enum stream_type st)
{
struct track *track = mpctx->current_track[0][st];
if (!track || !track->stream)
return M_PROPERTY_UNAVAILABLE;
struct m_sub_property props[] = {
{"name", SUB_PROP_STR(track->stream->codec->codec),
.unavailable = !track->stream->codec->codec},
{"desc", SUB_PROP_STR(track->stream->codec->codec_desc),
.unavailable = !track->stream->codec->codec_desc},
{"profile", SUB_PROP_STR(track->stream->codec->codec_profile),
.unavailable = !track->stream->codec->codec_profile},
{0}
};
return m_property_read_sub(props, action, arg);
}
static int mp_property_audio_codec_info(void *ctx, struct m_property *prop,
int action, void *arg)
{
return property_codec_info(ctx, prop, action, arg, STREAM_AUDIO);
}
static int property_audiofmt(struct mp_aframe *fmt, int action, void *arg)
{
if (!fmt || !mp_aframe_config_is_valid(fmt))
@ -2272,12 +2246,6 @@ static int mp_property_frame_count(void *ctx, struct m_property *prop,
return m_property_int_ro(action, arg, frames);
}
static int mp_property_video_codec_info(void *ctx, struct m_property *prop,
int action, void *arg)
{
return property_codec_info(ctx, prop, action, arg, STREAM_VIDEO);
}
static const char *get_aspect_ratio_name(double ratio)
{
// Depending on cropping/mastering exact ratio may differ.
@ -4019,9 +3987,8 @@ static const struct m_property mp_properties_base[] = {
{"ao-volume", mp_property_ao_volume},
{"ao-mute", mp_property_ao_mute},
{"audio-delay", mp_property_audio_delay},
{"audio-codec-info", mp_property_audio_codec_info},
M_PROPERTY_ALIAS("audio-codec-name", "audio-codec-info/name"),
M_PROPERTY_ALIAS("audio-codec", "audio-codec-info/desc"),
M_PROPERTY_ALIAS("audio-codec-name", "current-tracks/audio/codec"),
M_PROPERTY_ALIAS("audio-codec", "current-tracks/audio/codec-desc"),
{"audio-params", mp_property_audio_params},
{"audio-out-params", mp_property_audio_out_params},
{"aid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_AUDIO}},
@ -4035,9 +4002,8 @@ static const struct m_property mp_properties_base[] = {
{"video-dec-params", mp_property_dec_imgparams},
{"video-params", mp_property_vd_imgparams},
{"video-frame-info", mp_property_video_frame_info},
{"video-codec-info", mp_property_video_codec_info},
M_PROPERTY_ALIAS("video-format", "video-codec-info/name"),
M_PROPERTY_ALIAS("video-codec", "video-codec-info/desc"),
M_PROPERTY_ALIAS("video-format", "current-tracks/video/codec"),
M_PROPERTY_ALIAS("video-codec", "current-tracks/video/codec-desc"),
M_PROPERTY_ALIAS("dwidth", "video-out-params/dw"),
M_PROPERTY_ALIAS("dheight", "video-out-params/dh"),
M_PROPERTY_ALIAS("width", "video-params/w"),
@ -4183,10 +4149,10 @@ static const char *const *const mp_event_property_change[] = {
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
"width", "height", "container-fps", "aspect", "aspect-name", "vo-configured", "current-vo",
"video-dec-params", "osd-dimensions", "hwdec", "hwdec-current", "hwdec-interop",
"window-id", "video-codec-info"),
"window-id", "track-list", "current-tracks"),
E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate",
"samplerate", "channels", "audio", "volume", "volume-gain", "mute",
"current-ao", "audio-codec-name", "audio-params", "audio-codec-info",
"current-ao", "audio-codec-name", "audio-params", "track-list", "current-tracks",
"audio-out-params", "volume-max", "volume-gain-min", "volume-gain-max", "mixer-active"),
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
@ -6605,7 +6571,7 @@ static void cmd_context_menu(void *p)
struct mp_cmd_ctx *cmd = p;
struct MPContext *mpctx = cmd->mpctx;
struct vo *vo = mpctx->video_out;
if (vo)
vo_control(vo, VOCTRL_SHOW_MENU, NULL);
}

View File

@ -892,9 +892,9 @@ local function add_video(s)
end
append(s, "", {prefix=o.nl .. o.nl .. "Video:", nl="", indent=""})
local ci = mp.get_property_native("video-codec-info")
if ci and append(s, ci["desc"], {prefix_sep="", nl="", indent=""}) then
append(s, ci["profile"], {prefix="[", nl="", indent=" ", prefix_sep="",
local track = mp.get_property_native("current-tracks/video")
if track and append(s, track["codec-desc"], {prefix_sep="", nl="", indent=""}) then
append(s, track["codec-profile"], {prefix="[", nl="", indent=" ", prefix_sep="",
no_prefix_markup=true, suffix="]"})
append_property(s, "hwdec-current", {prefix="HW:", nl="",
indent=o.prefix_sep .. o.prefix_sep,
@ -948,10 +948,10 @@ local function add_audio(s)
end
append(s, "", {prefix=o.nl .. o.nl .. "Audio:", nl="", indent=""})
local ci = mp.get_property_native("audio-codec-info")
if ci then
append(s, ci["desc"], {prefix_sep="", nl="", indent=""})
append(s, ci["profile"], {prefix="[", nl="", indent=" ", prefix_sep="",
local track = mp.get_property_native("current-tracks/audio")
if track then
append(s, track["codec-desc"], {prefix_sep="", nl="", indent=""})
append(s, track["codec-profile"], {prefix="[", nl="", indent=" ", prefix_sep="",
no_prefix_markup=true, suffix="]"})
end
append_property(s, "current-ao", {prefix="AO:", nl="",