Alright so I wrote this part of code in the function that reads my file :
Code:
// Load Dictionary
string DictName = "dict.xml";
#ifdef COMPILED_DICT
if( UseCompiledDict )
{
LoadDictionary(DictData);
}
else
#endif // COMPILED_DICT
{
LoadDictionary(DictName);
}
// Open input file
MXFFilePtr InFile = new MXFFile();
InFile->Open(file, true);
// Get the master metadata
PartitionPtr MasterPartition = InFile->ReadMasterPartition();
MasterPartition->ReadMetadata();
MetadataPtr Meta = MasterPartition->ParseMetadata();
// Decide what BodySID we are interested in and the JP2k track within that essence container
UInt32 BodySID = 1;
UInt32 TrackNumber = 1;
// Build body reader for this file
BodyReaderPtr Reader = new BodyReader(InFile);
GCReadHandlerPtr Handler = new JP2KDataHandler();
// Notify the reader that we are interested in the specified stream
Reader->MakeGCReader(BodySID, Handler);
// Set up a handler for the sub-stream holding the JP2k essence
GCReaderPtr StreamReader = Reader->GetGCReader(BodySID);
StreamReader->SetDataHandler(TrackNumber, Handler);
// Parse the file
InFile->Seek(0);
while ( !(InFile->Eof()) ) {
if (!(Reader->ReadFromFile())) {
break;
}
}
// Done
InFile->Close();
BodySID and Tracknumber values have yet to be set properly. Like I said in my previous post, BodySID seems to have only 2 possible values in the file I'm working on : 0 or 1. Since a value of 0 means that the partition has no body, I set BodySID variable to 1. Concerning Tracknumber, well, I just randomly put 1 (may have to change I guess) ...
Here's my JP2KDataHandler class :
Code:
class JP2KDataHandler : public GCReadHandler_Base
{
public:
/*!
@brief Constructeur par défaut
*/
JP2KDataHandler() {}
/*!
@brief Destructeur
*/
~JP2KDataHandler() {}
/*!
@brief HandleData
*/
bool HandleData(GCReaderPtr Caller, KLVObjectPtr Object)
{
UL objectUL = Object->GetUL();
cout << "UL = " << objectUL.GetString() << endl;
}
};
Am I supposed to put something in the default constructor ?
When executing the code on my mxf file, the printed ULs are :
UL = [060e2b34.0102.0101.0d010301.15010801]
UL = [060e2b34.0102.0101.0d010301.16020101]
UL = [060e2b34.0102.0101.0d010301.16020102]
UL = [060e2b34.0102.0101.03010210.01000000]
I don't see these UL in the dict.xml file, but I guess the first UL represents the JPEG2000 images, the second & third the 2 audio streams and the last the data item. So all I would have to do is extract the value of the KLVObject in HandleData when UL is [060e2b34.0102.0101.0d010301.15010801] or [060e2b34.0102.0101.03010210.01000000].
Am I right ?