From 1e37a264f10445ed2ccb33d5daf864c3b0d105e9 Mon Sep 17 00:00:00 2001 From: Tom Finegan Date: Thu, 19 Jan 2012 16:37:11 -0500 Subject: [PATCH] mkvmuxer: Add element start notification. Just before the first byte of an element identifier is written the muxer calls IMkvWriter::ElementStartNotify to report the position of the element in the WebM stream. Change-Id: Iac40090587bd9496b05f41203aace00902f5606e --- mkvmuxer.hpp | 7 +++++++ mkvmuxerutil.cpp | 2 ++ mkvwriter.cpp | 3 +++ mkvwriter.hpp | 1 + 4 files changed, 13 insertions(+) diff --git a/mkvmuxer.hpp b/mkvmuxer.hpp index f42038a..1cb29d8 100644 --- a/mkvmuxer.hpp +++ b/mkvmuxer.hpp @@ -35,6 +35,13 @@ class IMkvWriter { // Returns true if the writer is seekable. virtual bool Seekable() const = 0; + // Element start notification. Called whenever an element identifier is about + // to be written to the stream. |element_id| is the element identifier, and + // |position| is the location in the WebM stream where the first octet of the + // element identifier will be written. + // Note: the |MkvId| enumeration in webmids.hpp defines element values. + virtual void ElementStartNotify(uint64 element_id, int64 position) = 0; + protected: IMkvWriter(); virtual ~IMkvWriter(); diff --git a/mkvmuxerutil.cpp b/mkvmuxerutil.cpp index 3a5739f..2136ff5 100644 --- a/mkvmuxerutil.cpp +++ b/mkvmuxerutil.cpp @@ -213,6 +213,8 @@ int32 WriteID(IMkvWriter* writer, uint64 type) { if (!writer) return -1; + writer->ElementStartNotify(type, writer->Position()); + const int32 size = GetUIntSize(type); return SerializeInt(writer, type, size); diff --git a/mkvwriter.cpp b/mkvwriter.cpp index a71455d..3492141 100644 --- a/mkvwriter.cpp +++ b/mkvwriter.cpp @@ -88,4 +88,7 @@ bool MkvWriter::Seekable() const { return true; } +void MkvWriter::ElementStartNotify(uint64, int64) { +} + } // namespace mkvmuxer diff --git a/mkvwriter.hpp b/mkvwriter.hpp index 6838f03..8bae247 100644 --- a/mkvwriter.hpp +++ b/mkvwriter.hpp @@ -26,6 +26,7 @@ class MkvWriter : public IMkvWriter { virtual int64 Position() const; virtual int32 Position(int64 position); virtual bool Seekable() const; + virtual void ElementStartNotify(uint64 element_id, int64 position); virtual int32 Write(const void* buffer, uint32 length); // Creates and opens a file for writing. |filename| is the name of the file