Add Ogg stream serial number to tag target when parsing Vorbis comments

So the stream the Vorbis comment belongs to is shown in the tag editor GUI.
Otherwise it shouldn't change the behavior.
This commit is contained in:
Martchus 2022-05-03 23:48:24 +02:00
parent 84b4d06f53
commit 5106d94f2a
4 changed files with 14 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include "../backuphelper.h"
#include "../mediafileinfo.h"
#include "../progressfeedback.h"
#include "../tagtarget.h"
#include <c++utilities/conversion/stringbuilder.h>
#include <c++utilities/io/copy.h>
@ -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<OggVorbisComment>());
m_tags.back()->oggParams().set(pageIndex, segmentIndex, lastMetaDataBlock, mediaFormat);
auto &tag = m_tags.emplace_back(make_unique<OggVorbisComment>());
tag->oggParams().set(pageIndex, segmentIndex, lastMetaDataBlock, mediaFormat);
tag->target().tracks().emplace_back(m_iterator.pages()[pageIndex].streamSerialNumber());
}
void OggContainer::internalParseTracks(Diagnostics &diag, AbortableProgressFeedback &progress)

View File

@ -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

6
tag.h
View File

@ -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;

View File

@ -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<std::uint64_t>{0x68a1ea7f}, tags.front()->target().tracks());
// Theora tags are currently not supported and hence only the Vorbis comment is
// taken into account here
break;