added more methods to control file layout when applying changes
This commit is contained in:
parent
238ca0cef9
commit
1db83eeccd
|
@ -74,11 +74,14 @@ MediaFileInfo::MediaFileInfo() :
|
||||||
m_chaptersParsingStatus(ParsingStatus::NotParsedYet),
|
m_chaptersParsingStatus(ParsingStatus::NotParsedYet),
|
||||||
m_attachmentsParsingStatus(ParsingStatus::NotParsedYet),
|
m_attachmentsParsingStatus(ParsingStatus::NotParsedYet),
|
||||||
m_forceFullParse(MEDIAINFO_CPP_FORCE_FULL_PARSE),
|
m_forceFullParse(MEDIAINFO_CPP_FORCE_FULL_PARSE),
|
||||||
|
m_forceRewrite(true),
|
||||||
m_minPadding(0),
|
m_minPadding(0),
|
||||||
m_maxPadding(0),
|
m_maxPadding(0),
|
||||||
m_preferredPadding(0),
|
m_preferredPadding(0),
|
||||||
m_tagPosition(TagPosition::BeforeData),
|
m_tagPosition(ElementPosition::BeforeData),
|
||||||
m_forceTagPosition(true)
|
m_forceTagPosition(true),
|
||||||
|
m_indexPosition(ElementPosition::BeforeData),
|
||||||
|
m_forceIndexPosition(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -97,11 +100,14 @@ MediaFileInfo::MediaFileInfo(const string &path) :
|
||||||
m_chaptersParsingStatus(ParsingStatus::NotParsedYet),
|
m_chaptersParsingStatus(ParsingStatus::NotParsedYet),
|
||||||
m_attachmentsParsingStatus(ParsingStatus::NotParsedYet),
|
m_attachmentsParsingStatus(ParsingStatus::NotParsedYet),
|
||||||
m_forceFullParse(MEDIAINFO_CPP_FORCE_FULL_PARSE),
|
m_forceFullParse(MEDIAINFO_CPP_FORCE_FULL_PARSE),
|
||||||
|
m_forceRewrite(true),
|
||||||
m_minPadding(0),
|
m_minPadding(0),
|
||||||
m_maxPadding(0),
|
m_maxPadding(0),
|
||||||
m_preferredPadding(0),
|
m_preferredPadding(0),
|
||||||
m_tagPosition(TagPosition::BeforeData),
|
m_tagPosition(ElementPosition::BeforeData),
|
||||||
m_forceTagPosition(true)
|
m_forceTagPosition(true),
|
||||||
|
m_indexPosition(ElementPosition::BeforeData),
|
||||||
|
m_forceIndexPosition(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -142,7 +148,7 @@ void MediaFileInfo::parseContainerFormat()
|
||||||
open(); // ensure the file is open
|
open(); // ensure the file is open
|
||||||
m_containerFormat = ContainerFormat::Unknown;
|
m_containerFormat = ContainerFormat::Unknown;
|
||||||
// file size
|
// file size
|
||||||
m_paddingSize = 0x0u;
|
m_paddingSize = 0;
|
||||||
m_containerOffset = 0;
|
m_containerOffset = 0;
|
||||||
// read signatrue
|
// read signatrue
|
||||||
char buff[16];
|
char buff[16];
|
||||||
|
|
|
@ -40,10 +40,11 @@ enum class TagUsage
|
||||||
Never /**< tags of the type are never used; a possibly existing tag of the type is removed */
|
Never /**< tags of the type are never used; a possibly existing tag of the type is removed */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TagPosition
|
enum class ElementPosition
|
||||||
{
|
{
|
||||||
BeforeData,
|
BeforeData, /**< the element is positioned before the actual data */
|
||||||
AfterData
|
AfterData, /**< the element is positioned after the actual data */
|
||||||
|
Keep /**< the element is placed at its previous position */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -141,16 +142,22 @@ public:
|
||||||
// methods to get, set object behaviour
|
// methods to get, set object behaviour
|
||||||
bool isForcingFullParse() const;
|
bool isForcingFullParse() const;
|
||||||
void setForceFullParse(bool forceFullParse);
|
void setForceFullParse(bool forceFullParse);
|
||||||
|
bool isForcingRewrite() const;
|
||||||
|
void setForceRewrite(bool forceRewrite);
|
||||||
size_t minPadding() const;
|
size_t minPadding() const;
|
||||||
void setMinPadding(size_t minPadding);
|
void setMinPadding(size_t minPadding);
|
||||||
size_t maxPadding() const;
|
size_t maxPadding() const;
|
||||||
void setMaxPadding(size_t maxPadding);
|
void setMaxPadding(size_t maxPadding);
|
||||||
size_t preferredPadding() const;
|
size_t preferredPadding() const;
|
||||||
void setPreferredPadding(size_t preferredPadding);
|
void setPreferredPadding(size_t preferredPadding);
|
||||||
TagPosition tagPosition() const;
|
ElementPosition tagPosition() const;
|
||||||
void setTagPosition(TagPosition tagPosition);
|
void setTagPosition(ElementPosition tagPosition);
|
||||||
bool forceTagPosition() const;
|
bool forceTagPosition() const;
|
||||||
void setForceTagPosition(bool forceTagPosition);
|
void setForceTagPosition(bool forceTagPosition);
|
||||||
|
ElementPosition indexPosition() const;
|
||||||
|
void setIndexPosition(ElementPosition indexPosition);
|
||||||
|
bool forceIndexPosition() const;
|
||||||
|
void setForceIndexPosition(bool forceTagPosition);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void invalidated();
|
virtual void invalidated();
|
||||||
|
@ -180,11 +187,14 @@ private:
|
||||||
ParsingStatus m_attachmentsParsingStatus;
|
ParsingStatus m_attachmentsParsingStatus;
|
||||||
// fields specifying object behaviour
|
// fields specifying object behaviour
|
||||||
bool m_forceFullParse;
|
bool m_forceFullParse;
|
||||||
|
bool m_forceRewrite;
|
||||||
size_t m_minPadding;
|
size_t m_minPadding;
|
||||||
size_t m_maxPadding;
|
size_t m_maxPadding;
|
||||||
size_t m_preferredPadding;
|
size_t m_preferredPadding;
|
||||||
TagPosition m_tagPosition;
|
ElementPosition m_tagPosition;
|
||||||
bool m_forceTagPosition;
|
bool m_forceTagPosition;
|
||||||
|
ElementPosition m_indexPosition;
|
||||||
|
bool m_forceIndexPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -383,6 +393,22 @@ inline void MediaFileInfo::setForceFullParse(bool forceFullParse)
|
||||||
m_forceFullParse = forceFullParse;
|
m_forceFullParse = forceFullParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns whether forcing rewriting (when applying changes) is enabled.
|
||||||
|
*/
|
||||||
|
inline bool MediaFileInfo::isForcingRewrite() const
|
||||||
|
{
|
||||||
|
return m_forceRewrite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets whether forcing rewriting (when applying changes) is enabled.
|
||||||
|
*/
|
||||||
|
inline void MediaFileInfo::setForceRewrite(bool forceRewrite)
|
||||||
|
{
|
||||||
|
m_forceRewrite = forceRewrite;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns the minimum padding to be written before the data blocks when applying changes.
|
* \brief Returns the minimum padding to be written before the data blocks when applying changes.
|
||||||
*
|
*
|
||||||
|
@ -458,7 +484,7 @@ inline void MediaFileInfo::setPreferredPadding(size_t preferredPadding)
|
||||||
* \brief Returns the position (in the output file) where the tag information is written when applying changes.
|
* \brief Returns the position (in the output file) where the tag information is written when applying changes.
|
||||||
* \sa setTagPosition()
|
* \sa setTagPosition()
|
||||||
*/
|
*/
|
||||||
inline TagPosition MediaFileInfo::tagPosition() const
|
inline ElementPosition MediaFileInfo::tagPosition() const
|
||||||
{
|
{
|
||||||
return m_tagPosition;
|
return m_tagPosition;
|
||||||
}
|
}
|
||||||
|
@ -471,8 +497,9 @@ inline TagPosition MediaFileInfo::tagPosition() const
|
||||||
* might not be used if forceTagPosition() is false.
|
* might not be used if forceTagPosition() is false.
|
||||||
* - However if the specified position is not supported by the container/tag format or by the implementation
|
* - However if the specified position is not supported by the container/tag format or by the implementation
|
||||||
* for the format it is ignored (even if forceTagPosition() is true).
|
* for the format it is ignored (even if forceTagPosition() is true).
|
||||||
|
* - Default value is ElementPosition::BeforeData
|
||||||
*/
|
*/
|
||||||
inline void MediaFileInfo::setTagPosition(TagPosition tagPosition)
|
inline void MediaFileInfo::setTagPosition(ElementPosition tagPosition)
|
||||||
{
|
{
|
||||||
m_tagPosition = tagPosition;
|
m_tagPosition = tagPosition;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +524,46 @@ inline void MediaFileInfo::setForceTagPosition(bool forceTagPosition)
|
||||||
m_forceTagPosition = forceTagPosition;
|
m_forceTagPosition = forceTagPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the position (in the output file) where the index is written when applying changes.
|
||||||
|
* \sa setIndexPosition()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
inline ElementPosition MediaFileInfo::indexPosition() const
|
||||||
|
{
|
||||||
|
return m_indexPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the position (in the output file) where the index is written when applying changes.
|
||||||
|
* \remarks Same rules as for tagPosition() apply. If conflicting with tagPosition(), tagPosition() has priority.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
inline void MediaFileInfo::setIndexPosition(ElementPosition indexPosition)
|
||||||
|
{
|
||||||
|
m_indexPosition = indexPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns whether indexPosition() is forced.
|
||||||
|
* \sa setForceIndexPosition()
|
||||||
|
* \sa indexPosition(), setIndexPosition()
|
||||||
|
*/
|
||||||
|
inline bool MediaFileInfo::forceIndexPosition() const
|
||||||
|
{
|
||||||
|
return m_forceIndexPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets whether indexPosition() is forced.
|
||||||
|
* \sa forceIndexPosition()
|
||||||
|
* \sa indexPosition(), setIndexPosition()
|
||||||
|
*/
|
||||||
|
inline void MediaFileInfo::setForceIndexPosition(bool forceIndexPosition)
|
||||||
|
{
|
||||||
|
m_forceIndexPosition = forceIndexPosition;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MEDIAINFO_H
|
#endif // MEDIAINFO_H
|
||||||
|
|
|
@ -246,7 +246,7 @@ void Mp4Container::internalMakeFile()
|
||||||
vector<int64> newMdatOffsets; // used when simply copying mdat
|
vector<int64> newMdatOffsets; // used when simply copying mdat
|
||||||
auto trackCount = tracks().size();
|
auto trackCount = tracks().size();
|
||||||
for(byte pass = 0; pass != 2; ++pass) {
|
for(byte pass = 0; pass != 2; ++pass) {
|
||||||
if(fileInfo().tagPosition() == (pass ? TagPosition::AfterData : TagPosition::BeforeData)) {
|
if(fileInfo().tagPosition() == (pass ? ElementPosition::AfterData : ElementPosition::BeforeData)) {
|
||||||
// write "moov"-atom (contains track and tag information)
|
// write "moov"-atom (contains track and tag information)
|
||||||
ostream::pos_type newMoovOffset = outputStream.tellp();
|
ostream::pos_type newMoovOffset = outputStream.tellp();
|
||||||
Mp4Atom *udtaAtom = nullptr;
|
Mp4Atom *udtaAtom = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue