2 Copyright (c) 2005-2012, 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 MXFTypes.cpp
36 using Kumu::DefaultLogSink;
38 //------------------------------------------------------------------------------------------
43 ASDCP::UL::operator==(const UL& rhs) const
45 if ( m_Value[0] == rhs.m_Value[0] &&
46 m_Value[1] == rhs.m_Value[1] &&
47 m_Value[2] == rhs.m_Value[2] &&
48 m_Value[3] == rhs.m_Value[3] &&
49 m_Value[4] == rhs.m_Value[4] &&
50 m_Value[5] == rhs.m_Value[5] &&
51 m_Value[6] == rhs.m_Value[6] &&
52 // m_Value[7] == rhs.m_Value[7] && // version is ignored when performing lookups
53 m_Value[8] == rhs.m_Value[8] &&
54 m_Value[9] == rhs.m_Value[9] &&
55 m_Value[10] == rhs.m_Value[10] &&
56 m_Value[11] == rhs.m_Value[11] &&
57 m_Value[12] == rhs.m_Value[12] &&
58 m_Value[13] == rhs.m_Value[13] &&
59 m_Value[14] == rhs.m_Value[14] &&
60 m_Value[15] == rhs.m_Value[15]
69 ASDCP::UL::MatchIgnoreStream(const UL& rhs) const
71 if ( m_Value[0] == rhs.m_Value[0] &&
72 m_Value[1] == rhs.m_Value[1] &&
73 m_Value[2] == rhs.m_Value[2] &&
74 m_Value[3] == rhs.m_Value[3] &&
75 m_Value[4] == rhs.m_Value[4] &&
76 m_Value[5] == rhs.m_Value[5] &&
77 m_Value[6] == rhs.m_Value[6] &&
78 // m_Value[7] == rhs.m_Value[7] && // version is ignored when performing lookups
79 m_Value[8] == rhs.m_Value[8] &&
80 m_Value[9] == rhs.m_Value[9] &&
81 m_Value[10] == rhs.m_Value[10] &&
82 m_Value[11] == rhs.m_Value[11] &&
83 m_Value[12] == rhs.m_Value[12] &&
84 m_Value[13] == rhs.m_Value[13] &&
85 m_Value[14] == rhs.m_Value[14]
86 // m_Value[15] == rhs.m_Value[15] // ignore stream number
95 ASDCP::UL::ExactMatch(const UL& rhs) const
97 if ( m_Value[0] == rhs.m_Value[0] &&
98 m_Value[1] == rhs.m_Value[1] &&
99 m_Value[2] == rhs.m_Value[2] &&
100 m_Value[3] == rhs.m_Value[3] &&
101 m_Value[4] == rhs.m_Value[4] &&
102 m_Value[5] == rhs.m_Value[5] &&
103 m_Value[6] == rhs.m_Value[6] &&
104 m_Value[7] == rhs.m_Value[7] &&
105 m_Value[8] == rhs.m_Value[8] &&
106 m_Value[9] == rhs.m_Value[9] &&
107 m_Value[10] == rhs.m_Value[10] &&
108 m_Value[11] == rhs.m_Value[11] &&
109 m_Value[12] == rhs.m_Value[12] &&
110 m_Value[13] == rhs.m_Value[13] &&
111 m_Value[14] == rhs.m_Value[14] &&
112 m_Value[15] == rhs.m_Value[15]
120 ASDCP::UL::EncodeString(char* str_buf, ui32_t buf_len) const
122 if ( buf_len > 38 ) // room for dotted notation?
124 snprintf(str_buf, buf_len,
125 "%02x%02x%02x%02x.%02x%02x.%02x%02x.%02x%02x%02x%02x.%02x%02x%02x%02x",
126 m_Value[0], m_Value[1], m_Value[2], m_Value[3],
127 m_Value[4], m_Value[5], m_Value[6], m_Value[7],
128 m_Value[8], m_Value[9], m_Value[10], m_Value[11],
129 m_Value[12], m_Value[13], m_Value[14], m_Value[15]
134 else if ( buf_len > 32 ) // room for compact?
136 snprintf(str_buf, buf_len,
137 "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
138 m_Value[0], m_Value[1], m_Value[2], m_Value[3],
139 m_Value[4], m_Value[5], m_Value[6], m_Value[7],
140 m_Value[8], m_Value[9], m_Value[10], m_Value[11],
141 m_Value[12], m_Value[13], m_Value[14], m_Value[15]
152 ASDCP::UMID::MakeUMID(int Type)
155 Kumu::GenRandomValue(AssetID);
156 MakeUMID(Type, AssetID);
161 ASDCP::UMID::MakeUMID(int Type, const UUID& AssetID)
163 // Set the non-varying base of the UMID
164 static const byte_t UMIDBase[10] = { 0x06, 0x0a, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
165 memcpy(m_Value, UMIDBase, 10);
166 m_Value[10] = Type; // Material Type
167 m_Value[12] = 0x13; // length
169 // preserved for compatibility with mfxlib
170 if( Type > 4 ) m_Value[7] = 5;
171 m_Value[11] = 0x20; // UUID/UL method, number gen undefined
174 m_Value[13] = m_Value[14] = m_Value[15] = 0;
176 memcpy(&m_Value[16], AssetID.Value(), AssetID.Size());
181 // Write the timestamp value to the given buffer in the form 2004-05-01 13:20:00.000
182 // returns 0 if the buffer is smaller than DateTimeLen
184 ASDCP::UMID::EncodeString(char* str_buf, ui32_t buf_len) const
188 snprintf(str_buf, buf_len, "[%02x%02x%02x%02x.%02x%02x.%02x%02x.%02x%02x%02x%02x],%02x,%02x,%02x,%02x,",
189 m_Value[0], m_Value[1], m_Value[2], m_Value[3],
190 m_Value[4], m_Value[5], m_Value[6], m_Value[7],
191 m_Value[8], m_Value[9], m_Value[10], m_Value[11],
192 m_Value[12], m_Value[13], m_Value[14], m_Value[15]
195 ui32_t offset = strlen(str_buf);
197 if ( ( m_Value[8] & 0x80 ) == 0 )
199 // half-swapped UL, use [bbaa9988.ddcc.ffee.00010203.04050607]
200 snprintf(str_buf + offset, buf_len - offset,
201 "[%02x%02x%02x%02x.%02x%02x.%02x%02x.%02x%02x%02x%02x.%02x%02x%02x%02x]",
202 m_Value[24], m_Value[25], m_Value[26], m_Value[27],
203 m_Value[28], m_Value[29], m_Value[30], m_Value[31],
204 m_Value[16], m_Value[17], m_Value[18], m_Value[19],
205 m_Value[20], m_Value[21], m_Value[22], m_Value[23]
210 // UUID, use {00112233-4455-6677-8899-aabbccddeeff}
211 snprintf(str_buf + offset, buf_len - offset,
212 "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
213 m_Value[16], m_Value[17], m_Value[18], m_Value[19],
214 m_Value[20], m_Value[21], m_Value[22], m_Value[23],
215 m_Value[24], m_Value[25], m_Value[26], m_Value[27],
216 m_Value[28], m_Value[29], m_Value[30], m_Value[31]
223 //------------------------------------------------------------------------------------------
227 const ASDCP::MXF::UTF16String&
228 ASDCP::MXF::UTF16String::operator=(const char* sz)
230 if ( sz == 0 || *sz == 0 )
240 const ASDCP::MXF::UTF16String&
241 ASDCP::MXF::UTF16String::operator=(const std::string& str)
249 ASDCP::MXF::UTF16String::EncodeString(char* str_buf, ui32_t buf_len) const
251 ui32_t write_len = Kumu::xmin(buf_len - 1, (ui32_t)size());
252 strncpy(str_buf, c_str(), write_len);
253 str_buf[write_len] = 0;
259 ASDCP::MXF::UTF16String::Unarchive(Kumu::MemIOReader* Reader)
262 const ui16_t* p = (ui16_t*)Reader->CurrentData();
263 ui32_t length = Reader->Remainder() / 2;
264 char mb_buf[MB_LEN_MAX+1];
266 for ( ui32_t i = 0; i < length; i++ )
268 int count = wctomb(mb_buf, KM_i16_BE(p[i]));
272 DefaultLogSink().Error("Unable to decode wide character 0x%04hx\n", p[i]);
276 assert(count <= MB_LEN_MAX);
278 this->append(mb_buf);
281 Reader->SkipOffset(length*2);
287 ASDCP::MXF::UTF16String::Archive(Kumu::MemIOWriter* Writer) const
289 if ( size() > IdentBufferLen )
291 DefaultLogSink().Error("String length exceeds maximum %u bytes\n", IdentBufferLen);
295 const char* mbp = c_str();
297 ui32_t remainder = size();
298 ui32_t length = size();
303 int count = mbtowc(&wcp, mbp+i, remainder);
307 DefaultLogSink().Error("Error decoding multi-byte sequence starting at offset %u\n", i);
310 else if ( count == 0 )
313 bool result = Writer->WriteUi16BE((ui16_t)wcp);
315 if ( result == false )
317 DefaultLogSink().Error("No more space in memory IO writer\n");
328 //------------------------------------------------------------------------------------------
332 const ASDCP::MXF::ISO8String&
333 ASDCP::MXF::ISO8String::operator=(const char* sz)
335 if ( sz == 0 || *sz == 0 )
345 const ASDCP::MXF::ISO8String&
346 ASDCP::MXF::ISO8String::operator=(const std::string& str)
354 ASDCP::MXF::ISO8String::EncodeString(char* str_buf, ui32_t buf_len) const
356 ui32_t write_len = Kumu::xmin(buf_len - 1, (ui32_t)size());
357 strncpy(str_buf, c_str(), write_len);
358 str_buf[write_len] = 0;
364 ASDCP::MXF::ISO8String::Unarchive(Kumu::MemIOReader* Reader)
366 assign((char*)Reader->CurrentData(), Reader->Remainder());
372 ASDCP::MXF::ISO8String::Archive(Kumu::MemIOWriter* Writer) const
374 if ( size() > IdentBufferLen )
376 DefaultLogSink().Error("String length exceeds maximum %u bytes\n", IdentBufferLen);
380 return Writer->WriteString(*this);
384 //------------------------------------------------------------------------------------------
389 #define TIMESTAMP_TO_SYSTIME(ts, t) \
390 (t)->wYear = (ts).Year; /* year */ \
391 (t)->wMonth = (ts).Month; /* month of year (1 - 12) */ \
392 (t)->wDay = (ts).Day; /* day of month (1 - 31) */ \
393 (t)->wHour = (ts).Hour; /* hours (0 - 23) */ \
394 (t)->wMinute = (ts).Minute; /* minutes (0 - 59) */ \
395 (t)->wSecond = (ts).Second; /* seconds (0 - 60) */ \
396 (t)->wDayOfWeek = 0; \
397 (t)->wMilliseconds = ((ts).Tick * 4);
399 #define SYSTIME_TO_TIMESTAMP(t, ts) \
400 (ts).Year = (t)->wYear; /* year */ \
401 (ts).Month = (t)->wMonth; /* month of year (1 - 12) */ \
402 (ts).Day = (t)->wDay; /* day of month (1 - 31) */ \
403 (ts).Hour = (t)->wHour; /* hours (0 - 23) */ \
404 (ts).Minute = (t)->wMinute; /* minutes (0 - 59) */ \
405 (ts).Second = (t)->wSecond; /* seconds (0 - 60) */ \
406 (ts).Tick = (t)->wMilliseconds / 4;
409 ASDCP::MXF::Timestamp::Timestamp() :
410 Year(0), Month(0), Day(0), Hour(0), Minute(0), Second(0), Tick(0)
413 GetSystemTime(&sys_time);
414 SYSTIME_TO_TIMESTAMP(&sys_time, *this);
419 ASDCP::MXF::Timestamp::operator<(const Timestamp& rhs) const
421 SYSTEMTIME lhst, rhst;
424 TIMESTAMP_TO_SYSTIME(*this, &lhst);
425 TIMESTAMP_TO_SYSTIME(rhs, &rhst);
426 SystemTimeToFileTime(&lhst, &lft);
427 SystemTimeToFileTime(&rhst, &rft);
428 return ( CompareFileTime(&lft, &rft) == -1 );
432 seconds_to_ns100(ui32_t seconds)
434 return ((ui64_t)seconds * 10000000);
439 ASDCP::MXF::Timestamp::AddDays(i32_t days)
441 SYSTEMTIME current_st;
443 ULARGE_INTEGER current_ul;
447 TIMESTAMP_TO_SYSTIME(*this, ¤t_st);
448 SystemTimeToFileTime(¤t_st, ¤t_ft);
449 memcpy(¤t_ul, ¤t_ft, sizeof(current_ul));
450 current_ul.QuadPart += ( seconds_to_ns100(86400) * (ui64_t)days );
451 memcpy(¤t_ft, ¤t_ul, sizeof(current_ft));
452 FileTimeToSystemTime(¤t_ft, ¤t_st);
453 SYSTIME_TO_TIMESTAMP(¤t_st, *this);
459 ASDCP::MXF::Timestamp::AddHours(i32_t hours)
461 SYSTEMTIME current_st;
463 ULARGE_INTEGER current_ul;
467 TIMESTAMP_TO_SYSTIME(*this, ¤t_st);
468 SystemTimeToFileTime(¤t_st, ¤t_ft);
469 memcpy(¤t_ul, ¤t_ft, sizeof(current_ul));
470 current_ul.QuadPart += ( seconds_to_ns100(3600) * (ui64_t)hours );
471 memcpy(¤t_ft, ¤t_ul, sizeof(current_ft));
472 FileTimeToSystemTime(¤t_ft, ¤t_st);
473 SYSTIME_TO_TIMESTAMP(¤t_st, *this);
481 #define TIMESTAMP_TO_TM(ts, t) \
482 (t)->tm_year = (ts).Year - 1900; /* year - 1900 */ \
483 (t)->tm_mon = (ts).Month - 1; /* month of year (0 - 11) */ \
484 (t)->tm_mday = (ts).Day; /* day of month (1 - 31) */ \
485 (t)->tm_hour = (ts).Hour; /* hours (0 - 23) */ \
486 (t)->tm_min = (ts).Minute; /* minutes (0 - 59) */ \
487 (t)->tm_sec = (ts).Second; /* seconds (0 - 60) */
489 #define TM_TO_TIMESTAMP(t, ts) \
490 (ts).Year = (t)->tm_year + 1900; /* year - 1900 */ \
491 (ts).Month = (t)->tm_mon + 1; /* month of year (0 - 11) */ \
492 (ts).Day = (t)->tm_mday; /* day of month (1 - 31) */ \
493 (ts).Hour = (t)->tm_hour; /* hours (0 - 23) */ \
494 (ts).Minute = (t)->tm_min; /* minutes (0 - 59) */ \
495 (ts).Second = (t)->tm_sec; /* seconds (0 - 60) */
498 ASDCP::MXF::Timestamp::Timestamp() :
499 Year(0), Month(0), Day(0), Hour(0), Minute(0), Second(0)
501 time_t t_now = time(0);
502 struct tm* now = gmtime(&t_now);
503 TM_TO_TIMESTAMP(now, *this);
508 ASDCP::MXF::Timestamp::operator<(const Timestamp& rhs) const
510 struct tm lhtm, rhtm;
511 TIMESTAMP_TO_TM(*this, &lhtm);
512 TIMESTAMP_TO_TM(rhs, &rhtm);
513 return ( timegm(&lhtm) < timegm(&rhtm) );
518 ASDCP::MXF::Timestamp::AddDays(i32_t days)
524 TIMESTAMP_TO_TM(*this, ¤t);
525 time_t adj_time = timegm(¤t);
526 adj_time += 86400 * days;
527 struct tm* now = gmtime(&adj_time);
528 TM_TO_TIMESTAMP(now, *this);
534 ASDCP::MXF::Timestamp::AddHours(i32_t hours)
540 TIMESTAMP_TO_TM(*this, ¤t);
541 time_t adj_time = timegm(¤t);
542 adj_time += 3600 * hours;
543 struct tm* now = gmtime(&adj_time);
544 TM_TO_TIMESTAMP(now, *this);
551 ASDCP::MXF::Timestamp::Timestamp(const Timestamp& rhs) : IArchive()
561 ASDCP::MXF::Timestamp::~Timestamp()
566 const ASDCP::MXF::Timestamp&
567 ASDCP::MXF::Timestamp::operator=(const Timestamp& rhs)
580 ASDCP::MXF::Timestamp::operator==(const Timestamp& rhs) const
582 if ( Year == rhs.Year
583 && Month == rhs.Month
586 && Minute == rhs.Minute
587 && Second == rhs.Second )
595 ASDCP::MXF::Timestamp::operator!=(const Timestamp& rhs) const
597 if ( Year != rhs.Year
598 || Month != rhs.Month
601 || Minute != rhs.Minute
602 || Second != rhs.Second )
610 ASDCP::MXF::Timestamp::EncodeString(char* str_buf, ui32_t buf_len) const
612 // 2004-05-01 13:20:00.000
613 snprintf(str_buf, buf_len,
614 "%04hu-%02hu-%02hu %02hu:%02hu:%02hu.000",
615 Year, Month, Day, Hour, Minute, Second);
620 //------------------------------------------------------------------------------------------
623 ASDCP::MXF::TLVReader::TLVReader(const byte_t* p, ui32_t c, IPrimerLookup* PrimerLookup) :
624 MemIOReader(p, c), m_Lookup(PrimerLookup)
626 Result_t result = RESULT_OK;
628 while ( Remainder() > 0 && ASDCP_SUCCESS(result) )
633 if ( MemIOReader::ReadUi8(&Tag.a) )
634 if ( MemIOReader::ReadUi8(&Tag.b) )
635 if ( MemIOReader::ReadUi16BE(&pkt_len) )
637 m_ElementMap.insert(TagMap::value_type(Tag, ItemInfo(m_size, pkt_len)));
638 if ( SkipOffset(pkt_len) )
642 DefaultLogSink().Error("Malformed Set\n");
643 m_ElementMap.clear();
644 result = RESULT_KLV_CODING;
650 ASDCP::MXF::TLVReader::FindTL(const MDDEntry& Entry)
654 DefaultLogSink().Error("No Lookup service\n");
660 if ( m_Lookup->TagForKey(Entry.ul, TmpTag) != RESULT_OK )
662 if ( Entry.tag.a == 0 )
664 // DefaultLogSink().Debug("No such UL in this TL list: %s (%02x %02x)\n",
665 // Entry.name, Entry.tag.a, Entry.tag.b);
672 TagMap::iterator e_i = m_ElementMap.find(TmpTag);
674 if ( e_i != m_ElementMap.end() )
676 m_size = (*e_i).second.first;
677 m_capacity = m_size + (*e_i).second.second;
681 // DefaultLogSink().Debug("Not Found (%02x %02x): %s\n", TmpTag.a, TmpTag.b, Entry.name);
687 ASDCP::MXF::TLVReader::ReadObject(const MDDEntry& Entry, Kumu::IArchive* Object)
689 ASDCP_TEST_NULL(Object);
693 if ( m_size < m_capacity ) // don't try to unarchive an empty item
694 return Object->Unarchive(this) ? RESULT_OK : RESULT_KLV_CODING;
702 ASDCP::MXF::TLVReader::ReadUi8(const MDDEntry& Entry, ui8_t* value)
704 ASDCP_TEST_NULL(value);
707 return MemIOReader::ReadUi8(value) ? RESULT_OK : RESULT_KLV_CODING;
714 ASDCP::MXF::TLVReader::ReadUi16(const MDDEntry& Entry, ui16_t* value)
716 ASDCP_TEST_NULL(value);
719 return MemIOReader::ReadUi16BE(value) ? RESULT_OK : RESULT_KLV_CODING;
726 ASDCP::MXF::TLVReader::ReadUi32(const MDDEntry& Entry, ui32_t* value)
728 ASDCP_TEST_NULL(value);
731 return MemIOReader::ReadUi32BE(value) ? RESULT_OK : RESULT_KLV_CODING;
738 ASDCP::MXF::TLVReader::ReadUi64(const MDDEntry& Entry, ui64_t* value)
740 ASDCP_TEST_NULL(value);
743 return MemIOReader::ReadUi64BE(value) ? RESULT_OK : RESULT_KLV_CODING;
748 //------------------------------------------------------------------------------------------
751 ASDCP::MXF::TLVWriter::TLVWriter(byte_t* p, ui32_t c, IPrimerLookup* PrimerLookup) :
752 MemIOWriter(p, c), m_Lookup(PrimerLookup)
759 ASDCP::MXF::TLVWriter::WriteTag(const MDDEntry& Entry)
763 DefaultLogSink().Error("No Primer object available\n");
769 if ( m_Lookup->InsertTag(Entry, TmpTag) != RESULT_OK )
771 DefaultLogSink().Error("No tag for entry %s\n", Entry.name);
775 if ( ! MemIOWriter::WriteUi8(TmpTag.a) ) return RESULT_KLV_CODING;
776 if ( ! MemIOWriter::WriteUi8(TmpTag.b) ) return RESULT_KLV_CODING;
782 ASDCP::MXF::TLVWriter::WriteObject(const MDDEntry& Entry, Kumu::IArchive* Object)
784 ASDCP_TEST_NULL(Object);
786 if ( Entry.optional && ! Object->HasValue() )
789 Result_t result = WriteTag(Entry);
791 if ( ASDCP_SUCCESS(result) )
793 // write a temp length
794 byte_t* l_p = CurrentData();
796 if ( ! MemIOWriter::WriteUi16BE(0) ) return RESULT_KLV_CODING;
798 ui32_t before = Length();
799 if ( ! Object->Archive(this) ) return RESULT_KLV_CODING;
800 if ( (Length() - before) > 0xffffL ) return RESULT_KLV_CODING;
801 Kumu::i2p<ui16_t>(KM_i16_BE(Length() - before), l_p);
809 ASDCP::MXF::TLVWriter::WriteUi8(const MDDEntry& Entry, ui8_t* value)
811 ASDCP_TEST_NULL(value);
812 Result_t result = WriteTag(Entry);
814 if ( ASDCP_SUCCESS(result) )
816 if ( ! MemIOWriter::WriteUi16BE(sizeof(ui8_t)) ) return RESULT_KLV_CODING;
817 if ( ! MemIOWriter::WriteUi8(*value) ) return RESULT_KLV_CODING;
825 ASDCP::MXF::TLVWriter::WriteUi16(const MDDEntry& Entry, ui16_t* value)
827 ASDCP_TEST_NULL(value);
828 Result_t result = WriteTag(Entry);
830 if ( KM_SUCCESS(result) )
832 if ( ! MemIOWriter::WriteUi16BE(sizeof(ui16_t)) ) return RESULT_KLV_CODING;
833 if ( ! MemIOWriter::WriteUi16BE(*value) ) return RESULT_KLV_CODING;
841 ASDCP::MXF::TLVWriter::WriteUi32(const MDDEntry& Entry, ui32_t* value)
843 ASDCP_TEST_NULL(value);
844 Result_t result = WriteTag(Entry);
846 if ( KM_SUCCESS(result) )
848 if ( ! MemIOWriter::WriteUi16BE(sizeof(ui32_t)) ) return RESULT_KLV_CODING;
849 if ( ! MemIOWriter::WriteUi32BE(*value) ) return RESULT_KLV_CODING;
857 ASDCP::MXF::TLVWriter::WriteUi64(const MDDEntry& Entry, ui64_t* value)
859 ASDCP_TEST_NULL(value);
860 Result_t result = WriteTag(Entry);
862 if ( KM_SUCCESS(result) )
864 if ( ! MemIOWriter::WriteUi16BE(sizeof(ui64_t)) ) return RESULT_KLV_CODING;
865 if ( ! MemIOWriter::WriteUi64BE(*value) ) return RESULT_KLV_CODING;
872 //----------------------------------------------------------------------------------------------------
875 ASDCP::MXF::Raw::Raw()
880 ASDCP::MXF::Raw::~Raw()
886 ASDCP::MXF::Raw::Unarchive(Kumu::MemIOReader* Reader)
888 ui32_t payload_size = Reader->Remainder();
889 if ( payload_size == 0 ) return false;
890 if ( KM_FAILURE(Capacity(payload_size)) ) return false;
892 memcpy(Data(), Reader->CurrentData(), payload_size);
893 Length(payload_size);
899 ASDCP::MXF::Raw::Archive(Kumu::MemIOWriter* Writer) const
901 return Writer->WriteRaw(RoData(), Length());
906 ASDCP::MXF::Raw::EncodeString(char* str_buf, ui32_t buf_len) const
909 Kumu::bin2hex(RoData(), Length(), str_buf, buf_len);