Skip to content

Audio/video media metadata: expose over EC, in the REST API, and in the File Details dialog #418

Description

@ngosang

Note: This should be implemented after #417

Summary

aMule stores audio/video media metadata (length, bitrate, codec, artist, album, title) on
a file, but this information is not carried over the EC protocol, so neither the
amuleapi REST API nor the remote GUI can show it — and the desktop File Details dialog
doesn't display it either. This issue adds media metadata end-to-end in three parts.

Effort: HEAVIEST — the only issue that touches all three layers (unlike issues 01–04,
which are webapi-only). It requires an EC-protocol addition on the amuled side.

Background

The six media fields live on CAbstractFile as FT_MEDIA_* tags
(src/include/tags/FileTags.h:72-77) and are read via GetIntTagValue / GetStrTagValue:

Field Tag Type Accessor
length (seconds) FT_MEDIA_LENGTH (0xD3) int GetIntTagValue
bitrate FT_MEDIA_BITRATE (0xD4) int GetIntTagValue
codec FT_MEDIA_CODEC (0xD5) string GetStrTagValue
artist FT_MEDIA_ARTIST (0xD0) string GetStrTagValue
album FT_MEDIA_ALBUM (0xD1) string GetStrTagValue
title FT_MEDIA_TITLE (0xD2) string GetStrTagValue

GetMetaDataVer() (src/KnownFile.cpp:124) returns non-zero only once media has been
probed — use it to guard emission/display so files without metadata cost nothing.

Reference emitter (Kad/ed2k tag build): src/KnownFile.cpp:1260-1268. Reference reader
(these same tags in the search list): src/SearchListCtrl.cpp:265-271.


Part 1 — amuled / EC protocol

  • Add new tag codes (e.g. EC_TAG_KNOWNFILE_MEDIA_LENGTH, _BITRATE, _CODEC,
    _ARTIST, _ALBUM, _TITLE) to src/libs/ec/cpp/ECCodes.h, plus their entries in the
    name-lookup switch in the same file.
  • Emit them in CEC_SharedFile_Tag (src/ECSpecialCoreTags.cpp:214, the base ctor shared
    by both shared files and partfiles) from file->GetIntTagValue(FT_MEDIA_LENGTH/BITRATE)
    and file->GetStrTagValue(FT_MEDIA_CODEC/ARTIST/ALBUM/TITLE).
  • Guard the whole block behind GetMetaDataVer() != 0 so files without probed metadata add
    no tags.

Because the emitter is the shared base ctor, both /shared and /downloads (partfiles)
get the tags automatically — no per-role code.

Part 2 — webapi (amuleapi)

  • Decode the new tags in src/webapi/Refresher.cpp into a new FileSnapshot sub-struct
    (src/webapi/State.h).
  • Expose an inline media object on both GET /downloads/{hash} and GET /shared/{hash}
    via the shared write helper (see the overview's two-endpoint model). Note: the
    GET /shared/{hash} detail endpoint is introduced by issue 01 — media is one of its
    fields.
"media": {
  "length_s": 5400,
  "bitrate": 1500,
  "codec": "h264",
  "artist": "...",
  "album": "...",
  "title": "..."
}
  • Omit the media object entirely when the file has no metadata.

Part 3 — aMule desktop GUI (amule) + remote GUI (amulegui)

Show the metadata in the File Details modal, which currently has no media section.

  • Add a new "Media Info" wxStaticBoxSizer (with IDC_FD_MEDIA_* label IDs) to
    fileDetails() in src/muuli_wdr.cpp, and declare the IDs in src/muuli_wdr.h
    mirroring the existing "Intelligent Corruption Handling" box.
  • Populate the labels in CFileDetailDialog::UpdateData() (src/FileDetailDialog.cpp:148-200)
    from m_file->GetIntTagValue(FT_MEDIA_*) / GetStrTagValue(FT_MEDIA_*), guarded by
    GetMetaDataVer().
  • amulegui (CLIENT_GUI build): the remote GUI's m_file is a proxy populated from
    EC, so it must decode the Part-1 tags into the proxy in the partfile-update path
    (src/amule-remote-gui.cpp ~2073, alongside the existing source-names / comments / A4AF
    decode). Store them with AddTagUnique(CTag(FT_MEDIA_*, value)) so the same
    GetIntTagValue / GetStrTagValue calls used in UpdateData() work identically in both
    the monolithic and remote builds — no build-specific display code.

Acceptance criteria

  • For a probed media file, GET /downloads/{hash} and GET /shared/{hash} return a
    populated media object; for a non-media file the object is absent.
  • The File Details dialog shows a "Media Info" box with the six fields in both the
    monolithic amule and the remote amulegui.
  • Files without metadata add no EC tags and show no (or an empty) Media Info box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions