2 Copyright (c) 2011-2013, Robert Scheler, Heiko Sparenberg Fraunhofer IIS, John Hurst
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 /*! \file AS_02_internal.h
28 \version $Id: AS_02_internal.h ***
29 \brief AS-02 library, non-public common elements
32 #ifndef _AS_02_INTERNAL_H_
33 #define _AS_02_INTERNAL_H_
36 #include "AS_DCP_internal.h"
39 using Kumu::DefaultLogSink;
41 #ifdef DEFAULT_MD_DECL
42 AS_02::MXF::AS02IndexReader *g_AS02IndexReader;
44 extern AS_02::MXF::AS02IndexReader *g_AS02IndexReader;
51 void default_md_object_init();
53 static void CalculateIndexPartitionSize(ui32_t& size,ui32_t numberOfIndexEntries)
55 if(numberOfIndexEntries){
56 //Partition::ArchiveSize(); HeaderSize = 124 bytes
58 //ItemSize IndexEntry = 11 bytes
59 //number of IndexEntries - parameter
60 //IndexEntryArray = 12 bytes
61 //size for other Elements(PosTableCount etc.) = 108 bytes
62 //see Index.cpp ASDCP::MXF::IndexTableSegment::WriteToTLVSet(TLVWriter& TLVSet) how this is computed
63 size = 124 + 20 + 11 * numberOfIndexEntries + 12 +108;
64 size += 20;//because maybe we must fill the last partition, minimum required space for KLV-Item
67 //Partition HeaderSize = 124 bytes
69 //244 for 2 IndexTableSegments
70 size = 124 + 20 + 244;
75 class h__AS02Reader : public ASDCP::MXF::TrackFileReader<ASDCP::MXF::OP1aHeader, AS_02::MXF::AS02IndexReader>
77 ASDCP_NO_COPY_CONSTRUCT(h__AS02Reader);
81 Partition *m_pCurrentBodyPartition;
82 AS_02::MXF::OP1aIndexBodyPartion* m_pCurrentIndexPartition;
83 ui64_t m_EssenceStart;
84 std::vector<Partition*> m_BodyPartList;
86 ui32_t m_PartitionSpace;
87 IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip
89 h__AS02Reader(const ASDCP::Dictionary&);
90 virtual ~h__AS02Reader();
92 Result_t OpenMXFRead(const char* filename);
93 Result_t ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
94 const byte_t* EssenceUL, ASDCP::AESDecContext* Ctx, ASDCP::HMACContext* HMAC);
95 Result_t LocateFrame(ui32_t FrameNum, Kumu::fpos_t& streamOffset,
96 i8_t& temporalOffset, i8_t& keyFrameOffset);
101 class h__AS02Writer : public ASDCP::MXF::TrackFileWriter<ASDCP::MXF::OP1aHeader>
103 ASDCP_NO_COPY_CONSTRUCT(h__AS02Writer);
107 AS_02::MXF::OP1aIndexBodyPartion* m_CurrentIndexBodyPartition;
109 ui32_t m_PartitionSpace;
110 IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip
111 std::vector<Partition*> m_BodyPartList;
113 h__AS02Writer(const Dictionary&);
114 virtual ~h__AS02Writer();
116 // all the above for a single source clip
117 Result_t WriteAS02Header(const std::string& PackageLabel, const ASDCP::UL& WrappingUL,
118 const std::string& TrackName, const ASDCP::UL& EssenceUL,
119 const ASDCP::UL& DataDefinition, const ASDCP::Rational& EditRate,
120 ui32_t TCFrameRate, ui32_t BytesPerEditUnit = 0);
122 Result_t CreateBodyPart(const ASDCP::MXF::Rational& EditRate, ui32_t BytesPerEditUnit);
123 Result_t CreateBodyPartPair();
124 Result_t CompleteIndexBodyPart();
126 Result_t WriteAS02Footer();
131 #endif // _AS_02_INTERNAL_H_
134 // end AS_02_internal.h