Allow custom writing application
This commit is contained in:
parent
3e85eba00f
commit
cbb54d5aeb
|
@ -33,10 +33,6 @@ using namespace ChronoUtilities;
|
||||||
|
|
||||||
namespace TagParser {
|
namespace TagParser {
|
||||||
|
|
||||||
constexpr const char appInfo[] = APP_NAME " v" APP_VERSION;
|
|
||||||
constexpr uint64 appInfoElementDataSize = sizeof(appInfo) - 1;
|
|
||||||
constexpr uint64 appInfoElementTotalSize = 2 + 1 + appInfoElementDataSize;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class Media::MatroskaContainer
|
* \class Media::MatroskaContainer
|
||||||
* \brief Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
|
* \brief Implementation of GenericContainer<MediaFileInfo, MatroskaTag, MatroskaTrack, EbmlElement>.
|
||||||
|
@ -931,6 +927,16 @@ void MatroskaContainer::internalMakeFile(Diagnostics &diag, AbortableProgressFee
|
||||||
ebmlHeaderDataSize += EbmlElement::calculateSizeDenotationLength(m_doctype.size());
|
ebmlHeaderDataSize += EbmlElement::calculateSizeDenotationLength(m_doctype.size());
|
||||||
const uint64 ebmlHeaderSize = 4 + EbmlElement::calculateSizeDenotationLength(ebmlHeaderDataSize) + ebmlHeaderDataSize;
|
const uint64 ebmlHeaderSize = 4 + EbmlElement::calculateSizeDenotationLength(ebmlHeaderDataSize) + ebmlHeaderDataSize;
|
||||||
|
|
||||||
|
// calculate size of "WritingLib"-element
|
||||||
|
constexpr const char muxingAppName[] = APP_NAME " v" APP_VERSION;
|
||||||
|
constexpr uint64 muxingAppElementDataSize = sizeof(muxingAppName) - 1;
|
||||||
|
constexpr uint64 muxingAppElementTotalSize = 2 + 1 + muxingAppElementDataSize;
|
||||||
|
|
||||||
|
// calculate size of "WritingApp"-element
|
||||||
|
const uint64 writingAppElementDataSize
|
||||||
|
= fileInfo().writingApplication().empty() ? muxingAppElementDataSize : fileInfo().writingApplication().size() - 1;
|
||||||
|
const uint64 writingAppElementTotalSize = 2 + 1 + writingAppElementDataSize;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// calculate size of "Tags"-element
|
// calculate size of "Tags"-element
|
||||||
for (auto &tag : tags()) {
|
for (auto &tag : tags()) {
|
||||||
|
@ -1103,7 +1109,7 @@ void MatroskaContainer::internalMakeFile(Diagnostics &diag, AbortableProgressFee
|
||||||
} else {
|
} else {
|
||||||
// add size of "SegmentInfo"-element
|
// add size of "SegmentInfo"-element
|
||||||
// -> size of "MuxingApp"- and "WritingApp"-element
|
// -> size of "MuxingApp"- and "WritingApp"-element
|
||||||
segment.infoDataSize = 2 * appInfoElementTotalSize;
|
segment.infoDataSize = muxingAppElementTotalSize + writingAppElementTotalSize;
|
||||||
// -> add size of "Title"-element
|
// -> add size of "Title"-element
|
||||||
if (segmentIndex < m_titles.size()) {
|
if (segmentIndex < m_titles.size()) {
|
||||||
const auto &title = m_titles[segmentIndex];
|
const auto &title = m_titles[segmentIndex];
|
||||||
|
@ -1617,8 +1623,9 @@ void MatroskaContainer::internalMakeFile(Diagnostics &diag, AbortableProgressFee
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -> write "MuxingApp"- and "WritingApp"-element
|
// -> write "MuxingApp"- and "WritingApp"-element
|
||||||
EbmlElement::makeSimpleElement(outputStream, MatroskaIds::MuxingApp, appInfo, appInfoElementDataSize);
|
EbmlElement::makeSimpleElement(outputStream, MatroskaIds::MuxingApp, muxingAppName, muxingAppElementDataSize);
|
||||||
EbmlElement::makeSimpleElement(outputStream, MatroskaIds::WrittingApp, appInfo, appInfoElementDataSize);
|
EbmlElement::makeSimpleElement(outputStream, MatroskaIds::WrittingApp,
|
||||||
|
fileInfo().writingApplication().empty() ? muxingAppName : fileInfo().writingApplication().data(), writingAppElementDataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write "Tracks"-element
|
// write "Tracks"-element
|
||||||
|
|
|
@ -122,6 +122,9 @@ public:
|
||||||
// methods to get, set object behaviour
|
// methods to get, set object behaviour
|
||||||
const std::string &saveFilePath() const;
|
const std::string &saveFilePath() const;
|
||||||
void setSaveFilePath(const std::string &saveFilePath);
|
void setSaveFilePath(const std::string &saveFilePath);
|
||||||
|
const std::string writingApplication() const;
|
||||||
|
void setWritingApplication(const std::string &writingApplication);
|
||||||
|
void setWritingApplication(const char *writingApplication);
|
||||||
bool isForcingFullParse() const;
|
bool isForcingFullParse() const;
|
||||||
void setForceFullParse(bool forceFullParse);
|
void setForceFullParse(bool forceFullParse);
|
||||||
bool isForcingRewrite() const;
|
bool isForcingRewrite() const;
|
||||||
|
@ -174,6 +177,7 @@ private:
|
||||||
|
|
||||||
// fields specifying object behaviour
|
// fields specifying object behaviour
|
||||||
std::string m_saveFilePath;
|
std::string m_saveFilePath;
|
||||||
|
std::string m_writingApplication;
|
||||||
size_t m_minPadding;
|
size_t m_minPadding;
|
||||||
size_t m_maxPadding;
|
size_t m_maxPadding;
|
||||||
size_t m_preferredPadding;
|
size_t m_preferredPadding;
|
||||||
|
@ -363,6 +367,34 @@ inline void MediaFileInfo::setSaveFilePath(const std::string &saveFilePath)
|
||||||
m_saveFilePath = saveFilePath;
|
m_saveFilePath = saveFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the writing application as container-level meta-data.
|
||||||
|
* \remarks This is not read from the file when parsing and only used when saving changes.
|
||||||
|
* \sa setWritingApplication() for more details
|
||||||
|
*/
|
||||||
|
inline const std::string MediaFileInfo::writingApplication() const
|
||||||
|
{
|
||||||
|
return m_writingApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the writing application as container-level meta-data. Put the name of your application here.
|
||||||
|
* \remarks Might not be used (depends on the format).
|
||||||
|
*/
|
||||||
|
inline void MediaFileInfo::setWritingApplication(const std::string &writingApplication)
|
||||||
|
{
|
||||||
|
m_writingApplication = writingApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the writing application as container-level meta-data. Put the name of your application here.
|
||||||
|
* \remarks Might not be used (depends on the format).
|
||||||
|
*/
|
||||||
|
inline void MediaFileInfo::setWritingApplication(const char *writingApplication)
|
||||||
|
{
|
||||||
|
m_writingApplication = writingApplication;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns the container for the current file.
|
* \brief Returns the container for the current file.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue