1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:27:35 +00:00

LibAudio: Add a generic audio metadata container

This container has several design goals:
- Represent all common and relevant metadata fields of audio files in a
  unified way.
- Allow perfect recreation of any metadata format from the in-memory
  structure. This requires that we allow non-detected fields to reside
  in an "untyped" miscellaneous collection.

Like with pictures, plugins are free to store their metadata into the
m_metadata field whenever they read it. It is recommended that this
happens on loader creation; however failing to read metadata should not
cause an error in the plugin.
This commit is contained in:
kleines Filmröllchen 2023-03-07 16:50:32 +01:00 committed by Tim Flynn
parent d1dd753a95
commit d8e8ddedf3
4 changed files with 168 additions and 0 deletions

View file

@ -18,6 +18,7 @@
#include <AK/Try.h>
#include <LibAudio/GenericTypes.h>
#include <LibAudio/LoaderError.h>
#include <LibAudio/Metadata.h>
#include <LibAudio/Sample.h>
#include <LibAudio/SampleFormats.h>
@ -67,12 +68,14 @@ public:
virtual DeprecatedString format_name() = 0;
virtual PcmSampleFormat pcm_format() = 0;
Metadata const& metadata() const { return m_metadata; }
Vector<PictureData> const& pictures() const { return m_pictures; };
protected:
NonnullOwnPtr<SeekableStream> m_stream;
Vector<PictureData> m_pictures;
Metadata m_metadata;
};
class Loader : public RefCounted<Loader> {
@ -96,6 +99,7 @@ public:
u16 num_channels() const { return m_plugin->num_channels(); }
DeprecatedString format_name() const { return m_plugin->format_name(); }
u16 bits_per_sample() const { return pcm_bits_per_sample(m_plugin->pcm_format()); }
Metadata const& metadata() const { return m_plugin->metadata(); }
Vector<PictureData> const& pictures() const { return m_plugin->pictures(); };
private: