/*
-Copyright (c) 2004-2007, John Hurst
+Copyright (c) 2004-2009, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
#include "JP2K.h"
#include "MPEG.h"
#include "Wav.h"
+#include <iostream>
+#include <iomanip>
//------------------------------------------------------------------------------------------
// misc subroutines
+//
+std::ostream&
+ASDCP::operator << (std::ostream& strm, const WriterInfo& Info)
+{
+ char str_buf[40];
+
+ strm << " ProductUUID: " << UUID(Info.ProductUUID).EncodeHex(str_buf, 40) << std::endl;
+ strm << " ProductVersion: " << Info.ProductVersion << std::endl;
+ strm << " CompanyName: " << Info.CompanyName << std::endl;
+ strm << " ProductName: " << Info.ProductName << std::endl;
+ strm << " EncryptedEssence: " << (Info.EncryptedEssence ? "Yes" : "No") << std::endl;
+
+ if ( Info.EncryptedEssence )
+ {
+ strm << " HMAC: " << (Info.UsesHMAC ? "Yes" : "No") << std::endl;
+ strm << " ContextID: " << UUID(Info.ContextID).EncodeHex(str_buf, 40) << std::endl;
+ strm << "CryptographicKeyID: " << UUID(Info.CryptographicKeyID).EncodeHex(str_buf, 40) << std::endl;
+ }
+
+ strm << " AssetUUID: " << UUID(Info.AssetUUID).EncodeHex(str_buf, 40) << std::endl;
+ strm << " Label Set Type: " << (Info.LabelSetType == LS_MXF_SMPTE ? "SMPTE" :
+ (Info.LabelSetType == LS_MXF_INTEROP ? "MXF Interop" :
+ "Unknown")) << std::endl;
+ return strm;
+}
+
//
void
ASDCP::WriterInfoDump(const WriterInfo& Info, FILE* stream)
//
Result_t
-ASDCP::MD_to_CryptoInfo(CryptographicContext* InfoObj, WriterInfo& Info)
+ASDCP::MD_to_CryptoInfo(CryptographicContext* InfoObj, WriterInfo& Info, const Dictionary& Dict)
{
ASDCP_TEST_NULL(InfoObj);
memcpy(Info.ContextID, InfoObj->ContextID.Value(), UUIDlen);
memcpy(Info.CryptographicKeyID, InfoObj->CryptographicKeyID.Value(), UUIDlen);
- UL MIC_SHA1(Dict::ul(MDD_MICAlgorithm_HMAC_SHA1));
- UL MIC_NONE(Dict::ul(MDD_MICAlgorithm_NONE));
+ UL MIC_SHA1(Dict.ul(MDD_MICAlgorithm_HMAC_SHA1));
+ UL MIC_NONE(Dict.ul(MDD_MICAlgorithm_NONE));
if ( InfoObj->MICAlgorithm == MIC_SHA1 )
Info.UsesHMAC = true;
ASDCP::Result_t
ASDCP::EssenceType(const char* filename, EssenceType_t& type)
{
+ const Dictionary* m_Dict = &DefaultCompositeDict();
+ assert(m_Dict);
+
ASDCP_TEST_NULL_STR(filename);
Kumu::FileReader Reader;
- OPAtomHeader TestHeader;
+ OPAtomHeader TestHeader(m_Dict);
Result_t result = Reader.OpenRead(filename);
type = ESS_PCM_24b_48k;
else if ( ASDCP_SUCCESS(TestHeader.GetMDObjectByType(OBJ_TYPE_ARGS(MPEG2VideoDescriptor))) )
type = ESS_MPEG2_VES;
- else if ( ASDCP_SUCCESS(TestHeader.GetMDObjectByType(OBJ_TYPE_ARGS(DCTimedTextDescriptor))) )
+ else if ( ASDCP_SUCCESS(TestHeader.GetMDObjectByType(OBJ_TYPE_ARGS(TimedTextDescriptor))) )
type = ESS_TIMED_TEXT;
}
while ( p[i] == 0 ) i++;
if ( i > 1 && p[i] == 1 && (p[i+1] == ASDCP::MPEG2::SEQ_START || p[i+1] == ASDCP::MPEG2::PIC_START) )
- type = ESS_MPEG2_VES;
-
- else if ( Kumu::StringIsXML((const char*)p, FB.Size()) )
- type = ESS_TIMED_TEXT;
-
- else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(p, read_count, &data_offset)) )
- type = ESS_PCM_24b_48k;
-
- else if ( ASDCP_SUCCESS(AIFFHeader.ReadFromBuffer(p, read_count, &data_offset)) )
- type = ESS_PCM_24b_48k;
+ {
+ type = ESS_MPEG2_VES;
+ }
+ else if ( memcmp(FB.RoData(), ASDCP::JP2K::Magic, sizeof(ASDCP::JP2K::Magic)) == 0 )
+ {
+ type = ESS_JPEG_2000;
+ }
+ else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(FB.RoData(), read_count, &data_offset)) )
+ {
+ switch ( WavHeader.samplespersec )
+ {
+ case 48000: type = ESS_PCM_24b_48k; break;
+ case 96000: type = ESS_PCM_24b_96k; break;
+ default:
+ return RESULT_FORMAT;
+ }
+ }
+ else if ( ASDCP_SUCCESS(AIFFHeader.ReadFromBuffer(FB.RoData(), read_count, &data_offset)) )
+ {
+ type = ESS_PCM_24b_48k;
+ }
+ else if ( Kumu::StringIsXML((const char*)FB.RoData(), FB.Size()) )
+ {
+ type = ESS_TIMED_TEXT;
+ }
}
}
else if ( Kumu::PathIsDirectory(filename) )
if ( ASDCP_SUCCESS(result) )
{
if ( memcmp(FB.RoData(), ASDCP::JP2K::Magic, sizeof(ASDCP::JP2K::Magic)) == 0 )
- type = ESS_JPEG_2000;
-
+ {
+ type = ESS_JPEG_2000;
+ }
else if ( ASDCP_SUCCESS(WavHeader.ReadFromBuffer(FB.RoData(), read_count, &data_offset)) )
- type = ESS_PCM_24b_48k;
+ {
+ switch ( WavHeader.samplespersec )
+ {
+ case 48000: type = ESS_PCM_24b_48k; break;
+ case 96000: type = ESS_PCM_24b_96k; break;
+ default:
+ return RESULT_FORMAT;
+ }
+ }
}
break;
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());