summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2008-10-06 04:40:02 +0000
committerjhurst <>2008-10-06 04:40:02 +0000
commit34b0ba8aa56c902a013f7ac799e1f64fb31b0a5c (patch)
tree06f2b023c86ee0793862d93fd1fac6e692bcd61d /src
parent94c656e78912129e3cc1afbb991fe4a2ecf8fdde (diff)
new interface for in-memory metadata packets
Diffstat (limited to 'src')
-rwxr-xr-xsrc/AS_DCP_MXF.cpp2
-rw-r--r--src/KM_tai.cpp4
-rwxr-xr-xsrc/MXF.cpp114
-rwxr-xr-xsrc/MXF.h5
4 files changed, 95 insertions, 30 deletions
diff --git a/src/AS_DCP_MXF.cpp b/src/AS_DCP_MXF.cpp
index 6b30da9..8bb084e 100755
--- a/src/AS_DCP_MXF.cpp
+++ b/src/AS_DCP_MXF.cpp
@@ -431,7 +431,7 @@ ASDCP::IntegrityPack::CalcValues(const ASDCP::FrameBuffer& FB, byte_t* AssetID,
byte_t* p = Data;
HMAC->Reset();
- static byte_t ber_4[MXF_BER_LENGTH] = {0x83, 0};
+ static byte_t ber_4[MXF_BER_LENGTH] = {0x83, 0, 0, 0};
// update HMAC with essence data
HMAC->Update(FB.RoData(), FB.Size());
diff --git a/src/KM_tai.cpp b/src/KM_tai.cpp
index 7aa7ada..dca8471 100644
--- a/src/KM_tai.cpp
+++ b/src/KM_tai.cpp
@@ -55,6 +55,7 @@ The libtai source code is in the public domain.
void
caldate_frommjd(Kumu::TAI::caldate* cd, i32_t day)
{
+ assert(cd);
i32_t year, month, yday;
year = day / 146097L;
@@ -101,6 +102,7 @@ static ui32_t montab[12] =
i32_t
caldate_mjd(const Kumu::TAI::caldate* cd)
{
+ assert(cd);
i32_t y, m, d;
d = cd->day - 678882L;
@@ -138,6 +140,7 @@ caldate_mjd(const Kumu::TAI::caldate* cd)
void
caltime_utc(Kumu::TAI::caltime* ct, const Kumu::TAI::tai* t)
{
+ assert(ct&&t);
Kumu::TAI::tai t2 = *t;
ui64_t u;
i32_t s;
@@ -163,6 +166,7 @@ caltime_utc(Kumu::TAI::caltime* ct, const Kumu::TAI::tai* t)
void
caltime_tai(const Kumu::TAI::caltime* ct, Kumu::TAI::tai* t)
{
+ assert(ct&&t);
i32_t day, s;
/* XXX: check for overflow? */
diff --git a/src/MXF.cpp b/src/MXF.cpp
index d01393c..cc09b15 100755
--- a/src/MXF.cpp
+++ b/src/MXF.cpp
@@ -283,27 +283,33 @@ ASDCP::MXF::Partition::InitFromFile(const Kumu::FileReader& Reader)
Result_t result = KLVFilePacket::InitFromFile(Reader);
// test the UL
// could be one of several values
-
if ( ASDCP_SUCCESS(result) )
- {
- Kumu::MemIOReader MemRDR(m_ValueStart, m_ValueLength);
- result = RESULT_KLV_CODING;
+ result = ASDCP::MXF::Partition::InitFromBuffer(m_ValueStart, m_ValueLength);
+
+ return result;
+}
- if ( MemRDR.ReadUi16BE(&MajorVersion) )
- if ( MemRDR.ReadUi16BE(&MinorVersion) )
- if ( MemRDR.ReadUi32BE(&KAGSize) )
- if ( MemRDR.ReadUi64BE(&ThisPartition) )
- if ( MemRDR.ReadUi64BE(&PreviousPartition) )
- if ( MemRDR.ReadUi64BE(&FooterPartition) )
- if ( MemRDR.ReadUi64BE(&HeaderByteCount) )
- if ( MemRDR.ReadUi64BE(&IndexByteCount) )
- if ( MemRDR.ReadUi32BE(&IndexSID) )
- if ( MemRDR.ReadUi64BE(&BodyOffset) )
- if ( MemRDR.ReadUi32BE(&BodySID) )
- if ( OperationalPattern.Unarchive(&MemRDR) )
- if ( EssenceContainers.Unarchive(&MemRDR) )
- result = RESULT_OK;
- }
+//
+ASDCP::Result_t
+ASDCP::MXF::Partition::InitFromBuffer(const byte_t* p, ui32_t l)
+{
+ Kumu::MemIOReader MemRDR(p, l);
+ Result_t result = RESULT_KLV_CODING;
+
+ if ( MemRDR.ReadUi16BE(&MajorVersion) )
+ if ( MemRDR.ReadUi16BE(&MinorVersion) )
+ if ( MemRDR.ReadUi32BE(&KAGSize) )
+ if ( MemRDR.ReadUi64BE(&ThisPartition) )
+ if ( MemRDR.ReadUi64BE(&PreviousPartition) )
+ if ( MemRDR.ReadUi64BE(&FooterPartition) )
+ if ( MemRDR.ReadUi64BE(&HeaderByteCount) )
+ if ( MemRDR.ReadUi64BE(&IndexByteCount) )
+ if ( MemRDR.ReadUi32BE(&IndexSID) )
+ if ( MemRDR.ReadUi64BE(&BodyOffset) )
+ if ( MemRDR.ReadUi32BE(&BodySID) )
+ if ( OperationalPattern.Unarchive(&MemRDR) )
+ if ( EssenceContainers.Unarchive(&MemRDR) )
+ result = RESULT_OK;
if ( ASDCP_FAILURE(result) )
DefaultLogSink().Error("Failed to initialize Partition\n");
@@ -731,8 +737,33 @@ ASDCP::MXF::OPAtomHeader::InitFromFile(const Kumu::FileReader& Reader)
}
}
- const byte_t* p = m_Buffer.RoData();
- const byte_t* end_p = p + m_Buffer.Capacity();
+ result = InitFromBuffer(m_Buffer.RoData(), m_Buffer.Capacity());
+}
+
+//
+ASDCP::Result_t
+ASDCP::MXF::OPAtomHeader::InitFromPartitionBuffer(const byte_t* p, ui32_t l)
+{
+ Result_t result = KLVPacket::InitFromBuffer(p, l);
+
+ if ( ASDCP_SUCCESS(result) )
+ result = Partition::InitFromBuffer(m_ValueStart, m_ValueLength); // test UL and OP
+
+ if ( ASDCP_SUCCESS(result) )
+ {
+ ui32_t pp_len = KLVPacket::PacketLength();
+ result = InitFromBuffer(p + pp_len, l - pp_len);
+ }
+
+ return result;
+}
+
+//
+ASDCP::Result_t
+ASDCP::MXF::OPAtomHeader::InitFromBuffer(const byte_t* p, ui32_t l)
+{
+ Result_t result = RESULT_OK;
+ const byte_t* end_p = p + l;
while ( ASDCP_SUCCESS(result) && p < end_p )
{
@@ -761,11 +792,8 @@ ASDCP::MXF::OPAtomHeader::InitFromFile(const Kumu::FileReader& Reader)
{
m_PacketList->AddPacket(object);
- if ( object->IsA(Dict::ul(MDD_Preface)) )
- {
- assert(m_Preface == 0);
- m_Preface = (Preface*)object;
- }
+ if ( object->IsA(Dict::ul(MDD_Preface)) && m_Preface == 0 )
+ m_Preface = (Preface*)object;
}
}
else
@@ -948,7 +976,7 @@ ASDCP::MXF::OPAtomIndexFooter::OPAtomIndexFooter() :
ASDCP::MXF::OPAtomIndexFooter::~OPAtomIndexFooter() {}
-
+//
ASDCP::Result_t
ASDCP::MXF::OPAtomIndexFooter::InitFromFile(const Kumu::FileReader& Reader)
{
@@ -973,8 +1001,36 @@ ASDCP::MXF::OPAtomIndexFooter::InitFromFile(const Kumu::FileReader& Reader)
return RESULT_FAIL;
}
- const byte_t* p = m_Buffer.RoData();
- const byte_t* end_p = p + m_Buffer.Capacity();
+ if ( ASDCP_SUCCESS(result) )
+ result = InitFromBuffer(m_Buffer.RoData(), m_Buffer.Capacity());
+
+ return result;
+}
+
+//
+ASDCP::Result_t
+ASDCP::MXF::OPAtomIndexFooter::InitFromPartitionBuffer(const byte_t* p, ui32_t l)
+{
+ Result_t result = KLVPacket::InitFromBuffer(p, l);
+
+ if ( ASDCP_SUCCESS(result) )
+ result = Partition::InitFromBuffer(m_ValueStart, m_ValueLength); // test UL and OP
+
+ if ( ASDCP_SUCCESS(result) )
+ {
+ ui32_t pp_len = KLVPacket::PacketLength();
+ result = InitFromBuffer(p + pp_len, l - pp_len);
+ }
+
+ return result;
+}
+
+//
+ASDCP::Result_t
+ASDCP::MXF::OPAtomIndexFooter::InitFromBuffer(const byte_t* p, ui32_t l)
+{
+ Result_t result = RESULT_OK;
+ const byte_t* end_p = p + l;
while ( ASDCP_SUCCESS(result) && p < end_p )
{
diff --git a/src/MXF.h b/src/MXF.h
index 6a9b14d..95f9043 100755
--- a/src/MXF.h
+++ b/src/MXF.h
@@ -133,6 +133,7 @@ namespace ASDCP
virtual ~Partition();
virtual void AddChildObject(InterchangeObject*);
virtual Result_t InitFromFile(const Kumu::FileReader& Reader);
+ virtual Result_t InitFromBuffer(const byte_t* p, ui32_t l);
virtual Result_t WriteToFile(Kumu::FileWriter& Writer, UL& PartitionLabel);
virtual ui32_t ArchiveSize(); // returns the size of the archived structure
virtual void Dump(FILE* = 0);
@@ -327,6 +328,8 @@ namespace ASDCP
OPAtomHeader();
virtual ~OPAtomHeader();
virtual Result_t InitFromFile(const Kumu::FileReader& Reader);
+ virtual Result_t InitFromPartitionBuffer(const byte_t* p, ui32_t l);
+ virtual Result_t InitFromBuffer(const byte_t* p, ui32_t l);
virtual Result_t WriteToFile(Kumu::FileWriter& Writer, ui32_t HeaderLength = 16384);
virtual void Dump(FILE* = 0);
virtual Result_t GetMDObjectByID(const UUID&, InterchangeObject** = 0);
@@ -353,6 +356,8 @@ namespace ASDCP
OPAtomIndexFooter();
virtual ~OPAtomIndexFooter();
virtual Result_t InitFromFile(const Kumu::FileReader& Reader);
+ virtual Result_t InitFromPartitionBuffer(const byte_t* p, ui32_t l);
+ virtual Result_t InitFromBuffer(const byte_t* p, ui32_t l);
virtual Result_t WriteToFile(Kumu::FileWriter& Writer, ui64_t duration);
virtual void Dump(FILE* = 0);