Skip to content

Commit

Permalink
various: print Image instead or Video for image tracks
Browse files Browse the repository at this point in the history
Fixes #8561
  • Loading branch information
guidocella committed Jun 27, 2024
1 parent 4574644 commit f43e43a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
9 changes: 6 additions & 3 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2075,9 +2075,12 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
return m_property_read_sub(props, action, arg);
}

static const char *track_type_name(enum stream_type t)
static const char *track_type_name(struct track *t)
{
switch (t) {
if (t->image)
return "Image";

switch (t->type) {
case STREAM_VIDEO: return "Video";
case STREAM_AUDIO: return "Audio";
case STREAM_SUB: return "Sub";
Expand All @@ -2099,7 +2102,7 @@ static int property_list_tracks(void *ctx, struct m_property *prop,
continue;

res = talloc_asprintf_append(res, "%s: ",
track_type_name(track->type));
track_type_name(track));
res = talloc_strdup_append(res,
track->selected ? list_current : list_normal);
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
Expand Down
2 changes: 1 addition & 1 deletion player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void print_stream(struct MPContext *mpctx, struct track *t, bool indent)
const char *langopt = "?";
switch (t->type) {
case STREAM_VIDEO:
tname = "Video"; selopt = "vid"; langopt = "vlang";
tname = t->image ? "Image" : "Video"; selopt = "vid"; langopt = "vlang";
break;
case STREAM_AUDIO:
tname = "Audio"; selopt = "aid"; langopt = "alang";
Expand Down
3 changes: 2 additions & 1 deletion player/lua/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ mp.add_forced_key_binding(nil, "select-track", function ()
local tracks = {}

for i, track in ipairs(mp.get_property_native("track-list")) do
tracks[i] = track.type:sub(1, 1):upper() .. track.type:sub(2) .. ": " ..
tracks[i] = (track.image and "Image" or
track.type:sub(1, 1):upper() .. track.type:sub(2)) .. ": " ..
format_track(track)
end

Expand Down
7 changes: 4 additions & 3 deletions player/lua/stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -952,9 +952,10 @@ local function add_video(s)
return
end

append(s, "", {prefix="Video:", nl=o.nl .. o.nl, indent=""})
local track = mp.get_property_native("current-tracks/video")
if track and append(s, track["codec-desc"], {prefix_sep="", nl="", indent=""}) then
if track then
append(s, "", {prefix=track.image and "Image:" or "Video:", nl=o.nl .. o.nl, indent=""})
append(s, track["codec-desc"], {prefix_sep="", nl="", indent=""})
append(s, track["codec-profile"], {prefix="[", nl="", indent=" ", prefix_sep="",
no_prefix_markup=true, suffix="]"})
if track["codec"] ~= track["decoder"] then
Expand Down Expand Up @@ -1217,7 +1218,7 @@ local function add_track(c, t, i)
return
end

local type = t["type"]:sub(1,1):upper() .. t["type"]:sub(2)
local type = t.image and "Image" or t["type"]:sub(1, 1):upper() .. t["type"]:sub(2)
append(c, "", {prefix=type .. ":", nl=o.nl .. o.nl, indent=""})
append(c, t["title"], {prefix_sep="", nl="", indent=""})
append(c, t["id"], {prefix="ID:"})
Expand Down

0 comments on commit f43e43a

Please sign in to comment.