X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2FAS_DCP_internal.h;h=ed9eec7e92dbd9d0878ba1bd60a942475a3beca1;hb=ba95e2de6e57669359dd72adedaf756a218437fa;hp=15890a77917f6f82adb79a906976d7a8d2727e99;hpb=30d642bd3b8474744dfbdcc2bdc46cdf827102c4;p=asdcplib.git diff --git a/src/AS_DCP_internal.h b/src/AS_DCP_internal.h index 15890a7..ed9eec7 100755 --- a/src/AS_DCP_internal.h +++ b/src/AS_DCP_internal.h @@ -29,14 +29,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \brief AS-DCP library, non-public common elements */ -#ifndef _AS_DCP_INTERNAL_H__ -#define _AS_DCP_INTERNAL_H__ +#ifndef _AS_DCP_INTERNAL_H_ +#define _AS_DCP_INTERNAL_H_ -#include "AS_DCP_system.h" +#include +#include +#include #include "Metadata.h" -#include "hex_utils.h" -using namespace std; +using Kumu::DefaultLogSink; +// using namespace std; using namespace ASDCP; using namespace ASDCP::MXF; @@ -45,7 +47,6 @@ using namespace ASDCP::MXF; namespace ASDCP { // constant values used to calculate KLV and EKLV packet sizes - static const ui32_t klv_cryptinfo_size = MXF_BER_LENGTH + UUIDlen /* ContextID */ @@ -75,17 +76,6 @@ namespace ASDCP return plaintext_offset + block_size + (CBC_BLOCK_SIZE * 3); } - // Interop labels - - static byte_t OPAtom_Data[SMPTE_UL_LENGTH] = - { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01, - 0x0d, 0x01, 0x02, 0x01, 0x10, 0x00, 0x00, 0x00 }; - static UL OPAtomUL(OPAtom_Data); - - static const byte_t CryptEssenceUL_Data[SMPTE_UL_LENGTH] = - { 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x04, 0x01, 0x07, - 0x0d, 0x01, 0x03, 0x01, 0x02, 0x7e, 0x01, 0x00 }; - // the check value for EKLV packets // CHUKCHUKCHUKCHUK static const byte_t ESV_CheckValue[CBC_BLOCK_SIZE] = @@ -100,28 +90,51 @@ namespace ASDCP Result_t EncryptFrameBuffer(const ASDCP::FrameBuffer&, ASDCP::FrameBuffer&, AESEncContext*); Result_t DecryptFrameBuffer(const ASDCP::FrameBuffer&, ASDCP::FrameBuffer&, AESDecContext*); + // + class KLReader : public ASDCP::KLVPacket + { + ASDCP_NO_COPY_CONSTRUCT(KLReader); + byte_t m_KeyBuf[SMPTE_UL_LENGTH*2]; + + public: + KLReader() {} + ~KLReader() {} + + inline const byte_t* Key() { return m_KeyBuf; } + inline const ui64_t Length() { return m_ValueLength; } + inline const ui64_t KLLength() { return m_KLLength; } + + Result_t ReadKLFromFile(Kumu::FileReader& Reader); + }; + // class h__Reader { ASDCP_NO_COPY_CONSTRUCT(h__Reader); public: - FileReader m_File; + Kumu::FileReader m_File; OPAtomHeader m_HeaderPart; Partition m_BodyPart; OPAtomIndexFooter m_FooterPart; ui64_t m_EssenceStart; WriterInfo m_Info; ASDCP::FrameBuffer m_CtFrameBuf; - fpos_t m_LastPosition; + Kumu::fpos_t m_LastPosition; h__Reader(); virtual ~h__Reader(); - Result_t InitInfo(WriterInfo& Info); + Result_t InitInfo(); Result_t OpenMXFRead(const char* filename); Result_t InitMXFIndex(); - Result_t ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf, + + // positions file before reading + Result_t ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf, + const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC); + + // reads from current position + Result_t ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::FrameBuffer& FrameBuf, const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC); void Close(); }; @@ -162,13 +175,15 @@ namespace ASDCP inline Result_t Goto_FINAL() { Goto_body(ST_RUNNING, ST_FINAL); } }; + typedef std::list DurationElementList_t; + // class h__Writer { ASDCP_NO_COPY_CONSTRUCT(h__Writer); public: - FileWriter m_File; + Kumu::FileWriter m_File; ui32_t m_HeaderSize; OPAtomHeader m_HeaderPart; Partition m_BodyPart; @@ -176,28 +191,32 @@ namespace ASDCP ui64_t m_EssenceStart; MaterialPackage* m_MaterialPackage; - Sequence* m_MPTCSequence; - TimecodeComponent* m_MPTimecode; - Sequence* m_MPClSequence; - SourceClip* m_MPClip; //! Material Package SourceClip for each essence stream - SourcePackage* m_FilePackage; - Sequence* m_FPTCSequence; - TimecodeComponent* m_FPTimecode; - Sequence* m_FPClSequence; - SourceClip* m_FPClip; //! File Package SourceClip for each essence stream FileDescriptor* m_EssenceDescriptor; + std::list 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; h__Writer(); virtual ~h__Writer(); + void InitHeader(); + void AddSourceClip(const MXF::Rational& EditRate, ui32_t TCFrameRate, + const std::string& TrackName, const UL& DataDefinition, + const std::string& PackageLabel); + void AddDMSegment(const MXF::Rational& EditRate, ui32_t TCFrameRate, + const std::string& TrackName, const UL& DataDefinition, + const std::string& PackageLabel); + void AddEssenceDescriptor(const UL& WrappingUL); + Result_t CreateBodyPart(const MXF::Rational& EditRate, ui32_t BytesPerEditUnit = 0); + + // all the above for a single source clip Result_t WriteMXFHeader(const std::string& PackageLabel, const UL& WrappingUL, const std::string& TrackName, const UL& DataDefinition, const MXF::Rational& EditRate, @@ -228,29 +247,10 @@ namespace ASDCP Result_t TestValues(const ASDCP::FrameBuffer&, byte_t* AssetID, ui32_t sequence, HMACContext* HMAC); }; - // - class KLVReader - { - byte_t m_Key[32]; - ui64_t m_Length; - ui32_t m_BERLength; - ui32_t m_HeaderLength; - - ASDCP_NO_COPY_CONSTRUCT(KLVReader); - - public: - KLVReader() : m_Length(0), m_BERLength(0), m_HeaderLength(0) {} - ~KLVReader() {} - - inline const byte_t* Key() { return m_Key; } - inline const ui64_t Length() { return m_Length; } - inline const ui64_t KLLength() { return m_BERLength + SMPTE_UL_LENGTH; } - Result_t ReadKLFromFile(ASDCP::FileReader& Reader); - }; } // namespace ASDCP -#endif // _AS_DCP_INTERNAL_H__ +#endif // _AS_DCP_INTERNAL_H_ //