diff --git a/ogg/oggcontainer.cpp b/ogg/oggcontainer.cpp index f58d99e..f668e27 100644 --- a/ogg/oggcontainer.cpp +++ b/ogg/oggcontainer.cpp @@ -5,6 +5,7 @@ #include "../backuphelper.h" #include "../mediafileinfo.h" #include "../progressfeedback.h" +#include "../tagtarget.h" #include #include @@ -317,8 +318,9 @@ void OggContainer::internalParseTags(Diagnostics &diag, AbortableProgressFeedbac */ void OggContainer::announceComment(std::size_t pageIndex, std::size_t segmentIndex, bool lastMetaDataBlock, GeneralMediaFormat mediaFormat) { - m_tags.emplace_back(make_unique()); - m_tags.back()->oggParams().set(pageIndex, segmentIndex, lastMetaDataBlock, mediaFormat); + auto &tag = m_tags.emplace_back(make_unique()); + tag->oggParams().set(pageIndex, segmentIndex, lastMetaDataBlock, mediaFormat); + tag->target().tracks().emplace_back(m_iterator.pages()[pageIndex].streamSerialNumber()); } void OggContainer::internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress) diff --git a/ogg/oggcontainer.h b/ogg/oggcontainer.h index f24b93e..97719e3 100644 --- a/ogg/oggcontainer.h +++ b/ogg/oggcontainer.h @@ -97,6 +97,9 @@ inline TagType OggVorbisComment::type() const /*! * \brief Returns true; the target is used to specify the stream. + * \remarks At this point, one cannot move a tag from one stream to another by changing the target. So + * the target is only evaluated when invoking createTag() and added to parsed tags for informative + * purposes. * \sa OggContainer::createTag(), TagTarget */ inline bool OggVorbisComment::supportsTarget() const diff --git a/tag.h b/tag.h index 914e498..591a808 100644 --- a/tag.h +++ b/tag.h @@ -193,6 +193,7 @@ public: std::uint64_t size() const; virtual bool supportsTarget() const; const TagTarget &target() const; + TagTarget &target(); void setTarget(const TagTarget &target); virtual TagTargetLevel targetLevel() const; std::string_view targetLevelName() const; @@ -255,6 +256,11 @@ inline const TagTarget &Tag::target() const return m_target; } +inline TagTarget &Tag::target() +{ + return m_target; +} + inline void Tag::setTarget(const TagTarget &target) { m_target = target; diff --git a/tests/overallogg.cpp b/tests/overallogg.cpp index 20943e0..ffac139 100644 --- a/tests/overallogg.cpp +++ b/tests/overallogg.cpp @@ -42,6 +42,7 @@ void OverallTests::checkOggTestfile1() CPPUNIT_ASSERT(m_fileInfo.hasAnyTag()); CPPUNIT_ASSERT_EQUAL(1_st, tags.size()); CPPUNIT_ASSERT_EQUAL("ffmpeg2theora 0.13"s, tags.front()->value(KnownField::Encoder).toString()); + CPPUNIT_ASSERT_EQUAL(std::vector{0x68a1ea7f}, tags.front()->target().tracks()); // Theora tags are currently not supported and hence only the Vorbis comment is // taken into account here break;