2 Copyright (c) 2011-2012, 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 h__02_Reader.cpp
29 \brief MXF file reader base class
32 #include "AS_02_internal.h"
34 using namespace ASDCP;
35 using namespace ASDCP::MXF;
38 AS_02::h__Reader::h__Reader(const Dictionary& d) :
39 m_HeaderPart(m_Dict), m_FooterPart(m_Dict), m_Dict(&d), m_EssenceStart(0)
41 m_pCurrentIndexPartition = 0;
45 AS_02::h__Reader::~h__Reader()
47 std::vector<Partition*>::iterator bli = m_BodyPartList.begin();
48 for ( ; bli != m_BodyPartList.end(); bli++ ){
56 AS_02::h__Reader::Close()
61 //------------------------------------------------------------------------------------------
66 AS_02::h__Reader::InitInfo()
69 InterchangeObject* Object;
71 UL OPAtomUL(SMPTE_390_OPAtom_Entry().ul);
72 UL Interop_OPAtomUL(MXFInterop_OPAtom_Entry().ul);
73 m_Info.LabelSetType = LS_MXF_SMPTE;
76 Result_t result = m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(Identification), &Object);
78 if( ASDCP_SUCCESS(result) )
79 MD_to_WriterInfo((Identification*)Object, m_Info);
82 if( ASDCP_SUCCESS(result) )
83 result = m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(SourcePackage), &Object);
85 if( ASDCP_SUCCESS(result) )
87 SourcePackage* SP = (SourcePackage*)Object;
88 memcpy(m_Info.AssetUUID, SP->PackageUID.Value() + 16, UUIDlen);
91 // optional CryptographicContext
92 if( ASDCP_SUCCESS(result) )
94 Result_t cr_result = m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(CryptographicContext), &Object);
96 if( ASDCP_SUCCESS(cr_result) )
97 MD_to_CryptoInfo((CryptographicContext*)Object, m_Info, *m_Dict);
103 // standard method of populating the in-memory index
105 AS_02::h__Reader::InitMXFIndex()
107 if ( ! m_File.IsOpen() )
110 Result_t result = m_File.Seek(m_HeaderPart.FooterPartition);
112 if ( ASDCP_SUCCESS(result) )
114 m_FooterPart.m_Lookup = &m_HeaderPart.m_Primer;
115 //Footer don't need to be initialized because there is no index table in the footer
116 //result = m_FooterPart.InitFromFile(m_File);
119 if ( ASDCP_SUCCESS(result) )
120 m_File.Seek(m_EssenceStart);
127 // end h__02_Reader.cpp