From: Alexey K. <akh...@us...> - 2007-01-10 20:13:17
|
Update of /cvsroot/aaf/AAF/ref-impl/src/OM In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv25586 Modified Files: OMKLVStoredStream.cpp Log Message: Add KLV helper functions. Index: OMKLVStoredStream.cpp =================================================================== RCS file: /cvsroot/aaf/AAF/ref-impl/src/OM/OMKLVStoredStream.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** OMKLVStoredStream.cpp 31 May 2006 17:41:57 -0000 1.36 --- OMKLVStoredStream.cpp 10 Jan 2007 20:13:11 -0000 1.37 *************** *** 242,243 **** --- 242,292 ---- return result; } + + void OMKLVStoredStream::writeKLVKey(OMStoredStream& stream, + const OMKLVKey& key) + { + TRACE("OMKLVStoredStream::writeKLVKey"); + + OMUInt32 x; + const OMByte* src = reinterpret_cast<const OMByte*>(&key); + stream.write(src, sizeof(OMKLVKey), x); + + POSTCONDITION("All bytes written", x == sizeof(OMKLVKey)); + } + + void OMKLVStoredStream::writeKLVLength(OMStoredStream& stream, + const OMUInt64& length) + { + TRACE("OMKLVStoredStream::writeKLVLength"); + + OMByte buffer[sizeof(OMUInt64) + 1]; // Max + + OMMXFStorage::berEncode(buffer, sizeof(buffer), sizeof(OMUInt64), length); + OMUInt32 x; + stream.write(buffer, sizeof(OMUInt64) + 1, x); + + POSTCONDITION("All bytes written", x == (sizeof(OMUInt64) + 1)); + } + + OMUInt64 OMKLVStoredStream::reserveKLVLength(OMStoredStream& stream) + { + TRACE("OMKLVStoredStream::reserveKLVLength"); + // Bah ! should reuse code in OMMXFStorage - tjb + OMUInt64 lengthPosition = stream.position(); + OMUInt64 length = 0; + writeKLVLength(stream, length); // must be fixed up later + return lengthPosition; + } + + void OMKLVStoredStream::fixupKLVLength(OMStoredStream& stream, + const OMUInt64 lengthPosition) + { + TRACE("OMKLVStoredStream::fixupKLVLength"); + // Bah ! should reuse code in OMMXFStorage - tjb + OMUInt64 endPosition = stream.position(); + ASSERT("Proper position", endPosition >= (lengthPosition + 8 + 1)); + OMUInt64 length = endPosition - (lengthPosition + 8 + 1); + stream.setPosition(lengthPosition); + writeKLVLength(stream, length); + stream.setPosition(endPosition); + } |