1 #ifndef TAG_PARSER_GENERICCONTAINER_H 2 #define TAG_PARSER_GENERICCONTAINER_H 29 void validateElementStructure(
Diagnostics &diag, uint64 *paddingSize =
nullptr);
30 FileInfoType &fileInfo()
const;
31 ElementType *firstElement()
const;
32 const std::vector<std::unique_ptr<ElementType>> &additionalElements()
const;
33 std::vector<std::unique_ptr<ElementType>> &additionalElements();
34 TagType *tag(std::size_t index)
override;
35 std::size_t tagCount()
const override;
36 TrackType *track(std::size_t index)
override;
38 std::size_t trackCount()
const override;
39 const std::vector<std::unique_ptr<TagType>> &tags()
const;
40 std::vector<std::unique_ptr<TagType>> &tags();
41 const std::vector<std::unique_ptr<TrackType>> &tracks()
const;
42 std::vector<std::unique_ptr<TrackType>> &tracks();
45 bool removeTag(
Tag *tag)
override;
46 void removeAllTags()
override;
49 void removeAllTracks()
override;
50 void reset()
override;
60 std::vector<std::unique_ptr<TagType>>
m_tags;
61 std::vector<std::unique_ptr<TrackType>>
m_tracks;
64 FileInfoType *m_fileInfo;
70 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
73 , m_fileInfo(&fileInfo)
83 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
98 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
102 if (m_firstElement) {
103 m_firstElement->validateSubsequentElementStructure(diag, paddingSize);
112 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
130 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
133 return m_firstElement.get();
143 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
146 return m_additionalElements;
156 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
159 return m_additionalElements;
162 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
165 return m_tags[index].get();
168 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
171 return m_tags.size();
174 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
177 return m_tracks[index].get();
180 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
183 for (
auto &track : m_tracks) {
184 if (track->id() == id) {
191 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
194 return m_tracks.size();
206 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
221 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
236 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
251 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
257 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
261 if (!m_tags.empty()) {
262 if (!target.
isEmpty() && m_tags.front()->supportsTarget()) {
263 for (
auto &tag : m_tags) {
264 if (tag->target() == target) {
269 return m_tags.front().get();
274 m_tags.emplace_back(std::make_unique<TagType>());
275 auto &tag = m_tags.back();
276 tag->setTarget(target);
280 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
283 if (
auto size = m_tags.size()) {
284 m_tags.erase(std::remove_if(m_tags.begin(), m_tags.end(),
285 [tag](
const std::unique_ptr<TagType> &existingTag) ->
bool {
return static_cast<Tag *>(existingTag.get()) == tag; }),
287 return size != m_tags.size();
292 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
314 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
317 if (areTracksParsed() && supportsTrackModifications()) {
319 auto id = track->id();
321 for (
const auto &track : m_tracks) {
322 if (track->id() == id) {
324 goto ensureIdIsUnique;
329 m_tracks.emplace_back(track);
330 return m_tracksAltered =
true;
335 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
338 bool removed =
false;
339 if (areTracksParsed() && supportsTrackModifications() && !m_tracks.empty()) {
340 for (
auto i = m_tracks.end() - 1, begin = m_tracks.begin();; --i) {
341 if (static_cast<AbstractTrack *>(i->get()) == track) {
351 m_tracksAltered =
true;
357 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
360 if (areTracksParsed() && supportsTrackModifications() && m_tracks.size()) {
362 m_tracksAltered =
true;
366 template <
class FileInfoType,
class TagType,
class TrackType,
class ElementType>
369 AbstractContainer::reset();
370 m_firstElement.reset();
371 m_additionalElements.clear();
378 #endif // TAG_PARSER_GENERICCONTAINER_H std::unique_ptr< ElementType > m_firstElement
Implementation of TagParser::Tag for the MP4 container.
The Tag class is used to store, read and write tag information.
The AbstractContainer class provides an interface and common functionality to parse and make a certai...
The Mp4Atom class helps to parse MP4 files.
Implementation of TagParser::AbstractTrack for the MP4 container.
std::vector< std::unique_ptr< ElementType > > m_additionalElements
bool isEmpty() const
Returns an indication whether the target is empty.
The TagTarget class specifies the target of a tag.
std::vector< std::unique_ptr< TrackType > > m_tracks
GenericContainer(FileInfoType &fileInfo, uint64 startOffset)
Constructs a new container for the specified fileInfo at the specified startOffset.
The AbstractTrack class parses and stores technical information about video, audio and other kinds of...
TagType
Specifies the tag type.
Contains all classes and functions of the TagInfo library.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TrackType
Specifies the track type.
std::vector< std::unique_ptr< TagType > > m_tags
The Diagnostics class is a container for DiagMessage.
The GenericContainer class helps parsing header, track, tag and chapter information of a file.