Implement determine tag/index pos for MKV
This commit is contained in:
parent
a8dce14514
commit
554351810a
|
@ -175,6 +175,9 @@ bool AbstractContainer::supportsTrackModifications() const
|
||||||
* \brief Determines the position of the index.
|
* \brief Determines the position of the index.
|
||||||
* \returns Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could
|
* \returns Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could
|
||||||
* be determined; otherwise returns ElementPosition::Keep.
|
* be determined; otherwise returns ElementPosition::Keep.
|
||||||
|
* \remarks
|
||||||
|
* - It might be required to parse tracks before the index position can be determined.
|
||||||
|
* - Not be applicable for files composed of multiple segments.
|
||||||
*/
|
*/
|
||||||
ElementPosition AbstractContainer::determineIndexPosition() const
|
ElementPosition AbstractContainer::determineIndexPosition() const
|
||||||
{
|
{
|
||||||
|
@ -329,6 +332,9 @@ void AbstractContainer::removeAllTags()
|
||||||
* \brief Determines the position of the tags inside the file.
|
* \brief Determines the position of the tags inside the file.
|
||||||
* \returns Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could
|
* \returns Returns ElementPosition::BeforeData or ElementPosition::AfterData if the position could
|
||||||
* be determined; otherwise returns ElementPosition::Keep.
|
* be determined; otherwise returns ElementPosition::Keep.
|
||||||
|
* \remarks
|
||||||
|
* - It might be required to parse tags before the tag position can be determined.
|
||||||
|
* - Not be applicable for files composed of multiple segments.
|
||||||
*/
|
*/
|
||||||
ElementPosition AbstractContainer::determineTagPosition() const
|
ElementPosition AbstractContainer::determineTagPosition() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -332,14 +332,41 @@ generateRandomId:
|
||||||
return attachment.get();
|
return attachment.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Determines the position of the element with the specified \a elementId.
|
||||||
|
* \sa determineTagPosition() and determineIndexPosition()
|
||||||
|
*/
|
||||||
|
ElementPosition MatroskaContainer::determineElementPosition(uint64 elementId) const
|
||||||
|
{
|
||||||
|
if(m_firstElement && m_segmentCount == 1) {
|
||||||
|
if(const EbmlElement *segmentElement = m_firstElement->siblingById(MatroskaIds::Segment, true)) {
|
||||||
|
for(const EbmlElement *childElement = segmentElement->firstChild(); childElement; childElement = childElement->nextSibling()) {
|
||||||
|
if(childElement->id() == elementId) {
|
||||||
|
return ElementPosition::BeforeData;
|
||||||
|
} else if(childElement->id() == MatroskaIds::Cluster) {
|
||||||
|
for(const auto &seekInfo : m_seekInfos) {
|
||||||
|
for(const auto &info : seekInfo->info()) {
|
||||||
|
if(info.first == elementId) {
|
||||||
|
return ElementPosition::AfterData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ElementPosition::Keep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ElementPosition::Keep;
|
||||||
|
}
|
||||||
|
|
||||||
ElementPosition MatroskaContainer::determineTagPosition() const
|
ElementPosition MatroskaContainer::determineTagPosition() const
|
||||||
{
|
{
|
||||||
return ElementPosition::Keep; // TODO
|
return determineElementPosition(MatroskaIds::Tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementPosition MatroskaContainer::determineIndexPosition() const
|
ElementPosition MatroskaContainer::determineIndexPosition() const
|
||||||
{
|
{
|
||||||
return ElementPosition::Keep; // TODO
|
return determineElementPosition(MatroskaIds::Cues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatroskaContainer::internalParseHeader()
|
void MatroskaContainer::internalParseHeader()
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
MatroskaAttachment *createAttachment();
|
MatroskaAttachment *createAttachment();
|
||||||
MatroskaAttachment *attachment(std::size_t index);
|
MatroskaAttachment *attachment(std::size_t index);
|
||||||
std::size_t attachmentCount() const;
|
std::size_t attachmentCount() const;
|
||||||
|
ElementPosition determineElementPosition(uint64 elementId) const;
|
||||||
ElementPosition determineTagPosition() const;
|
ElementPosition determineTagPosition() const;
|
||||||
ElementPosition determineIndexPosition() const;
|
ElementPosition determineIndexPosition() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue