Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to the ShouldWrite API to select which elements to write #122

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions matroska/KaxBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class MATROSKA_DLL_API KaxInternalBlock : public EbmlBinary {
/*!
\note override this function to generate the Data/Size on the fly, unlike the usual binary elements
*/
filepos_t UpdateSize(bool bSaveDefault = false, bool bForceRender = false) override;
filepos_t UpdateSize(ShouldWrite writeFilter = WriteSkipDefault, bool bForceRender = false) override;
filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;

/*!
Expand Down Expand Up @@ -264,7 +264,7 @@ class MATROSKA_DLL_API KaxInternalBlock : public EbmlBinary {
bool bIsKeyframe{true};
bool bIsDiscardable{false};

filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault = false) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter = WriteSkipDefault) override;
};

class MATROSKA_DLL_API KaxBlock : public KaxInternalBlock {
Expand Down Expand Up @@ -334,11 +334,11 @@ DECLARE_MKX_BINARY_CONS(KaxBlockVirtual)
/*!
\note override this function to generate the Data/Size on the fly, unlike the usual binary elements
*/
filepos_t UpdateSize(bool bSaveDefault = false, bool bForceRender = false) override;
filepos_t UpdateSize(ShouldWrite writeFilter = WriteSkipDefault, bool bForceRender = false) override;

void SetParent(const KaxCluster & aParentCluster) {ParentCluster = &aParentCluster;}

filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;

filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;

Expand Down
2 changes: 1 addition & 1 deletion matroska/KaxBlockData.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DECLARE_MKX_SINTEGER_CONS(KaxReferenceBlock)
/*!
\brief override this method to compute the timecode value
*/
filepos_t UpdateSize(bool bSaveDefault = false, bool bForceRender = false) override;
filepos_t UpdateSize(ShouldWrite writeFilter = WriteSkipDefault, bool bForceRender = false) override;

const KaxBlockBlob & RefBlock() const;
void SetReferencedBlock(const KaxBlockBlob * aRefdBlock);
Expand Down
2 changes: 1 addition & 1 deletion matroska/KaxCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DECLARE_MKX_MASTER_CONS(KaxCluster)
/*!
\brief Render the data to the stream and retrieve the position of BlockGroups for later cue entries
*/
filepos_t Render(IOCallback & output, KaxCues & CueToUpdate, bool bSaveDefault = false);
filepos_t Render(IOCallback & output, KaxCues & CueToUpdate, ShouldWrite writeFilter = WriteSkipDefault);

/*!
\return the global timecode of this Cluster
Expand Down
4 changes: 2 additions & 2 deletions matroska/KaxCues.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ DECLARE_MKX_MASTER(KaxCues)
/*!
\brief override to sort by timecode/track
*/
filepos_t Render(IOCallback & output, bool bSaveDefault = false) {
filepos_t Render(IOCallback & output, ShouldWrite writeFilter = WriteSkipDefault) {
Sort();
return EbmlMaster::Render(output, bSaveDefault);
return EbmlMaster::Render(output, writeFilter);
}

std::uint64_t GetTimecodePosition(std::uint64_t aTimecode) const;
Expand Down
90 changes: 45 additions & 45 deletions matroska/KaxSemantic.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ DECLARE_MKX_UINTEGER(KaxClusterTimecode)

DECLARE_MKX_MASTER(KaxClusterSilentTracks)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxClusterSilentTrackNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxClusterPosition)
Expand Down Expand Up @@ -133,7 +133,7 @@ DECLARE_MKX_UINTEGER(KaxReferencePriority)

DECLARE_MKX_SINTEGER(KaxReferenceVirtual)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxCodecState)
Expand All @@ -144,57 +144,57 @@ DECLARE_MKX_SINTEGER(KaxDiscardPadding)

DECLARE_MKX_MASTER(KaxSlices)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxTimeSlice)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceLaceNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceFrameNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceBlockAddID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceDelay)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxSliceDuration)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxReferenceFrame)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxReferenceOffset)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxReferenceTimeCode)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxEncryptedBlock)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxTracks)
Expand Down Expand Up @@ -238,12 +238,12 @@ DECLARE_MKX_UINTEGER(KaxTrackFlagLacing)

DECLARE_MKX_UINTEGER(KaxTrackMinCache)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrackMaxCache)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrackDefaultDuration)
Expand All @@ -254,12 +254,12 @@ DECLARE_MKX_UINTEGER(KaxTrackDefaultDecodedFieldDuration)

