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();
55 class AS02IndexWriter : public ASDCP::MXF::Partition
57 ASDCP::MXF::IndexTableSegment* m_CurrentSegment;
58 ui32_t m_BytesPerEditUnit;
59 ASDCP::MXF::Rational m_EditRate;
61 KM_NO_COPY_CONSTRUCT(AS02IndexWriter);
65 const ASDCP::Dictionary*& m_Dict;
66 Kumu::fpos_t m_ECOffset;
67 ASDCP::IPrimerLookup* m_Lookup;
69 AS02IndexWriter(const ASDCP::Dictionary*&);
70 virtual ~AS02IndexWriter();
72 Result_t WriteToFile(Kumu::FileWriter& Writer);
73 void ResetCBR(Kumu::fpos_t offset);
76 ui32_t GetDuration() const;
77 void PushIndexEntry(const ASDCP::MXF::IndexTableSegment::IndexEntry&);
78 void SetIndexParamsCBR(ASDCP::IPrimerLookup* lookup, ui32_t size, const ASDCP::Rational& Rate);
79 void SetIndexParamsVBR(ASDCP::IPrimerLookup* lookup, const ASDCP::Rational& Rate, Kumu::fpos_t offset);
83 class h__AS02Reader : public ASDCP::MXF::TrackFileReader<ASDCP::MXF::OP1aHeader, AS_02::MXF::AS02IndexReader>
85 ASDCP_NO_COPY_CONSTRUCT(h__AS02Reader);
89 // Partition *m_pCurrentBodyPartition;
90 // ui64_t m_EssenceStart;
91 // std::vector<Partition*> m_BodyPartList;
92 // ui32_t m_start_pos;
94 h__AS02Reader(const ASDCP::Dictionary&);
95 virtual ~h__AS02Reader();
97 Result_t OpenMXFRead(const char* filename);
99 Result_t ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
100 const byte_t* EssenceUL, ASDCP::AESDecContext* Ctx, ASDCP::HMACContext* HMAC);
102 Result_t LocateFrame(ui32_t FrameNum, Kumu::fpos_t& streamOffset, i8_t& temporalOffset, i8_t& keyFrameOffset);
106 class h__AS02Writer : public ASDCP::MXF::TrackFileWriter<ASDCP::MXF::OP1aHeader>
108 ASDCP_NO_COPY_CONSTRUCT(h__AS02Writer);
112 AS02IndexWriter m_IndexWriter;
113 ui32_t m_PartitionSpace; // edit units per partition
114 IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip
116 h__AS02Writer(const Dictionary&);
117 virtual ~h__AS02Writer();
119 // all the above for a single source clip
120 Result_t WriteAS02Header(const std::string& PackageLabel, const ASDCP::UL& WrappingUL,
121 const std::string& TrackName, const ASDCP::UL& EssenceUL,
122 const ASDCP::UL& DataDefinition, const ASDCP::Rational& EditRate,
123 ui32_t TCFrameRate, ui32_t BytesPerEditUnit = 0);
125 Result_t WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf,const byte_t* EssenceUL,
126 AESEncContext* Ctx, HMACContext* HMAC);
128 Result_t WriteAS02Footer();
133 #endif // _AS_02_INTERNAL_H_
136 // end AS_02_internal.h