diff options
| author | jhurst <jhurst@cinecert.com> | 2013-06-03 00:12:31 +0000 |
|---|---|---|
| committer | jhurst <> | 2013-06-03 00:12:31 +0000 |
| commit | f285ea055151fae2e13d71c2d0282201197a9143 (patch) | |
| tree | 718615ffacefa98c498ec15dd9e373ccb8cba16b /src/AS_02_internal.h | |
| parent | dc0a23dd428b933040c9ff1602f5d35a27cbc8cb (diff) | |
the big-pre-as-02-refactor
Diffstat (limited to 'src/AS_02_internal.h')
| -rw-r--r-- | src/AS_02_internal.h | 186 |
1 files changed, 61 insertions, 125 deletions
diff --git a/src/AS_02_internal.h b/src/AS_02_internal.h index 64fe836..0439ae4 100644 --- a/src/AS_02_internal.h +++ b/src/AS_02_internal.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2011-2012, Robert Scheler, Heiko Sparenberg Fraunhofer IIS, John Hurst + Copyright (c) 2011-2013, Robert Scheler, Heiko Sparenberg Fraunhofer IIS, John Hurst All rights reserved. Redistribution and use in source and binary forms, with or without @@ -32,20 +32,24 @@ #ifndef _AS_02_INTERNAL_H_ #define _AS_02_INTERNAL_H_ -#include "KM_platform.h" -#include "KM_util.h" #include "KM_log.h" -#include "Metadata.h" #include "AS_DCP_internal.h" #include "AS_02.h" using Kumu::DefaultLogSink; -using namespace ASDCP; -using namespace ASDCP::MXF; +#ifdef DEFAULT_MD_DECL +AS_02::MXF::AS02IndexReader *g_AS02IndexReader; +#else +extern AS_02::MXF::AS02IndexReader *g_AS02IndexReader; +#endif + namespace AS_02 { + + void default_md_object_init(); + static void CalculateIndexPartitionSize(ui32_t& size,ui32_t numberOfIndexEntries) { if(numberOfIndexEntries){ @@ -68,127 +72,59 @@ namespace AS_02 } // - class h__Reader - { - ASDCP_NO_COPY_CONSTRUCT(h__Reader); - h__Reader(); - - public: - const Dictionary* m_Dict; - Kumu::FileReader m_File; - OPAtomHeader m_HeaderPart; - //more than one Body-Partition use a list - std::vector<Partition*> m_BodyPartList; - OPAtomIndexFooter m_FooterPart; - ui64_t m_EssenceStart; - WriterInfo m_Info; - ASDCP::FrameBuffer m_CtFrameBuf; - Kumu::fpos_t m_LastPosition; - - IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip - ui32_t m_PartitionSpace; - - ////new elements for AS-02 - Partition* m_pCurrentBodyPartition; - AS_02::MXF::OP1aIndexBodyPartion* m_pCurrentIndexPartition; - ui32_t m_start_pos; - - h__Reader(const Dictionary&); - virtual ~h__Reader(); - - Result_t InitInfo(); - virtual Result_t OpenMXFRead(const char* filename) = 0; - Result_t InitMXFIndex(); - - // positions file before reading - virtual Result_t ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf, - const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC) = 0; - - // reads from current position - virtual Result_t ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::FrameBuffer& FrameBuf, - const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC) = 0; - void Close(); - }; + class h__AS02Reader : public ASDCP::MXF::TrackFileReader<ASDCP::MXF::OP1aHeader, AS_02::MXF::AS02IndexReader> + { + ASDCP_NO_COPY_CONSTRUCT(h__AS02Reader); + h__AS02Reader(); + + public: + Partition *m_pCurrentBodyPartition; + AS_02::MXF::OP1aIndexBodyPartion* m_pCurrentIndexPartition; + ui64_t m_EssenceStart; + std::vector<Partition*> m_BodyPartList; + ui32_t m_start_pos; + ui32_t m_PartitionSpace; + IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip + + h__AS02Reader(const ASDCP::Dictionary&); + virtual ~h__AS02Reader(); + + Result_t OpenMXFRead(const char* filename); + Result_t ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf, + const byte_t* EssenceUL, ASDCP::AESDecContext* Ctx, ASDCP::HMACContext* HMAC); + Result_t LocateFrame(ui32_t FrameNum, Kumu::fpos_t& streamOffset, + i8_t& temporalOffset, i8_t& keyFrameOffset); + + }; // - class h__Writer - { - ASDCP_NO_COPY_CONSTRUCT(h__Writer); - h__Writer(); - - public: - const Dictionary* m_Dict; - Kumu::FileWriter m_File; - ui32_t m_HeaderSize; - OPAtomHeader m_HeaderPart; - //more than one Body-Partition -> use a list of Partitions - std::vector<Partition*> m_BodyPartList; - //we don't use the footer like in the dcps but we need also a footer - AS_02::MXF::OP1aIndexFooter m_FooterPart; - ui64_t m_EssenceStart; - - MaterialPackage* m_MaterialPackage; - SourcePackage* m_FilePackage; - - FileDescriptor* m_EssenceDescriptor; - std::list<InterchangeObject*> m_EssenceSubDescriptorList; - - ui32_t m_FramesWritten; - ui64_t m_StreamOffset; - ASDCP::FrameBuffer m_CtFrameBuf; - h__WriterState m_State; - WriterInfo m_Info; - DurationElementList_t m_DurationUpdateList; - - //new elements for AS-02 - ui64_t m_BodyOffset; - //TODO: Currently not used, delete if not necessary - // Counter values for BodySID and IndexSID - ui32_t m_CurrentBodySID; - ui32_t m_CurrentIndexSID; - //TODO: maybe set this to the lf__Writer class because this is only in JP2K creation necessary - //our computed PartitionSpace - ui32_t m_PartitionSpace; - IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip - - //the EditRate - ASDCP::MXF::Rational m_EditRate; - //the BytesPerEditUnit - ui32_t m_BytesPerEditUnit; - //pointer to the current Body Partition(Index) - AS_02::MXF::OP1aIndexBodyPartion* m_CurrentIndexBodyPartition; - - h__Writer(const Dictionary&); - virtual ~h__Writer(); - - //virtual methods, implementation details for JP2K or PCM are in the MXFWriter::h__Writer classes if they are different - virtual void InitHeader(); - /*virtual*/ void AddSourceClip(const ASDCP::MXF::Rational& EditRate, ui32_t TCFrameRate, - const std::string& TrackName, const UL& EssenceUL, - const UL& DataDefinition, const std::string& PackageLabel); - /*virtual*/ void AddDMSegment(const ASDCP::MXF::Rational& EditRate, ui32_t TCFrameRate, - const std::string& TrackName, const UL& DataDefinition, - const std::string& PackageLabel); - /*virtual*/ void AddEssenceDescriptor(const ASDCP::UL& WrappingUL); - virtual Result_t CreateBodyPart(const ASDCP::MXF::Rational& EditRate, ui32_t BytesPerEditUnit = 0); - - //new method to create BodyPartition for essence and index - virtual Result_t CreateBodyPartPair(); - //new method to finalize BodyPartion(index) - virtual Result_t CompleteIndexBodyPart(); - - // all the above for a single source clip - virtual Result_t WriteMXFHeader(const std::string& PackageLabel, const UL& WrappingUL, - const std::string& TrackName, const UL& EssenceUL, - const UL& DataDefinition, const ASDCP::MXF::Rational& EditRate, - ui32_t TCFrameRate, ui32_t BytesPerEditUnit = 0); - - virtual Result_t WriteEKLVPacket(const ASDCP::FrameBuffer& FrameBuf, - const byte_t* EssenceUL, AESEncContext* Ctx, HMACContext* HMAC); - - virtual Result_t WriteMXFFooter() = 0; - - }; + class h__AS02Writer : public ASDCP::MXF::TrackFileWriter<ASDCP::MXF::OP1aHeader> + { + ASDCP_NO_COPY_CONSTRUCT(h__AS02Writer); + h__AS02Writer(); + + public: + AS_02::MXF::OP1aIndexBodyPartion* m_CurrentIndexBodyPartition; + ui64_t m_BodyOffset; + ui32_t m_PartitionSpace; + IndexStrategy_t m_IndexStrategy; //Shim parameter index_strategy_frame/clip + std::vector<Partition*> m_BodyPartList; + + h__AS02Writer(const Dictionary&); + virtual ~h__AS02Writer(); + + // all the above for a single source clip + Result_t WriteAS02Header(const std::string& PackageLabel, const ASDCP::UL& WrappingUL, + const std::string& TrackName, const ASDCP::UL& EssenceUL, + const ASDCP::UL& DataDefinition, const ASDCP::Rational& EditRate, + ui32_t TCFrameRate, ui32_t BytesPerEditUnit = 0); + + Result_t CreateBodyPart(const ASDCP::MXF::Rational& EditRate, ui32_t BytesPerEditUnit); + Result_t CreateBodyPartPair(); + Result_t CompleteIndexBodyPart(); + + Result_t WriteAS02Footer(); + }; } // namespace AS_02 |