DECLARE_MKX_FLOAT(KaxTrackTimecodeScale)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_SINTEGER(KaxTrackOffset)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxMaxBlockAdditionID)
Expand Down Expand Up @@ -300,27 +300,27 @@ DECLARE_MKX_UNISTRING(KaxCodecName)

DECLARE_MKX_UINTEGER(KaxTrackAttachmentLink)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UNISTRING(KaxCodecSettings)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_STRING(KaxCodecInfoURL)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_STRING(KaxCodecDownloadURL)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCodecDecodeAll)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrackOverlay)
Expand Down Expand Up @@ -361,7 +361,7 @@ DECLARE_MKX_UINTEGER(KaxVideoAlphaMode)

DECLARE_MKX_UINTEGER(KaxOldStereoMode)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxVideoPixelWidth)
Expand Down Expand Up @@ -393,7 +393,7 @@ DECLARE_MKX_UINTEGER(KaxVideoDisplayUnit)

DECLARE_MKX_UINTEGER(KaxVideoAspectRatio)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxVideoColourSpace)
Expand All @@ -403,12 +403,12 @@ DECLARE_MKX_BINARY (KaxVideoColourSpace)

DECLARE_MKX_FLOAT(KaxVideoGamma)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_FLOAT(KaxVideoFrameRate)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxVideoColour)
Expand Down Expand Up @@ -518,7 +518,7 @@ DECLARE_MKX_UINTEGER(KaxAudioChannels)

DECLARE_MKX_BINARY (KaxAudioPosition)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxAudioBitDepth)
Expand Down Expand Up @@ -550,28 +550,28 @@ DECLARE_MKX_UINTEGER(KaxTrackJoinUID)

DECLARE_MKX_UINTEGER(KaxTrickTrackUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxTrickTrackSegmentUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
bool ValidateSize() const override {return IsFiniteSize() && GetSize() == 16;}
};

DECLARE_MKX_UINTEGER(KaxTrickTrackFlag)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxTrickMasterTrackUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxTrickMasterTrackSegmentUID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
bool ValidateSize() const override {return IsFiniteSize() && GetSize() == 16;}
};

Expand Down Expand Up @@ -616,22 +616,22 @@ DECLARE_MKX_UINTEGER(KaxAESSettingsCipherMode)

DECLARE_MKX_BINARY (KaxContentSignature)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_BINARY (KaxContentSigKeyID)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxContentSigAlgo)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxContentSigHashAlgo)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCueTime)
Expand Down Expand Up @@ -660,17 +660,17 @@ DECLARE_MKX_UINTEGER(KaxCueRefTime)

DECLARE_MKX_UINTEGER(KaxCueRefCluster)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCueRefNumber)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxCueRefCodecState)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxAttachments)
Expand All @@ -696,17 +696,17 @@ DECLARE_MKX_UINTEGER(KaxFileUID)

DECLARE_MKX_BINARY (KaxFileReferral)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxFileUsedStartTime)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UINTEGER(KaxFileUsedEndTime)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_MASTER(KaxChapters)
Expand Down Expand Up @@ -854,7 +854,7 @@ DECLARE_MKX_UINTEGER(KaxTagDefault)

DECLARE_MKX_UINTEGER(KaxTagDefaultBogus)
public:
filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override;
filepos_t RenderData(IOCallback & output, bool bForceRender, ShouldWrite writeFilter) override;
};

DECLARE_MKX_UNISTRING(KaxTagString)
Expand Down Expand Up @@ -1180,7 +1180,7 @@ typedef enum {
*Indicate what type of content the ChapterAtom contains and might be skipped. It can be used to automatically skip content based on the type.
If a `ChapterAtom` is inside a `ChapterAtom` that has a `ChapterSkipType` set, it **MUST NOT** have a `ChapterSkipType` or have a `ChapterSkipType` with the same value as it's parent `ChapterAtom`.
If the `ChapterAtom` doesn't contain a `ChapterTimeEnd`, the value of the `ChapterSkipType` is only valid until the next `ChapterAtom` with a `ChapterSkipType` value or the end of the file.

*/
typedef enum {
MATROSKA_CHAPTERSKIPTYPE_NO_SKIPPING = 0, // Content which should not be skipped.
Expand Down
Loading