From 0485d6b5c621e57bd7150da0edf16ce672b31eb4 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 17 Aug 2017 18:59:51 +0200 Subject: [PATCH] Add method to generate technical summary --- mediafileinfo.cpp | 30 ++++++++++++++++++++++++++++++ mediafileinfo.h | 1 + 2 files changed, 31 insertions(+) diff --git a/mediafileinfo.cpp b/mediafileinfo.cpp index 4ea26ee..465303a 100644 --- a/mediafileinfo.cpp +++ b/mediafileinfo.cpp @@ -865,6 +865,36 @@ unordered_set MediaFileInfo::availableLanguages(MediaType type) const return res; } +/*! + * \brief Generates a short technical summary about the file's tracks. + * + * parseTracks() needs to be called before. Otherwise this + * method always returns an empty string. + * + * Example (exact format might change in the future!): + * "H.264-720p / HE-AAC-6ch-eng / HE-AAC-2ch-ger / SRT-eng / SRT-ger" + * + * \sa parseTracks() + */ +string MediaFileInfo::technicalSummary() const +{ + if(m_container) { + const size_t trackCount = m_container->trackCount(); + vector parts; + parts.reserve(trackCount); + for(size_t i = 0; i != trackCount; ++i) { + const string description(m_container->track(i)->description()); + if(!description.empty()) { + parts.emplace_back(move(description)); + } + } + return joinStrings(parts, " / "); + } else if(m_singleTrack) { + return m_singleTrack->description(); + } + return string(); +} + /*! * \brief Removes a possibly assigned ID3v1 tag from the current file. * diff --git a/mediafileinfo.h b/mediafileinfo.h index 20cbff9..01f3fb9 100644 --- a/mediafileinfo.h +++ b/mediafileinfo.h @@ -97,6 +97,7 @@ public: bool hasTracksOfType(Media::MediaType type) const; ChronoUtilities::TimeSpan duration() const; std::unordered_set availableLanguages(Media::MediaType type = Media::MediaType::Audio) const; + std::string technicalSummary() const; bool areTracksSupported() const; // ... the tags ParsingStatus tagsParsingStatus() const;