/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- // Pre-compilation #include "MediaInfo/PreComp.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DCP_YES) //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Multiple/File_DcpAm.h" #include "MediaInfo/MediaInfo.h" #include "MediaInfo/MediaInfo_Internal.h" #include "MediaInfo/Multiple/File__ReferenceFilesHelper.h" #include "MediaInfo/Multiple/File_DcpCpl.h" #include "MediaInfo/XmlUtils.h" #include "ZenLib/FileName.h" #include "tinyxml2.h" using namespace tinyxml2; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- File_DcpAm::File_DcpAm() :File__Analyze(), File__HasReferences() { #if MEDIAINFO_EVENTS ParserIDs[0]=MediaInfo_Parser_DcpAm; StreamIDs_Width[0]=sizeof(size_t)*2; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Demux_EventWasSent_Accept_Specific=true; #endif //MEDIAINFO_DEMUX //PKL PKL_Pos=(size_t)-1; } //*************************************************************************** // Streams management //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpAm::Streams_Finish() { ReferenceFiles_Finish(); // Detection of IMF CPL bool IsImf=false; for (size_t StreamKind=Stream_General+1; StreamKindFile_ID_OnlyRoot_Set(false); ReferenceFiles_Accept(this, Config); //Parsing main elements for (XMLElement* AssetMap_Item=AssetMap->FirstChildElement(); AssetMap_Item; AssetMap_Item=AssetMap_Item->NextSiblingElement()) { const char *AmItemNs, *AmItemName = LocalName(AssetMap_Item, AmItemNs); if (!AmItemNs || strcmp(AmItemNs, NameSpace)) continue; // item has wrong namespace //AssetList if (!strcmp(AmItemName, "AssetList")) { for (XMLElement* AssetList_Item=AssetMap_Item->FirstChildElement(); AssetList_Item; AssetList_Item=AssetList_Item->NextSiblingElement()) { //Asset if (MatchQName(AssetList_Item, "Asset", NameSpace)) { File_DcpPkl::stream Stream; for (XMLElement* Asset_Item=AssetList_Item->FirstChildElement(); Asset_Item; Asset_Item=Asset_Item->NextSiblingElement()) { //ChunkList if (MatchQName(Asset_Item, "ChunkList", NameSpace)) { for (XMLElement* ChunkList_Item=Asset_Item->FirstChildElement(); ChunkList_Item; ChunkList_Item=ChunkList_Item->NextSiblingElement()) { //Chunk if (MatchQName(ChunkList_Item, "Chunk", NameSpace)) { File_DcpPkl::stream::chunk Chunk; for (XMLElement* Chunk_Item=ChunkList_Item->FirstChildElement(); Chunk_Item; Chunk_Item=Chunk_Item->NextSiblingElement()) { //Path if (MatchQName(Chunk_Item, "Path", NameSpace)) if (const char* Text=Chunk_Item->GetText()) Chunk.Path=Text; } Stream.ChunkList.push_back(Chunk); } } } //Id if (MatchQName(Asset_Item, "Id", NameSpace)) if (const char* Text=Asset_Item->GetText()) Stream.Id=Text; //PackingList if (MatchQName(Asset_Item, "PackingList", NameSpace) && Asset_Item->GetText() && !strcmp(Asset_Item->GetText(), "true")) { PKL_Pos=Streams.size(); Stream.StreamKind=(stream_t)(Stream_Max+2); // Means PKL } } Streams.push_back(Stream); } } } //Creator if (!strcmp(AmItemName, "Creator")) Fill(Stream_General, 0, General_Encoded_Library, AssetMap_Item->GetText()); //IssueDate if (!strcmp(AmItemName, "IssueDate")) Fill(Stream_General, 0, General_Encoded_Date, AssetMap_Item->GetText()); //Issuer if (!strcmp(AmItemName, "Issuer")) Fill(Stream_General, 0, General_EncodedBy, AssetMap_Item->GetText()); } //Merging with PKL if (PKL_PosStreams); for (size_t Pos=0; PosFile_IsReferenced_Get()) { for (File_DcpPkl::streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) if (Stream->StreamKind==(stream_t)(Stream_Max+1) && Stream->ChunkList.size()==1) // Means CPL { sequence* Sequence=new sequence; Sequence->FileNames.push_back(Ztring().From_UTF8(Stream->ChunkList[0].Path)); Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } ReferenceFiles->FilesForStorage=true; } #endif //MEDIAINFO_REFERENCES_YES //All should be OK... Element_Offset=File_Size; return true; } //*************************************************************************** // Infos //*************************************************************************** //--------------------------------------------------------------------------- void File_DcpAm::MergeFromPkl (File_DcpPkl::streams &StreamsToMerge) { for (File_DcpPkl::streams::iterator Stream=Streams.begin(); Stream!=Streams.end(); ++Stream) { for (File_DcpPkl::streams::iterator StreamToMerge=StreamsToMerge.begin(); StreamToMerge!=StreamsToMerge.end(); ++StreamToMerge) if (StreamToMerge->Id==Stream->Id) { if (Stream->StreamKind==Stream_Max) Stream->StreamKind=StreamToMerge->StreamKind; if (Stream->OriginalFileName.empty()) Stream->OriginalFileName=StreamToMerge->OriginalFileName; if (Stream->Type.empty()) Stream->Type=StreamToMerge->Type; if (Stream->AnnotationText.empty()) Stream->AnnotationText=StreamToMerge->AnnotationText; } } } } //NameSpace #endif //MEDIAINFO_DCP_YES