diff --git a/src/audiosource.h b/src/audiosource.h index b082a06..0f5e857 100644 --- a/src/audiosource.h +++ b/src/audiosource.h @@ -55,7 +55,7 @@ struct BSAudioProperties { double StartTime; /* in seconds */ }; -struct LWAudioDecoder { +class LWAudioDecoder { private: AVFormatContext *FormatContext = nullptr; AVCodecContext *CodecContext = nullptr; diff --git a/src/tracklist.cpp b/src/tracklist.cpp index 5c52a53..e7a81e9 100644 --- a/src/tracklist.cpp +++ b/src/tracklist.cpp @@ -92,4 +92,31 @@ int BestTrackList::GetNumTracks() const { const BestTrackList::TrackInfo &BestTrackList::GetTrackInfo(int Track) const { return TrackList[Track]; -} \ No newline at end of file +} + +std::map BestTrackList::GetFileMetadata() const { + std::map Result; + + auto Entry = av_dict_iterate(FormatContext->metadata, nullptr); + while (Entry) { + Result[Entry->key] = Entry->value; + Entry = av_dict_iterate(FormatContext->metadata, Entry); + } + + return Result; +} + +std::map BestTrackList::GetTrackMetadata(int Track) const { + if (Track < 0 || Track >= FormatContext->nb_streams) + throw BestSourceException("Invalid track number"); + + std::map Result; + + auto Entry = av_dict_iterate(FormatContext->streams[Track]->metadata, nullptr); + while (Entry) { + Result[Entry->key] = Entry->value; + Entry = av_dict_iterate(FormatContext->streams[Track]->metadata, Entry); + } + + return Result; +} diff --git a/src/tracklist.h b/src/tracklist.h index 6483a84..af6f085 100644 --- a/src/tracklist.h +++ b/src/tracklist.h @@ -50,6 +50,8 @@ struct BestTrackList { ~BestTrackList(); [[nodiscard]] int GetNumTracks() const; [[nodiscard]] const TrackInfo &GetTrackInfo(int Track) const; + [[nodiscard]] std::map GetFileMetadata() const; + [[nodiscard]] std::map GetTrackMetadata(int Track) const; }; #endif diff --git a/src/videosource.h b/src/videosource.h index 9bdb7dc..25f4723 100644 --- a/src/videosource.h +++ b/src/videosource.h @@ -95,7 +95,7 @@ struct BSVideoProperties { int Rotation; /* A positive number in degrees */ }; -struct LWVideoDecoder { +class LWVideoDecoder { private: AVFormatContext *FormatContext = nullptr; AVCodecContext *CodecContext = nullptr;