/* Copyright (c) 2005-2012, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*! \file MXF.h \version $Id: MXF.h,v 1.42 2012/03/05 13:11:47 jhurst Exp $ \brief MXF objects */ #ifndef _MXF_H_ #define _MXF_H_ #include "MXFTypes.h" namespace ASDCP { namespace MXF { class InterchangeObject; // typedef ASDCP::MXF::InterchangeObject* (*MXFObjectFactory_t)(const Dictionary*&); // void SetObjectFactory(UL label, MXFObjectFactory_t factory); // InterchangeObject* CreateObject(const Dictionary*& Dict, const UL& label); // seek an open file handle to the start of the RIP KLV packet Result_t SeekToRIP(const Kumu::FileReader&); // class RIP : public ASDCP::KLVFilePacket { ASDCP_NO_COPY_CONSTRUCT(RIP); RIP(); public: // class Pair : public Kumu::IArchive { public: ui32_t BodySID; ui64_t ByteOffset; Pair() : BodySID(0), ByteOffset(0) {} Pair(ui32_t sid, ui64_t offset) : BodySID(sid), ByteOffset(offset) {} virtual ~Pair() {} ui32_t Size() { return sizeof(ui32_t) + sizeof(ui64_t); } inline const char* EncodeString(char* str_buf, ui32_t buf_len) const { Kumu::ui64Printer offset_str(ByteOffset); snprintf(str_buf, buf_len, "%-6u: %s", BodySID, offset_str.c_str()); return str_buf; } inline bool HasValue() const { return true; } inline ui32_t ArchiveLength() const { return sizeof(ui32_t) + sizeof(ui64_t); } inline bool Unarchive(Kumu::MemIOReader* Reader) { if ( ! Reader->ReadUi32BE(&BodySID) ) return false; if ( ! Reader->ReadUi64BE(&ByteOffset) ) return false; return true; } inline bool Archive(Kumu::MemIOWriter* Writer) const { if ( ! Writer->WriteUi32BE(BodySID) ) return false; if ( ! Writer->WriteUi64BE(ByteOffset) ) return false; return true; } }; const Dictionary*& m_Dict; Array PairArray; RIP(const Dictionary*& d) : m_Dict(d) {} virtual ~RIP() {} virtual Result_t InitFromFile(const Kumu::FileReader& Reader); virtual Result_t WriteToFile(Kumu::FileWriter& Writer); virtual Result_t GetPairBySID(ui32_t, Pair&) const; virtual void Dump(FILE* = 0); }; // class Partition : public ASDCP::KLVFilePacket { ASDCP_NO_COPY_CONSTRUCT(Partition); Partition(); protected: class h__PacketList; mem_ptr m_PacketList; public: const Dictionary*& m_Dict; ui16_t MajorVersion; ui16_t MinorVersion; ui32_t KAGSize; ui64_t ThisPartition; ui64_t PreviousPartition; ui64_t FooterPartition; ui64_t HeaderByteCount; ui64_t IndexByteCount; ui32_t IndexSID; ui64_t BodyOffset; ui32_t BodySID; UL OperationalPattern; Batch