/* 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" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/MediaInfo_Config_MediaInfo.h" #include "MediaInfo/MediaInfo_Config.h" #include "MediaInfo/TimeCode.h" #include "ZenLib/ZtringListListF.h" #if MEDIAINFO_EVENTS #include "ZenLib/FileName.h" #endif //MEDIAINFO_EVENTS #if MEDIAINFO_IBI || MEDIAINFO_AES #include "ThirdParty/base64/base64.h" #endif //MEDIAINFO_IBI || MEDIAINFO_AES #include #if MEDIAINFO_DEMUX #include #endif //MEDIAINFO_DEMUX using namespace ZenLib; using namespace std; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Debug #ifdef MEDIAINFO_DEBUG #include #include namespace MediaInfo_Config_MediaInfo_Debug { FILE* F; std::string Debug; SYSTEMTIME st_In; void Debug_Open(bool Out) { F=fopen("C:\\Temp\\MediaInfo_Debug.txt", "a+t"); Debug.clear(); SYSTEMTIME st; GetLocalTime( &st ); char Duration[100]; if (Out) { FILETIME ft_In; if (SystemTimeToFileTime(&st_In, &ft_In)) { FILETIME ft_Out; if (SystemTimeToFileTime(&st, &ft_Out)) { ULARGE_INTEGER UI_In; UI_In.HighPart=ft_In.dwHighDateTime; UI_In.LowPart=ft_In.dwLowDateTime; ULARGE_INTEGER UI_Out; UI_Out.HighPart=ft_Out.dwHighDateTime; UI_Out.LowPart=ft_Out.dwLowDateTime; ULARGE_INTEGER UI_Diff; UI_Diff.QuadPart=UI_Out.QuadPart-UI_In.QuadPart; FILETIME ft_Diff; ft_Diff.dwHighDateTime=UI_Diff.HighPart; ft_Diff.dwLowDateTime=UI_Diff.LowPart; SYSTEMTIME st_Diff; if (FileTimeToSystemTime(&ft_Diff, &st_Diff)) { sprintf(Duration, "%02hd:%02hd:%02hd.%03hd", st_Diff.wHour, st_Diff.wMinute, st_Diff.wSecond, st_Diff.wMilliseconds); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else strcpy(Duration, " "); } else { st_In=st; strcpy(Duration, " "); } fprintf(F," %02hd:%02hd:%02hd.%03hd %s", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, Duration); } void Debug_Close() { Debug += "\r\n"; fwrite(Debug.c_str(), Debug.size(), 1, F); \ fclose(F); } } using namespace MediaInfo_Config_MediaInfo_Debug; #define MEDIAINFO_DEBUG1(_NAME,_TOAPPEND) \ Debug_Open(false); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #define MEDIAINFO_DEBUG2(_NAME,_TOAPPEND) \ Debug_Open(true); \ Debug+=", ";Debug+=_NAME; \ _TOAPPEND; \ Debug_Close(); #else // MEDIAINFO_DEBUG #define MEDIAINFO_DEBUG1(_NAME,_TOAPPEND) #define MEDIAINFO_DEBUG2(_NAME,_TOAPPEND) #endif // MEDIAINFO_DEBUG namespace MediaInfoLib { const size_t Buffer_NormalSize=/*188*7;//*/64*1024; //*************************************************************************** // Info //*************************************************************************** const char* DisplayCaptions_Strings[] = { "Command", "Content", "Stream", }; static_assert(sizeof(DisplayCaptions_Strings) / sizeof(*DisplayCaptions_Strings) == DisplayCaptions_Max, ""); //*************************************************************************** // Class //*************************************************************************** MediaInfo_Config_MediaInfo::MediaInfo_Config_MediaInfo() { MediaInfoLib::Config.Init(); //Initialize Configuration RequestTerminate=false; FileIsSeekable=true; FileIsSub=false; FileIsDetectingDuration=false; FileIsReferenced=false; FileTestContinuousFileNames=true; FileTestDirectory=true; FileKeepInfo=false; FileStopAfterFilled=false; FileStopSubStreamAfterFilled=false; Audio_MergeMonoStreams=false; File_Demux_Interleave=false; File_ID_OnlyRoot=false; File_ExpandSubs_Backup=NULL; File_ExpandSubs_Source=NULL; #if MEDIAINFO_ADVANCED File_IgnoreSequenceFileSize=false; File_IgnoreSequenceFilesCount=false; File_SequenceFilesSkipFrames=0; File_DefaultFrameRate=0; File_DefaultTimeCodeDropFrame=(int8u)-1; File_Source_List=false; File_RiskyBitRateEstimation=false; File_MergeBitRateInfo=true; File_HighestFormat=true; File_ChannelLayout=true; File_FrameIsAlwaysComplete=false; #if MEDIAINFO_DEMUX File_Demux_Unpacketize_StreamLayoutChange_Skip=false; #endif //MEDIAINFO_DEMUX #endif //MEDIAINFO_ADVANCED #if MEDIAINFO_MD5 File_Md5=false; #endif //MEDIAINFO_MD5 #if defined(MEDIAINFO_REFERENCES_YES) File_CheckSideCarFiles=false; #endif //defined(MEDIAINFO_REFERENCES_YES) File_TimeToLive=0; File_Buffer_Size_Hint_Pointer=NULL; File_Buffer_Read_Size=64*1024*1024; #if MEDIAINFO_AES Encryption_Format=Encryption_Format_None; Encryption_Method=Encryption_Method_None; Encryption_Mode=Encryption_Mode_None; Encryption_Padding=Encryption_Padding_None; #endif //MEDIAINFO_AES #if MEDIAINFO_NEXTPACKET NextPacket=false; #endif //MEDIAINFO_NEXTPACKET #if MEDIAINFO_FILTER File_Filter_Audio=false; File_Filter_HasChanged_=false; #endif //MEDIAINFO_FILTER #if MEDIAINFO_EVENTS Event_CallBackFunction=NULL; Event_UserHandler=NULL; SubFile_StreamID=(int64u)-1; ParseUndecodableFrames=false; Events_TimestampShift_Reference_PTS=(int64u)-1; Events_TimestampShift_Reference_ID=(int64u)-1; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Demux_ForceIds=false; Demux_PCM_20bitTo16bit=false; Demux_PCM_20bitTo24bit=false; Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10=false; Demux_Hevc_Transcode_Iso14496_15_to_AnnexB=false; Demux_Unpacketize=false; Demux_SplitAudioBlocks=false; Demux_Rate=0; Demux_FirstDts=(int64u)-1; Demux_FirstFrameNumber=(int64u)-1; Demux_InitData=0; //In Demux event #endif //MEDIAINFO_DEMUX #if MEDIAINFO_IBIUSAGE Ibi_UseIbiInfoIfAvailable=false; #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE Ibi_Create=false; #endif //MEDIAINFO_IBIUSAGE //Specific File_MpegTs_ForceMenu=false; File_MpegTs_stream_type_Trust=true; File_MpegTs_Atsc_transport_stream_id_Trust=true; File_MpegTs_RealTime=false; File_Mxf_TimeCodeFromMaterialPackage=false; File_Mxf_ParseIndex=false; File_Bdmv_ParseTargetedFile=true; #if defined(MEDIAINFO_DVDIF_YES) File_DvDif_DisableAudioIfIsInContainer=false; File_DvDif_IgnoreTransmittingFlags=false; #endif //defined(MEDIAINFO_DVDIF_YES) #if defined(MEDIAINFO_DVDIF_ANALYZE_YES) File_DvDif_Analysis=false; #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES) #if MEDIAINFO_MACROBLOCKS File_Macroblocks_Parse=0; #endif //MEDIAINFO_MACROBLOCKS File_GrowingFile_Delay=10; File_GrowingFile_Force=false; #if defined(MEDIAINFO_LIBMMS_YES) File_Mmsh_Describe_Only=false; #endif //defined(MEDIAINFO_LIBMMS_YES) DisplayCaptions=DisplayCaptions_Command; File_ProbeCaption_Set({}); State=0; #if defined(MEDIAINFO_AC3_YES) File_Ac3_IgnoreCrc=false; #endif //defined(MEDIAINFO_AC3_YES) //Internal to MediaInfo, not thread safe File_Names_Pos=0; File_Buffer=NULL; File_Buffer_Size_Max=0; File_Buffer_Size_ToRead=Buffer_NormalSize; File_Buffer_Size=0; File_Buffer_Repeat=false; File_Buffer_Repeat_IsSupported=false; File_IsGrowing=false; File_IsNotGrowingAnymore=false; File_IsImageSequence=false; #if defined(MEDIAINFO_EIA608_YES) File_Scte20_IsPresent=false; #endif //defined(MEDIAINFO_EIA608_YES) #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) File_DtvccTransport_Stream_IsPresent=false; File_DtvccTransport_Descriptor_IsPresent=false; #endif //defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) #if defined(MEDIAINFO_MPEGPS_YES) File_MpegPs_PTS_Begin_IsNearZero=false; #endif //defined(MEDIAINFO_MPEGPS_YES) File_Current_Offset=0; File_Current_Size=(int64u)-1; File_IgnoreEditsBefore=0; File_IgnoreEditsAfter=(int64u)-1; File_EditRate=0; File_Size=(int64u)-1; ParseSpeed=MediaInfoLib::Config.ParseSpeed_Get(); ParseSpeed_FromFile=false; IsFinishing=false; #if MEDIAINFO_EVENTS Config_PerPackage=NULL; Events_TimestampShift_Disabled=false; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_DEMUX Demux_EventWasSent=false; Demux_Offset_Frame=(int64u)-1; Demux_Offset_DTS=(int64u)-1; Demux_Offset_DTS_FromStream=(int64u)-1; Events_Delayed_CurrentSource=NULL; #if MEDIAINFO_SEEK Demux_IsSeeking=false; #endif //MEDIAINFO_SEEK #endif //MEDIAINFO_DEMUX #if MEDIAINFO_SEEK File_GoTo_IsFrameOffset=false; #endif //MEDIAINFO_SEEK #if MEDIAINFO_FIXITY TryToFix=false; #endif //MEDIAINFO_SEEK #if MEDIAINFO_ADVANCED TimeCode_Dumps=nullptr; #endif //MEDIAINFO_ADVANCED } MediaInfo_Config_MediaInfo::~MediaInfo_Config_MediaInfo() { delete[] File_Buffer; //File_Buffer=NULL; delete (std::vector >*)File_ExpandSubs_Backup; //File_ExpandSubs_Backup=NULL #if MEDIAINFO_EVENTS for (events_delayed::iterator Event=Events_Delayed.begin(); Event!=Events_Delayed.end(); ++Event) for (size_t Pos=0; Possecond.size(); Pos++) delete Event->second[Pos]; //Event->second[Pos]=NULL; #endif //MEDIAINFO_EVENTS #if MEDIAINFO_ADVANCED delete TimeCode_Dumps; #endif //MEDIAINFO_ADVANCED } //*************************************************************************** // Info //*************************************************************************** Ztring MediaInfo_Config_MediaInfo::Option (const String &Option, const String &Value) { #if MEDIAINFO_EVENTS SubFile_Config(Option)=Value; #endif //MEDIAINFO_EVENTS String Option_Lower(Option); size_t Egal_Pos=Option_Lower.find(__T('=')); if (Egal_Pos==string::npos) Egal_Pos=Option_Lower.size(); transform(Option_Lower.begin(), Option_Lower.begin()+Egal_Pos, Option_Lower.begin(), (int(*)(int))tolower); //(int(*)(int)) is a patch for unix if (Option_Lower==__T("file_requestterminate")) { RequestTerminate=true; return Ztring(); } if (Option_Lower==__T("file_isseekable")) { File_IsSeekable_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_isseekable_get")) { return File_IsSeekable_Get()?"1":"0"; } if (Option_Lower==__T("file_issub")) { File_IsSub_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_issub_get")) { return File_IsSub_Get()?"1":"0"; } if (Option_Lower==__T("file_parsespeed")) { File_ParseSpeed_Set(Ztring(Value).To_float32()); return __T(""); } else if (Option_Lower==__T("file_parsespeed_get")) { return Ztring::ToZtring(File_ParseSpeed_Get(), 1); } if (Option_Lower==__T("file_isdetectingduration")) { File_IsDetectingDuration_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_isdetectingduration_get")) { return File_IsDetectingDuration_Get()?"1":"0"; } if (Option_Lower==__T("file_isreferenced")) { File_IsReferenced_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_isreferenced_get")) { return File_IsReferenced_Get()?"1":"0"; } if (Option_Lower==__T("file_testcontinuousfilenames")) { File_TestContinuousFileNames_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_testcontinuousfilenames_get")) { return File_TestContinuousFileNames_Get()?"1":"0"; } if (Option_Lower==__T("file_testdirectory")) { File_TestDirectory_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_testdirectory_get")) { return File_TestDirectory_Get()?"1":"0"; } if (Option_Lower==__T("file_keepinfo")) { File_KeepInfo_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_keepinfo_get")) { return File_KeepInfo_Get()?"1":"0"; } if (Option_Lower==__T("file_stopafterfilled")) { File_StopAfterFilled_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_stopafterfilled_get")) { return File_StopAfterFilled_Get()?"1":"0"; } if (Option_Lower==__T("file_stopsubstreamafterfilled")) { File_StopSubStreamAfterFilled_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_stopsubstreamafterfilled_get")) { return File_StopSubStreamAfterFilled_Get()?"1":"0"; } if (Option_Lower==__T("file_audio_mergemonostreams")) { File_Audio_MergeMonoStreams_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_audio_mergemonostreams_get")) { return File_Audio_MergeMonoStreams_Get()?"1":"0"; } else if (Option_Lower==__T("file_demux_interleave")) { File_Demux_Interleave_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_demux_interleave_get")) { return File_Demux_Interleave_Get()?"1":"0"; } else if (Option_Lower==__T("file_id_onlyroot")) { File_ID_OnlyRoot_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_expandsubs")) { File_ExpandSubs_Set(!(Value==__T("0") || Value.empty())); return __T(""); } else if (Option_Lower==__T("file_id_onlyroot_get")) { return File_ID_OnlyRoot_Get()?"1":"0"; } else if (Option_Lower==__T("file_ignoresequencefilesize")) { #if MEDIAINFO_ADVANCED File_IgnoreSequenceFileSize_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_ignoresequencefilescount")) { #if MEDIAINFO_ADVANCED File_IgnoreSequenceFilesCount_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_sequencefilesskipframes") || Option_Lower==__T("file_sequencefileskipframes")) { #if MEDIAINFO_ADVANCED File_SequenceFilesSkipFrames_Set(Ztring(Value).To_int64u()); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_defaultframerate")) { #if MEDIAINFO_ADVANCED File_DefaultFrameRate_Set(Ztring(Value).To_float64()); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("File_DefaultFrameRate is disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_defaulttimecode")) { #if MEDIAINFO_ADVANCED File_DefaultTimeCode_Set(Ztring(Value).To_UTF8()); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("File_DefaultTimeCode is disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_defaulttimecodedropframe")) { #if MEDIAINFO_ADVANCED return File_DefaultTimeCodeDropFrame_Set(Value); #else //MEDIAINFO_ADVANCED return __T("File_DefaultTimeCodeDropFrame is disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_source_list")) { #if MEDIAINFO_ADVANCED File_Source_List_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("File_Source_List_Set is disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_riskybitrateestimation")) { #if MEDIAINFO_ADVANCED File_RiskyBitRateEstimation_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_mergebitrateinfo")) { #if MEDIAINFO_ADVANCED File_MergeBitRateInfo_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_highestformat")) { #if MEDIAINFO_ADVANCED File_HighestFormat_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_channellayout")) { #if MEDIAINFO_ADVANCED File_ChannelLayout_Set(Value==__T("2018")); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_frameisalwayscomplete")) { #if MEDIAINFO_ADVANCED File_FrameIsAlwaysComplete_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features are disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_demux_unpacketize_streamlayoutchange_skip")) { #if MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED File_Demux_Unpacketize_StreamLayoutChange_Skip_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_ADVANCED return __T("Advanced features disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED #else //MEDIAINFO_ADVANCED return __T("Advanced features disabled due to compilation options"); #endif //MEDIAINFO_ADVANCED } else if (Option_Lower==__T("file_md5")) { #if MEDIAINFO_MD5 File_Md5_Set(!(Value==__T("0") || Value.empty())); return Ztring(); #else //MEDIAINFO_MD5 return __T("MD5 is disabled due to compilation options"); #endif //MEDIAINFO_MD5 } else if (Option_Lower==__T("file_hash")) { #if MEDIAINFO_HASH ZtringList List; List.Separator_Set(0, __T(",")); List.Write(Value); ZtringList ToReturn; ToReturn.Separator_Set(0, __T(",")); HashWrapper::HashFunctions Functions; for (size_t i=0; i >* Stream_More=(std::vector >*)File_ExpandSubs_Source; std::vector >* Backup=(std::vector >*)File_ExpandSubs_Backup; *Stream_More=*Backup; Backup->clear(); } delete (std::vector > *)File_ExpandSubs_Backup; File_ExpandSubs_Backup=NULL; } else { //We want the expanded subs File_ExpandSubs_Backup=new std::vector >; } } File_ExpandSubs_Update(NULL); } bool MediaInfo_Config_MediaInfo::File_ExpandSubs_Get () { CriticalSectionLocker CSL(CS); return File_ExpandSubs_Backup?true:false; } void MediaInfo_Config_MediaInfo::File_ExpandSubs_Update(void** Source) { CriticalSectionLocker CSL(CS); if (Source) File_ExpandSubs_Source=*Source; if (!File_ExpandSubs_Source) return; std::vector >* Stream_More=(std::vector >*)File_ExpandSubs_Source; std::vector >* Backup=(std::vector >*)File_ExpandSubs_Backup; //Reset if needed if (File_ExpandSubs_Backup && !Backup->empty()) { *Stream_More=*Backup; Backup->clear(); } if (File_ExpandSubs_Backup) { //Backup *Backup=*Stream_More; //Sub-elements //for (set::iterator File_ExpandSubs_Item=File_ExpandSubs_Items.begin(); File_ExpandSubs_Item!=File_ExpandSubs_Items.end(); ++File_ExpandSubs_Item) for (size_t i=0; i<6; i++) { //const Ztring Sub=Ztring().From_UTF8(*File_ExpandSubs_Item); for (size_t StreamKind=Stream_General; StreamKind4*1024) break; // Too big, arbitrary stop ZtringListList Temp; size_t Pos_Max=(*Stream_More)[StreamKind][StreamPos].size(); for (size_t Pos=0; PosInfo_Name_Text) { Ztring& Name=(*Stream_More)[StreamKind][StreamPos][Pos][Info_Name]; // Tree size_t Up_Pos=Name.find(__T(" LinkedTo_")); size_t Up_Pos_End=string::npos; if (Up_Pos!=string::npos) Up_Pos_End=Name.find(__T("_Pos"), Name.size()-4); if (Up_Pos!=string::npos && Up_Pos_End==Name.size()-4) { Ztring Up=Name.substr(Up_Pos); auto IsComplementary=Up.FindAndReplace(__T("Complementary"), Ztring()); //Hide Ztring ToHide=Name+__T("/String"); for (size_t j=Pos+1; j<(*Stream_More)[StreamKind][StreamPos].size(); j++) { if ((*Stream_More)[StreamKind][StreamPos][j][Info_Name]==ToHide) { ZtringList& ToHideList=(*Stream_More)[StreamKind][StreamPos][j]; ToHideList[Info_Options]=__T("N NT"); break; } } //Expand size_t SpacesCount=1; size_t SpacesTestPos=Name.size()-Up.size(); while (SpacesTestPos && (SpacesTestPos=Name.rfind(__T(' '), SpacesTestPos-1))!=string::npos) SpacesCount++; ZtringList L; L.Separator_Set(0, __T(" + ")); L.Write((*Stream_More)[StreamKind][StreamPos][Pos][Info_Text]); for (size_t i=0; i=ToSearch2.size()) { Ztring Name=ToSearch; if ((*Stream_More)[StreamKind][StreamPos][j][Info_Name].size()>ToSearch2.size()) Name+=__T(' ')+(*Stream_More)[StreamKind][StreamPos][j][Info_Name].substr(ToSearch2.size()+1); size_t IsFound=(size_t)-1; for (size_t k=Pos+1; kInfo_Name_Text) { // Text Ztring Name=Field[Info_Name]; size_t Spaces=0; size_t i=0; bool Nested=false; for (;;) { size_t j=Name.find(__T(' '), i); if (!j) Nested=true; if (j==(size_t)-1) break; i=j+1; Spaces++; } //if (Spaces) { size_t j; if (i>=2 && Pos && i-2==Track[Pos-1][Info_Name].size()) j=2; else j=1; size_t PosPrevious=Pos; if (PosPrevious) PosPrevious--; while (PosPrevious && Track[PosPrevious][Info_Name][0]==__T(' ')) // avoid injected lines PosPrevious--; if (!Nested && Spaces && Pos && i && i-j<=Track[PosPrevious][Info_Name].size() && Name.substr(0, i-j)==Track[PosPrevious][Info_Name].substr(0, i-j) && Info_Name_Text Numbers; if (!Name.empty() && Pos+11 && Name.back()==__T('_')) { auto Last2=Name[Name.size()-2]; if (Last2>='0' && Last2<='9') Name.pop_back(); } auto& Number=Numbers[i]; if (Number) Name+=MediaInfoLib::Config.Language_Get(__T(" Config_Text_NumberTag"))+Ztring::ToZtring(Number); } Names.Separator_Set(0, __T(" ")); Names.Quote_Set(__T("")); (*Stream_More)[StreamKind][StreamPos][Pos][Info_Name_Text]=Names.Read(); } } } } } //--------------------------------------------------------------------------- #if MEDIAINFO_MD5 void MediaInfo_Config_MediaInfo::File_Md5_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Md5=NewValue; Hash_Functions.set(HashWrapper::MD5, NewValue); } bool MediaInfo_Config_MediaInfo::File_Md5_Get () { CriticalSectionLocker CSL(CS); return Hash_Functions[HashWrapper::MD5]; } #endif //MEDIAINFO_MD5 //--------------------------------------------------------------------------- #if MEDIAINFO_HASH void MediaInfo_Config_MediaInfo::File_Hash_Set (HashWrapper::HashFunctions Funtions) { CriticalSectionLocker CSL(CS); Hash_Functions=Funtions; //Legacy if (File_Md5) Hash_Functions.set(HashWrapper::MD5); } HashWrapper::HashFunctions MediaInfo_Config_MediaInfo::File_Hash_Get () { CriticalSectionLocker CSL(CS); return Hash_Functions; } #endif //MEDIAINFO_HASH //--------------------------------------------------------------------------- #if defined(MEDIAINFO_REFERENCES_YES) void MediaInfo_Config_MediaInfo::File_CheckSideCarFiles_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_CheckSideCarFiles=NewValue; } bool MediaInfo_Config_MediaInfo::File_CheckSideCarFiles_Get () { CriticalSectionLocker CSL(CS); return File_CheckSideCarFiles; } #endif //defined(MEDIAINFO_REFERENCES_YES) //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_IgnoreSequenceFileSize_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_IgnoreSequenceFileSize=NewValue; } bool MediaInfo_Config_MediaInfo::File_IgnoreSequenceFileSize_Get () { CriticalSectionLocker CSL(CS); return File_IgnoreSequenceFileSize; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_IgnoreSequenceFilesCount_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_IgnoreSequenceFilesCount=NewValue; } bool MediaInfo_Config_MediaInfo::File_IgnoreSequenceFilesCount_Get () { CriticalSectionLocker CSL(CS); return File_IgnoreSequenceFilesCount; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_SequenceFilesSkipFrames_Set (int64u NewValue) { CriticalSectionLocker CSL(CS); File_SequenceFilesSkipFrames=NewValue; } int64u MediaInfo_Config_MediaInfo::File_SequenceFilesSkipFrames_Get () { CriticalSectionLocker CSL(CS); return File_SequenceFilesSkipFrames; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_DefaultFrameRate_Set (float64 NewValue) { CriticalSectionLocker CSL(CS); File_DefaultFrameRate=NewValue; #if MEDIAINFO_DEMUX Demux_Rate=File_DefaultFrameRate; #endif //MEDIAINFO_DEMUX } float64 MediaInfo_Config_MediaInfo::File_DefaultFrameRate_Get () { CriticalSectionLocker CSL(CS); return File_DefaultFrameRate; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_DefaultTimeCode_Set(string NewValue) { CriticalSectionLocker CSL(CS); File_DefaultTimeCode = NewValue; } string MediaInfo_Config_MediaInfo::File_DefaultTimeCode_Get() { CriticalSectionLocker CSL(CS); return File_DefaultTimeCode; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED Ztring MediaInfo_Config_MediaInfo::File_DefaultTimeCodeDropFrame_Set(const String& NewValue) { int8u NewValueI; if (NewValue.empty()) NewValueI=(int8u)-1; else if (NewValue.size()==1 && NewValue[0]>=__T('0') && NewValue[0] <=__T('1')) NewValueI=NewValue[0]-__T('0'); else return __T("File_DefaultTimeCodeDropFrame value must be empty, 0 or 1"); CriticalSectionLocker CSL(CS); File_DefaultTimeCodeDropFrame=NewValueI; return Ztring(); } int8u MediaInfo_Config_MediaInfo::File_DefaultTimeCodeDropFrame_Get() { CriticalSectionLocker CSL(CS); return File_DefaultTimeCodeDropFrame; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_Source_List_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Source_List=NewValue; } bool MediaInfo_Config_MediaInfo::File_Source_List_Get () { CriticalSectionLocker CSL(CS); return File_Source_List; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_RiskyBitRateEstimation_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_RiskyBitRateEstimation=NewValue; } bool MediaInfo_Config_MediaInfo::File_RiskyBitRateEstimation_Get () { CriticalSectionLocker CSL(CS); return File_RiskyBitRateEstimation; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_MergeBitRateInfo_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_MergeBitRateInfo=NewValue; } bool MediaInfo_Config_MediaInfo::File_MergeBitRateInfo_Get () { CriticalSectionLocker CSL(CS); return File_MergeBitRateInfo; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_ChannelLayout_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_ChannelLayout =NewValue; } bool MediaInfo_Config_MediaInfo::File_ChannelLayout_Get () { CriticalSectionLocker CSL(CS); return File_ChannelLayout; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_HighestFormat_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_HighestFormat=NewValue; } bool MediaInfo_Config_MediaInfo::File_HighestFormat_Get () { CriticalSectionLocker CSL(CS); return File_HighestFormat; } #endif //MEDIAINFO_ADVANCED //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX #if MEDIAINFO_ADVANCED void MediaInfo_Config_MediaInfo::File_Demux_Unpacketize_StreamLayoutChange_Skip_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Demux_Unpacketize_StreamLayoutChange_Skip=NewValue; } bool MediaInfo_Config_MediaInfo::File_Demux_Unpacketize_StreamLayoutChange_Skip_Get () { CriticalSectionLocker CSL(CS); return File_Demux_Unpacketize_StreamLayoutChange_Skip; } #endif //MEDIAINFO_ADVANCED #endif //MEDIAINFO_DEMUX //*************************************************************************** // File name from somewhere else //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_FileName_Set (const Ztring &NewValue) { CriticalSectionLocker CSL(CS); File_FileName=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_FileName_Get () { CriticalSectionLocker CSL(CS); return File_FileName; } //*************************************************************************** // File name format //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_FileNameFormat_Set (const Ztring &NewValue) { CriticalSectionLocker CSL(CS); File_FileNameFormat=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_FileNameFormat_Get () { CriticalSectionLocker CSL(CS); return File_FileNameFormat; } //*************************************************************************** // Time to live //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_TimeToLive_Set (float64 NewValue) { CriticalSectionLocker CSL(CS); File_TimeToLive=NewValue; } float64 MediaInfo_Config_MediaInfo::File_TimeToLive_Get () { CriticalSectionLocker CSL(CS); return File_TimeToLive; } //*************************************************************************** // Partial file (begin and end are cut) //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Partial_Begin_Set (const Ztring &NewValue) { CriticalSectionLocker CSL(CS); File_Partial_Begin=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_Partial_Begin_Get () { CriticalSectionLocker CSL(CS); return File_Partial_Begin; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Partial_End_Set (const Ztring &NewValue) { CriticalSectionLocker CSL(CS); File_Partial_End=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_Partial_End_Get () { CriticalSectionLocker CSL(CS); return File_Partial_End; } //*************************************************************************** // Force Parser //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_ForceParser_Set (const Ztring &NewValue) { CriticalSectionLocker CSL(CS); File_ForceParser=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_ForceParser_Get () { CriticalSectionLocker CSL(CS); return File_ForceParser; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_ForceParser_Config_Set (const Ztring &NewValue) { CriticalSectionLocker CSL(CS); File_ForceParser_Config=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_ForceParser_Config_Get () { CriticalSectionLocker CSL(CS); return File_ForceParser_Config; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Buffer_Size_Hint_Pointer_Set (size_t* NewValue) { CriticalSectionLocker CSL(CS); File_Buffer_Size_Hint_Pointer=NewValue; } size_t* MediaInfo_Config_MediaInfo::File_Buffer_Size_Hint_Pointer_Get () { CriticalSectionLocker CSL(CS); return File_Buffer_Size_Hint_Pointer; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Buffer_Read_Size_Set (size_t NewValue) { CriticalSectionLocker CSL(CS); File_Buffer_Read_Size=NewValue; } size_t MediaInfo_Config_MediaInfo::File_Buffer_Read_Size_Get () { CriticalSectionLocker CSL(CS); return File_Buffer_Read_Size; } //*************************************************************************** // Filter //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_FILTER void MediaInfo_Config_MediaInfo::File_Filter_Set (int64u NewValue) { CriticalSectionLocker CSL(CS); File_Filter_16[(int16u)NewValue]=true; File_Filter_HasChanged_=true; } bool MediaInfo_Config_MediaInfo::File_Filter_Get (const int16u Value) { CriticalSectionLocker CSL(CS); //Test bool Exists; if (File_Filter_16.empty()) Exists=true; else Exists=(File_Filter_16.find(Value)!=File_Filter_16.end()); return Exists; } bool MediaInfo_Config_MediaInfo::File_Filter_Get () { CriticalSectionLocker CSL(CS); bool Exist=!File_Filter_16.empty(); return Exist; } void MediaInfo_Config_MediaInfo::File_Filter_Audio_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Filter_Audio=NewValue; } bool MediaInfo_Config_MediaInfo::File_Filter_Audio_Get () { CriticalSectionLocker CSL(CS); return File_Filter_Audio; } bool MediaInfo_Config_MediaInfo::File_Filter_HasChanged () { CriticalSectionLocker CSL(CS); bool File_Filter_HasChanged_Temp=File_Filter_HasChanged_; File_Filter_HasChanged_=false; return File_Filter_HasChanged_Temp; } #endif //MEDIAINFO_FILTER //*************************************************************************** // Duplicate //*************************************************************************** #if MEDIAINFO_DUPLICATE Ztring MediaInfo_Config_MediaInfo::File_Duplicate_Set (const Ztring &Value_In) { //Preparing for File__Duplicate... Ztring ToReturn; { CriticalSectionLocker CSL(CS); File__Duplicate_List.push_back(Value_In); //Handling Memory index ZtringList List=Value_In; for (size_t Pos=0; Pos=File__Duplicate_List.size()) return Ztring(); //Nothing or not more than the last time return File__Duplicate_List[AlreadyRead_Pos]; } bool MediaInfo_Config_MediaInfo::File_Duplicate_Get_AlwaysNeeded (size_t AlreadyRead_Pos) { CriticalSectionLocker CSL(CS); bool Temp=AlreadyRead_Pos>=File__Duplicate_List.size(); return !Temp; //True if there is something to read } size_t MediaInfo_Config_MediaInfo::File__Duplicate_Memory_Indexes_Get (const Ztring &Value) { CriticalSectionLocker CSL(CS); return File__Duplicate_Memory_Indexes.Find(Value); } void MediaInfo_Config_MediaInfo::File__Duplicate_Memory_Indexes_Erase (const Ztring &Value) { CriticalSectionLocker CSL(CS); size_t Pos=File__Duplicate_Memory_Indexes.Find(Value); if (Pos!=Error) File__Duplicate_Memory_Indexes[Pos].clear(); } #endif //MEDIAINFO_DUPLICATE //*************************************************************************** // Demux //*************************************************************************** #if MEDIAINFO_DEMUX //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_ForceIds_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_ForceIds=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_ForceIds_Get () { CriticalSectionLocker CSL(CS); return Demux_ForceIds; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo16bit_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_PCM_20bitTo16bit=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo16bit_Get () { CriticalSectionLocker CSL(CS); return Demux_PCM_20bitTo16bit; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo24bit_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_PCM_20bitTo24bit=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_PCM_20bitTo24bit_Get () { CriticalSectionLocker CSL(CS); return Demux_PCM_20bitTo24bit; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10_Get () { CriticalSectionLocker CSL(CS); return Demux_Avc_Transcode_Iso14496_15_to_Iso14496_10; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_Hevc_Transcode_Iso14496_15_to_AnnexB=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_Hevc_Transcode_Iso14496_15_to_AnnexB_Get () { CriticalSectionLocker CSL(CS); return Demux_Hevc_Transcode_Iso14496_15_to_AnnexB; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Demux_Unpacketize_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Demux_Unpacketize=NewValue; } bool MediaInfo_Config_MediaInfo::Demux_Unpacketize_Get () { CriticalSectionLocker CSL(CS); return Demux_Unpacketize; } #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX void MediaInfo_Config_MediaInfo::Demux_SplitAudioBlocks_Set(bool NewValue) { CriticalSectionLocker CSL(CS); Demux_SplitAudioBlocks = NewValue; } bool MediaInfo_Config_MediaInfo::Demux_SplitAudioBlocks_Get() { CriticalSectionLocker CSL(CS); return Demux_SplitAudioBlocks; } #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- #if 1 //MEDIAINFO_DEMUX void MediaInfo_Config_MediaInfo::Demux_Rate_Set (float64 NewValue) { CriticalSectionLocker CSL(CS); Demux_Rate=NewValue; } float64 MediaInfo_Config_MediaInfo::Demux_Rate_Get () { CriticalSectionLocker CSL(CS); return Demux_Rate; } #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX void MediaInfo_Config_MediaInfo::Demux_FirstDts_Set (int64u NewValue) { CriticalSectionLocker CSL(CS); Demux_FirstDts=NewValue; } int64u MediaInfo_Config_MediaInfo::Demux_FirstDts_Get () { CriticalSectionLocker CSL(CS); return Demux_FirstDts; } #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX void MediaInfo_Config_MediaInfo::Demux_FirstFrameNumber_Set (int64u NewValue) { CriticalSectionLocker CSL(CS); Demux_FirstFrameNumber=NewValue; } int64u MediaInfo_Config_MediaInfo::Demux_FirstFrameNumber_Get () { CriticalSectionLocker CSL(CS); return Demux_FirstFrameNumber; } #endif //MEDIAINFO_DEMUX //--------------------------------------------------------------------------- #if MEDIAINFO_DEMUX void MediaInfo_Config_MediaInfo::Demux_InitData_Set (int8u NewValue) { CriticalSectionLocker CSL(CS); Demux_InitData=NewValue; } int8u MediaInfo_Config_MediaInfo::Demux_InitData_Get () { CriticalSectionLocker CSL(CS); return Demux_InitData; } #endif //MEDIAINFO_DEMUX //*************************************************************************** // IBI support //*************************************************************************** #if MEDIAINFO_IBIUSAGE //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Ibi_Set (const Ztring &Value) { string Data_Base64=Value.To_UTF8(); CriticalSectionLocker CSL(CS); Ibi=Base64::decode(Data_Base64); } string MediaInfo_Config_MediaInfo::Ibi_Get () { CriticalSectionLocker CSL(CS); return Ibi; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Ibi_UseIbiInfoIfAvailable_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Ibi_UseIbiInfoIfAvailable=NewValue; } bool MediaInfo_Config_MediaInfo::Ibi_UseIbiInfoIfAvailable_Get () { CriticalSectionLocker CSL(CS); return Ibi_UseIbiInfoIfAvailable; } #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_IBIUSAGE //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Ibi_Create_Set (bool NewValue) { CriticalSectionLocker CSL(CS); Ibi_Create=NewValue; } bool MediaInfo_Config_MediaInfo::Ibi_Create_Get () { CriticalSectionLocker CSL(CS); return Ibi_Create; } #endif //MEDIAINFO_IBIUSAGE #if MEDIAINFO_FIXITY //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::TryToFix_Set (bool NewValue) { CriticalSectionLocker CSL(CS); TryToFix=NewValue; } bool MediaInfo_Config_MediaInfo::TryToFix_Get () { CriticalSectionLocker CSL(CS); return TryToFix || MediaInfoLib::Config.TryToFix_Get(); } #endif //MEDIAINFO_FIXITY //*************************************************************************** // Encryption //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Format_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_format Encryption_Format_Temp=Encryption_Format_None; if (Data=="AES") Encryption_Format_Temp=Encryption_Format_Aes; CriticalSectionLocker CSL(CS); Encryption_Format=Encryption_Format_Temp; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Encryption_Format_Set (encryption_format Value) { CriticalSectionLocker CSL(CS); Encryption_Format=Value; } string MediaInfo_Config_MediaInfo::Encryption_Format_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Format) { case Encryption_Format_Aes: return "AES"; default: return string(); } } encryption_format MediaInfo_Config_MediaInfo::Encryption_Format_Get () { CriticalSectionLocker CSL(CS); return Encryption_Format; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Key_Set (const Ztring &Value) { string Data_Base64=Value.To_UTF8(); CriticalSectionLocker CSL(CS); Encryption_Key=Base64::decode(Data_Base64); } void MediaInfo_Config_MediaInfo::Encryption_Key_Set (const int8u* Value, size_t Value_Size) { CriticalSectionLocker CSL(CS); Encryption_Key=string((const char*)Value, Value_Size); } string MediaInfo_Config_MediaInfo::Encryption_Key_Get () { CriticalSectionLocker CSL(CS); return Encryption_Key; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Method_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_method Encryption_Method_Temp=Encryption_Method_None; if (Data=="Segment") Encryption_Method_Temp=Encryption_Method_Segment; CriticalSectionLocker CSL(CS); Encryption_Method=Encryption_Method_Temp; } void MediaInfo_Config_MediaInfo::Encryption_Method_Set (encryption_method Value) { CriticalSectionLocker CSL(CS); Encryption_Method=Value; } string MediaInfo_Config_MediaInfo::Encryption_Method_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Method) { case Encryption_Method_Segment: return "Segment"; default: return string(); } } encryption_method MediaInfo_Config_MediaInfo::Encryption_Method_Get () { CriticalSectionLocker CSL(CS); return Encryption_Method; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Mode_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_mode Encryption_Mode_Temp=Encryption_Mode_None; if (Data=="CBC") Encryption_Mode_Temp=Encryption_Mode_Cbc; CriticalSectionLocker CSL(CS); Encryption_Mode=Encryption_Mode_Temp; } void MediaInfo_Config_MediaInfo::Encryption_Mode_Set (encryption_mode Value) { CriticalSectionLocker CSL(CS); Encryption_Mode=Value; } string MediaInfo_Config_MediaInfo::Encryption_Mode_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Mode) { case Encryption_Mode_Cbc: return "CBC"; default: return string(); } } encryption_mode MediaInfo_Config_MediaInfo::Encryption_Mode_Get () { CriticalSectionLocker CSL(CS); return Encryption_Mode; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_Padding_Set (const Ztring &Value) { string Data=Value.To_UTF8(); encryption_padding Encryption_Padding_Temp=Encryption_Padding_None; if (Data=="PKCS7") Encryption_Padding_Temp=Encryption_Padding_Pkcs7; CriticalSectionLocker CSL(CS); Encryption_Padding=Encryption_Padding_Temp; } void MediaInfo_Config_MediaInfo::Encryption_Padding_Set (encryption_padding Value) { CriticalSectionLocker CSL(CS); Encryption_Padding=Value; } string MediaInfo_Config_MediaInfo::Encryption_Padding_GetS () { CriticalSectionLocker CSL(CS); switch (Encryption_Padding) { case Encryption_Padding_Pkcs7: return "PKCS7"; default: return string(); } } encryption_padding MediaInfo_Config_MediaInfo::Encryption_Padding_Get () { CriticalSectionLocker CSL(CS); return Encryption_Padding; } #endif //MEDIAINFO_AES //--------------------------------------------------------------------------- #if MEDIAINFO_AES void MediaInfo_Config_MediaInfo::Encryption_InitializationVector_Set (const Ztring &Value) { if (Value==__T("Sequence number")) { CriticalSectionLocker CSL(CS); Encryption_InitializationVector="Sequence number"; } else { string Data_Base64=Value.To_UTF8(); CriticalSectionLocker CSL(CS); Encryption_InitializationVector=Base64::decode(Data_Base64); } } string MediaInfo_Config_MediaInfo::Encryption_InitializationVector_Get () { CriticalSectionLocker CSL(CS); return Encryption_InitializationVector; } #endif //MEDIAINFO_AES //*************************************************************************** // NextPacket //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_NEXTPACKET void MediaInfo_Config_MediaInfo::NextPacket_Set (bool NewValue) { CriticalSectionLocker CSL(CS); NextPacket=NewValue; } bool MediaInfo_Config_MediaInfo::NextPacket_Get () { CriticalSectionLocker CSL(CS); return NextPacket; } #endif //MEDIAINFO_NEXTPACKET //*************************************************************************** // SubFile //*************************************************************************** #if MEDIAINFO_EVENTS //--------------------------------------------------------------------------- ZtringListList MediaInfo_Config_MediaInfo::SubFile_Config_Get () { CriticalSectionLocker CSL(CS); return SubFile_Config; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::SubFile_StreamID_Set (int64u Value) { CriticalSectionLocker CSL(CS); SubFile_StreamID=Value; } //--------------------------------------------------------------------------- int64u MediaInfo_Config_MediaInfo::SubFile_StreamID_Get () { CriticalSectionLocker CSL(CS); return SubFile_StreamID; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::SubFile_IDs_Set (Ztring Value) { CriticalSectionLocker CSL(CS); SubFile_IDs=Value; } //--------------------------------------------------------------------------- Ztring MediaInfo_Config_MediaInfo::SubFile_IDs_Get () { CriticalSectionLocker CSL(CS); return SubFile_IDs; } #endif //MEDIAINFO_EVENTS //*************************************************************************** // SubFile //*************************************************************************** #if MEDIAINFO_EVENTS //--------------------------------------------------------------------------- bool MediaInfo_Config_MediaInfo::ParseUndecodableFrames_Get () { CriticalSectionLocker CSL(CS); return ParseUndecodableFrames; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::ParseUndecodableFrames_Set (bool Value) { CriticalSectionLocker CSL(CS); ParseUndecodableFrames=Value; } #endif //MEDIAINFO_EVENTS //*************************************************************************** // Event //*************************************************************************** //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS bool MediaInfo_Config_MediaInfo::Event_CallBackFunction_IsSet () { CriticalSectionLocker CSL(CS); return Event_CallBackFunction?true:false; } #endif //MEDIAINFO_EVENTS //--------------------------------------------------------------------------- #if MEDIAINFO_EVENTS Ztring MediaInfo_Config_MediaInfo::Event_CallBackFunction_Set (const Ztring &Value) { ZtringList List=Value; CriticalSectionLocker CSL(CS); if (List.empty()) { Event_CallBackFunction=(MediaInfo_Event_CallBackFunction*)NULL; Event_UserHandler=NULL; } else for (size_t Pos=0; PosFrameNumber!=(int64u)-1) Temp->FrameNumber+=Demux_Offset_Frame; if (Temp->FrameNumber_PresentationOrder!=(int64u)-1) Temp->FrameNumber_PresentationOrder+=Demux_Offset_Frame; } if (Demux_Offset_DTS!=(int64u)-1) { if (Temp->DTS!=(int64u)-1) Temp->DTS+=Demux_Offset_DTS; if (Temp->PTS!=(int64u)-1) Temp->PTS+=Demux_Offset_DTS; if (Demux_Offset_DTS_FromStream!=(int64u)-1) { if (Temp->DTS!=(int64u)-1) Temp->DTS-=Demux_Offset_DTS_FromStream; if (Temp->PTS!=(int64u)-1) Temp->PTS-=Demux_Offset_DTS_FromStream; } } #endif //MEDIAINFO_DEMUX if (File_IgnoreEditsBefore) { if (Temp->FrameNumber!=(int64u)-1) { if (Temp->FrameNumber>File_IgnoreEditsBefore) Temp->FrameNumber-=File_IgnoreEditsBefore; else Temp->FrameNumber=0; } if (Temp->DTS!=(int64u)-1) { if (File_EditRate) { int64u TimeOffset=float64_int64s(((float64)File_IgnoreEditsBefore)/File_EditRate*1000000000); if (Temp->DTS>TimeOffset) Temp->DTS-=TimeOffset; else Temp->DTS=0; } } if (Temp->PTS!=(int64u)-1) { if (File_IgnoreEditsBefore && File_EditRate) { int64u TimeOffset=float64_int64s(((float64)File_IgnoreEditsBefore)/File_EditRate*1000000000); if (Temp->PTS>TimeOffset) Temp->PTS-=TimeOffset; else Temp->PTS=0; } } } } //Adaptation of time stamps if (!FileIsReferenced && !Events_TimestampShift_Disabled) { MediaInfo_Event_Generic* Event=(MediaInfo_Event_Generic*)Data_Content; if (Event->StreamIDs_Size>=2 && Event->EventCode!=(MediaInfo_Parser_DvDif<<24 | MediaInfo_Event_DvDif_Analysis_Frame<<8) && Event->ParserIDs[0]==MediaInfo_Parser_MpegTs && Event->ParserIDs[1]==MediaInfo_Parser_MpegPs) { //Catching reference stream if (Event->StreamIDs[1]==0xE0 && Events_TimestampShift_Reference_ID==(int64u)-1) Events_TimestampShift_Reference_ID=Event->StreamIDs[0]; //Store the last PTS of the reference stream if (Events_TimestampShift_Reference_ID==Event->StreamIDs[0] && Event->PTS!=(int64u)-1) Events_TimestampShift_Reference_PTS=Event->PTS; //Sending events whose were delayed if (!Events_TimestampShift_Delayed.empty() && Events_TimestampShift_Reference_ID!=(int64u)-1 && Event->PTS!=(int64u)-1) { Events_TimestampShift_Disabled=true; //Disable the sending of events in the next call for (size_t Pos=0; PosData_Content, Events_TimestampShift_Delayed[Pos]->Data_Size, Events_TimestampShift_Delayed[Pos]->File_Name); CS.Enter(); int32u EventCode=*((int32u*)Events_TimestampShift_Delayed[Pos]->Data_Content); bool IsSimpleText=(EventCode&0x00FFFF00)==(MediaInfo_Event_Global_SimpleText<<8); if (IsSimpleText) { MediaInfo_Event_Global_SimpleText_0* Old=(MediaInfo_Event_Global_SimpleText_0*)Events_TimestampShift_Delayed[Pos]->Data_Content; delete[] Old->Content; //Old->Content=NULL; if (Old->Row_Values) { for (size_t Row_Pos=0; Row_PosRow_Max; Row_Pos++) delete[] Old->Row_Values[Row_Pos]; // Row_Values[Row_Pos]=NULL; delete[] Old->Row_Values; //Old->Row_Values=NULL; } if (Old->Row_Attributes) { for (size_t Row_Pos=0; Row_PosRow_Max; Row_Pos++) delete[] Old->Row_Attributes[Row_Pos]; // Row_Attributes[Row_Pos]=NULL; delete[] Old->Row_Attributes; //Old->Row_Attributes=NULL; } } delete Events_TimestampShift_Delayed[Pos]; //Events_TimestampShift_Delayed[Pos]=NULL; } Events_TimestampShift_Delayed.clear(); Events_TimestampShift_Disabled=false; } //MediaInfo_Event_Global_SimpleText if ((Event->EventCode &0x00FFFF00)==(MediaInfo_Event_Global_SimpleText<<8)) //If it is MediaInfo_Event_Global_SimpleText { //Store the event if there is no reference stream if (Events_TimestampShift_Reference_ID==(int64u)-1 || Events_TimestampShift_Reference_PTS==(int64u)-1) { event_delayed* Event=new event_delayed(Data_Content, Data_Size, File_Name); Events_TimestampShift_Delayed.push_back(Event); // Copying buffers int32u* EventCode=(int32u*)Data_Content; if (((*EventCode)&0x00FFFFFF)==(MediaInfo_Event_Global_SimpleText<<8) && Data_Size==sizeof(MediaInfo_Event_Global_SimpleText_0)) { MediaInfo_Event_Global_SimpleText_0* Old=(MediaInfo_Event_Global_SimpleText_0*)Data_Content; MediaInfo_Event_Global_SimpleText_0* New=(MediaInfo_Event_Global_SimpleText_0*)Event->Data_Content; if (New->Content) { size_t Content_Size=wcslen(New->Content); wchar_t* Content=new wchar_t[Content_Size+1]; std::memcpy(Content, Old->Content, (Content_Size+1)*sizeof(wchar_t)); New->Content=Content; } if (New->Row_Values) { wchar_t** Row_Values=new wchar_t*[New->Row_Max]; for (size_t Row_Pos=0; Row_PosRow_Max; Row_Pos++) { Row_Values[Row_Pos]=new wchar_t[New->Column_Max]; std::memcpy(Row_Values[Row_Pos], Old->Row_Values[Row_Pos], New->Column_Max*sizeof(wchar_t)); } New->Row_Values=Row_Values; } if (New->Row_Attributes) { int8u** Row_Attributes=new int8u*[New->Row_Max]; for (size_t Row_Pos=0; Row_PosRow_Max; Row_Pos++) { Row_Attributes[Row_Pos]=new int8u[New->Column_Max]; std::memcpy(Row_Attributes[Row_Pos], Old->Row_Attributes[Row_Pos], New->Column_Max*sizeof(int8u)); } New->Row_Attributes=Row_Attributes; } } return; } //Shift of the PTS if difference is too huge if (Event->PTS>Events_TimestampShift_Reference_PTS+60000000000LL) // difference more than 60 seconds { int64u Shift= Event->PTS -Events_TimestampShift_Reference_PTS; if (Shift>=55555555555555LL-10000000000LL && Shift<=55555555555555LL+10000000000LL) //+/- 10 second Shift=55555555555555LL; if (Event->PTS!=(int64u)-1) Event->PTS-=Shift; if (Event->DTS!=(int64u)-1) Event->DTS-=Shift; } } } } if (Source) { event_delayed* Event=new event_delayed(Data_Content, Data_Size, File_Name); Events_Delayed[Source].push_back(Event); // Copying buffers int32u* EventCode=(int32u*)Data_Content; if (((*EventCode)&0x00FFFFFF)==((MediaInfo_Event_Global_Demux<<8)|4) && Data_Size==sizeof(MediaInfo_Event_Global_Demux_4)) { MediaInfo_Event_Global_Demux_4* Old=(MediaInfo_Event_Global_Demux_4*)Data_Content; MediaInfo_Event_Global_Demux_4* New=(MediaInfo_Event_Global_Demux_4*)Event->Data_Content; if (New->Content_Size) { int8u* Content=new int8u[New->Content_Size]; std::memcpy(Content, Old->Content, New->Content_Size*sizeof(int8u)); New->Content=Content; } if (New->Offsets_Size) { int64u* Offsets_Stream=new int64u[New->Offsets_Size]; std::memcpy(Offsets_Stream, Old->Offsets_Stream, New->Offsets_Size*sizeof(int64u)); New->Offsets_Stream=Offsets_Stream; int64u* Offsets_Content=new int64u[New->Offsets_Size]; std::memcpy(Offsets_Content, Old->Offsets_Content, New->Offsets_Size*sizeof(int64u)); New->Offsets_Content=Offsets_Content; } if (New->OriginalContent_Size) { int8u* OriginalContent=new int8u[New->OriginalContent_Size]; std::memcpy(OriginalContent, Old->OriginalContent, New->OriginalContent_Size*sizeof(int8u)); New->OriginalContent=OriginalContent; } } } else if (Event_CallBackFunction) { MEDIAINFO_DEBUG1( "CallBackFunction", Debug+=", EventID=";Debug+=Ztring::ToZtring(LittleEndian2int32u(Data_Content), 16).To_UTF8();) Event_CallBackFunction ((unsigned char*)Data_Content, Data_Size, Event_UserHandler); MEDIAINFO_DEBUG2( "CallBackFunction", ) } #if MEDIAINFO_DEMUX else if (!File_Name.empty()) { MediaInfo_Event_Generic* Event_Generic=(MediaInfo_Event_Generic*)Data_Content; if ((Event_Generic->EventCode&0x00FFFFFF)==((MediaInfo_Event_Global_Demux<<8)|0x04)) //Demux version 4 { if (!MediaInfoLib::Config.Demux_Get()) return; MediaInfo_Event_Global_Demux_4* Event=(MediaInfo_Event_Global_Demux_4*)Data_Content; Ztring File_Name_Final(File_Name); if (Event->StreamIDs_Size==0) File_Name_Final+=__T(".demux"); else for (size_t Pos=0; PosStreamIDs_Size; Pos++) { if (Event->StreamIDs_Width[Pos]==17) { Ztring ID; ID.From_CC4((int32u)Event->StreamIDs[Pos]); File_Name_Final+=__T('.')+ID; } else if (Event->StreamIDs_Width[Pos]) { Ztring ID; ID.From_Number(Event->StreamIDs[Pos], 16); while (ID.size()StreamIDs_Width[Pos]) ID.insert(0, 1, __T('0')); if (ID.size()>Event->StreamIDs_Width[Pos]) ID.erase(0, ID.size()-Event->StreamIDs_Width[Pos]); File_Name_Final+=__T('.')+ID; } else File_Name_Final+=__T(".raw"); } std::map::iterator F = Demux_Files.find(File_Name_Final); if (F == Demux_Files.end()) { Demux_Files[File_Name_Final].Open(File_Name_Final, File::Access_Write_Append); F = Demux_Files.find(File_Name_Final); } F->second.Write(Event->Content, Event->Content_Size); } } #endif //MEDIAINFO_DEMUX } void MediaInfo_Config_MediaInfo::Event_Accepted (File__Analyze* Source) { #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (Demux_EventWasSent && NextPacket_Get()) { Events_Delayed_CurrentSource=Source; return; } #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET for (events_delayed::iterator Event=Events_Delayed.begin(); Event!=Events_Delayed.end(); ++Event) if (Event->first==Source) { for (size_t Pos=0; Possecond.size(); Pos++) if (Event->second[Pos]) { Event_Send(NULL, Event->second[Pos]->Data_Content, Event->second[Pos]->Data_Size, Event->second[Pos]->File_Name); int32u EventCode=*((int32u*)Event->second[Pos]->Data_Content); bool IsDemux=(EventCode&0x00FFFF00)==(MediaInfo_Event_Global_Demux<<8); if (IsDemux) { MediaInfo_Event_Global_Demux_4* Old=(MediaInfo_Event_Global_Demux_4*)Event->second[Pos]->Data_Content; delete[] Old->Content; Old->Content=NULL; if (Old->Offsets_Size) { delete[] Old->Offsets_Content; Old->Offsets_Content=NULL; } if (Old->Offsets_Size) { delete[] Old->OriginalContent; Old->OriginalContent=NULL; } } delete Event->second[Pos]; Event->second[Pos]=NULL; #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET if (IsDemux && NextPacket_Get()) { Demux_EventWasSent=true; Event->second.erase(Event->second.begin(), Event->second.begin()+Pos); Events_Delayed_CurrentSource=Source; return; } #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET } Events_Delayed.erase(Event->first); return; } } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Event_SubFile_Start(const Ztring &FileName_Absolute) { Ztring FileName_Relative; if (File_Names_RootDirectory.empty()) { FileName FN(FileName_Absolute); FileName_Relative=FN.Name_Get(); if (!FN.Extension_Get().empty()) { FileName_Relative+=__T('.'); FileName_Relative+=FN.Extension_Get(); } } else { Ztring Root=File_Names_RootDirectory+PathSeparator; FileName_Relative=FileName_Absolute; if (FileName_Relative.find(Root)==0) FileName_Relative.erase(0, Root.size()); } struct MediaInfo_Event_General_SubFile_Start_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(0, MediaInfo_Event_General_SubFile_Start, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_SubFile_Start_0); Event.StreamIDs_Size=0; std::string FileName_Relative_Ansi=FileName_Relative.To_UTF8(); std::wstring FileName_Relative_Unicode=FileName_Relative.To_Unicode(); std::string FileName_Absolute_Ansi=FileName_Absolute.To_UTF8(); std::wstring FileName_Absolute_Unicode=FileName_Absolute.To_Unicode(); Event.FileName_Relative=FileName_Relative_Ansi.c_str(); Event.FileName_Relative_Unicode=FileName_Relative_Unicode.c_str(); Event.FileName_Absolute=FileName_Absolute_Ansi.c_str(); Event.FileName_Absolute_Unicode=FileName_Absolute_Unicode.c_str(); Event_Send(NULL, (const int8u*)&Event, Event.EventSize); } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Event_SubFile_Missing(const Ztring &FileName_Relative) { struct MediaInfo_Event_General_SubFile_Missing_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(0, MediaInfo_Event_General_SubFile_Missing, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_SubFile_Start_0); Event.StreamIDs_Size=0; std::string FileName_Relative_Ansi=FileName_Relative.To_UTF8(); std::wstring FileName_Relative_Unicode=FileName_Relative.To_Unicode(); Event.FileName_Relative=FileName_Relative_Ansi.c_str(); Event.FileName_Relative_Unicode=FileName_Relative_Unicode.c_str(); Event.FileName_Absolute=NULL; Event.FileName_Absolute_Unicode=NULL; Event_Send(NULL, (const int8u*)&Event, Event.EventSize); } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::Event_SubFile_Missing_Absolute(const Ztring &FileName_Absolute) { Ztring FileName_Relative; if (File_Names_RootDirectory.empty()) { FileName FN(FileName_Absolute); FileName_Relative=FN.Name_Get(); if (!FN.Extension_Get().empty()) { FileName_Relative+=__T('.'); FileName_Relative+=FN.Extension_Get(); } } else { Ztring Root=File_Names_RootDirectory+PathSeparator; FileName_Relative=FileName_Absolute; if (FileName_Relative.find(Root)==0) FileName_Relative.erase(0, Root.size()); } struct MediaInfo_Event_General_SubFile_Missing_0 Event; memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic)); Event.EventCode=MediaInfo_EventCode_Create(0, MediaInfo_Event_General_SubFile_Missing, 0); Event.EventSize=sizeof(struct MediaInfo_Event_General_SubFile_Missing_0); Event.StreamIDs_Size=0; std::string FileName_Relative_Ansi=FileName_Relative.To_UTF8(); std::wstring FileName_Relative_Unicode=FileName_Relative.To_Unicode(); std::string FileName_Absolute_Ansi=FileName_Absolute.To_UTF8(); std::wstring FileName_Absolute_Unicode=FileName_Absolute.To_Unicode(); Event.FileName_Relative=FileName_Relative_Ansi.c_str(); Event.FileName_Relative_Unicode=FileName_Relative_Unicode.c_str(); Event.FileName_Absolute=FileName_Absolute_Ansi.c_str(); Event.FileName_Absolute_Unicode=FileName_Absolute_Unicode.c_str(); Event_Send(NULL, (const int8u*)&Event, Event.EventSize); } #endif //MEDIAINFO_EVENTS //*************************************************************************** // Force Parser //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_MpegTs_ForceMenu_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_MpegTs_ForceMenu=NewValue; } bool MediaInfo_Config_MediaInfo::File_MpegTs_ForceMenu_Get () { CriticalSectionLocker CSL(CS); return File_MpegTs_ForceMenu; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_MpegTs_stream_type_Trust_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_MpegTs_stream_type_Trust=NewValue; } bool MediaInfo_Config_MediaInfo::File_MpegTs_stream_type_Trust_Get () { CriticalSectionLocker CSL(CS); return File_MpegTs_stream_type_Trust; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_MpegTs_Atsc_transport_stream_id_Trust_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_MpegTs_Atsc_transport_stream_id_Trust=NewValue; } bool MediaInfo_Config_MediaInfo::File_MpegTs_Atsc_transport_stream_id_Trust_Get () { CriticalSectionLocker CSL(CS); return File_MpegTs_Atsc_transport_stream_id_Trust; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_MpegTs_RealTime_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_MpegTs_RealTime=NewValue; } bool MediaInfo_Config_MediaInfo::File_MpegTs_RealTime_Get () { CriticalSectionLocker CSL(CS); return File_MpegTs_RealTime; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Mxf_TimeCodeFromMaterialPackage_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Mxf_TimeCodeFromMaterialPackage=NewValue; } bool MediaInfo_Config_MediaInfo::File_Mxf_TimeCodeFromMaterialPackage_Get () { CriticalSectionLocker CSL(CS); return File_Mxf_TimeCodeFromMaterialPackage; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Mxf_ParseIndex_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Mxf_ParseIndex=NewValue; } bool MediaInfo_Config_MediaInfo::File_Mxf_ParseIndex_Get () { CriticalSectionLocker CSL(CS); return File_Mxf_ParseIndex; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_Bdmv_ParseTargetedFile_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Bdmv_ParseTargetedFile=NewValue; } bool MediaInfo_Config_MediaInfo::File_Bdmv_ParseTargetedFile_Get () { CriticalSectionLocker CSL(CS); return File_Bdmv_ParseTargetedFile; } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DVDIF_YES) void MediaInfo_Config_MediaInfo::File_DvDif_DisableAudioIfIsInContainer_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_DvDif_DisableAudioIfIsInContainer=NewValue; } bool MediaInfo_Config_MediaInfo::File_DvDif_DisableAudioIfIsInContainer_Get () { CriticalSectionLocker CSL(CS); bool Temp=File_DvDif_DisableAudioIfIsInContainer; return Temp; } #endif //defined(MEDIAINFO_DVDIF_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DVDIF_YES) void MediaInfo_Config_MediaInfo::File_DvDif_IgnoreTransmittingFlags_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_DvDif_IgnoreTransmittingFlags=NewValue; } bool MediaInfo_Config_MediaInfo::File_DvDif_IgnoreTransmittingFlags_Get () { CriticalSectionLocker CSL(CS); return File_DvDif_IgnoreTransmittingFlags; } #endif //defined(MEDIAINFO_DVDIF_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_DVDIF_ANALYZE_YES) void MediaInfo_Config_MediaInfo::File_DvDif_Analysis_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_DvDif_Analysis=NewValue; } bool MediaInfo_Config_MediaInfo::File_DvDif_Analysis_Get () { CriticalSectionLocker CSL(CS); return File_DvDif_Analysis; } #endif //defined(MEDIAINFO_DVDIF_ANALYZE_YES) //--------------------------------------------------------------------------- #if MEDIAINFO_MACROBLOCKS void MediaInfo_Config_MediaInfo::File_Macroblocks_Parse_Set (int NewValue) { CriticalSectionLocker CSL(CS); File_Macroblocks_Parse=NewValue; } int MediaInfo_Config_MediaInfo::File_Macroblocks_Parse_Get () { CriticalSectionLocker CSL(CS); return File_Macroblocks_Parse; } #endif //MEDIAINFO_MACROBLOCKS //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_GrowingFile_Delay_Set (float64 NewValue) { CriticalSectionLocker CSL(CS); File_GrowingFile_Delay=NewValue; } float64 MediaInfo_Config_MediaInfo::File_GrowingFile_Delay_Get () { CriticalSectionLocker CSL(CS); return File_GrowingFile_Delay; } //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::File_GrowingFile_Force_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_GrowingFile_Force=NewValue; } //--------------------------------------------------------------------------- bool MediaInfo_Config_MediaInfo::File_GrowingFile_Force_Get () { CriticalSectionLocker CSL(CS); return File_GrowingFile_Force; } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_LIBCURL_YES) void MediaInfo_Config_MediaInfo::File_Curl_Set (const Ztring &NewValue) { size_t Pos=NewValue.find(__T(',')); if (Pos==string::npos) Pos=NewValue.find(__T(';')); if (Pos!=string::npos) { Ztring Field=NewValue.substr(0, Pos); Field.MakeLowerCase(); Ztring Value=NewValue.substr(Pos+1, string::npos); CriticalSectionLocker CSL(CS); Curl[Field]=Value; } } void MediaInfo_Config_MediaInfo::File_Curl_Set (const Ztring &Field_, const Ztring &NewValue) { Ztring Field=Field_; Field.MakeLowerCase(); CriticalSectionLocker CSL(CS); Curl[Field]=NewValue; } Ztring MediaInfo_Config_MediaInfo::File_Curl_Get (const Ztring &Field_) { Ztring Field=Field_; Field.MakeLowerCase(); CriticalSectionLocker CSL(CS); std::map::iterator Value=Curl.find(Field); if (Value==Curl.end()) return Ztring(); else return Curl[Field]; } #endif //defined(MEDIAINFO_LIBCURL_YES) //--------------------------------------------------------------------------- #if defined(MEDIAINFO_LIBMMS_YES) void MediaInfo_Config_MediaInfo::File_Mmsh_Describe_Only_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Mmsh_Describe_Only=NewValue; } bool MediaInfo_Config_MediaInfo::File_Mmsh_Describe_Only_Get () { CriticalSectionLocker CSL(CS); return File_Mmsh_Describe_Only; } #endif //defined(MEDIAINFO_LIBMMS_YES) //--------------------------------------------------------------------------- Ztring MediaInfo_Config_MediaInfo::File_DisplayCaptions_Set (const Ztring& NewValue) { auto NewValueS = NewValue.To_UTF8(); size_t i = 0; for (; i < DisplayCaptions_Max; i++) { if (NewValueS == DisplayCaptions_Strings[i]) { break; } } if (i >= DisplayCaptions_Max) return __T("Unknown value"); CriticalSectionLocker CSL(CS); DisplayCaptions = (display_captions)i; return {}; } display_captions MediaInfo_Config_MediaInfo::File_DisplayCaptions_Get () { CriticalSectionLocker CSL(CS); return DisplayCaptions; } //--------------------------------------------------------------------------- Ztring MediaInfo_Config_MediaInfo::File_ProbeCaption_Set (const Ztring& NewValue) { static const auto Malformed = __T("File_ProbeCaption option malformed"); ZtringListList List; List.Separator_Set(0, __T(",")); List.Separator_Set(1, __T("+")); List.Write(NewValue); CriticalSectionLocker CSL(CS); File_ProbeCaption.clear(); bool HasForAll = false; string AllMinus; for (const auto& Line : List) { config_probe Item; for (const auto& Value : Line) { auto Pos = Value.find_first_not_of(__T("0123456789")); if (Pos == string::npos) { Item.Start_Type = config_probe_size; Item.Start = Value.To_int64u(); } else if (!Value.empty() && ((Value[0] >= __T('A') && Value[0] <= __T('Z')) || (Value[0] >= __T('a') && Value[0] <= __T('z')))) { string Value2(Ztring(Value).MakeUpperCase().To_UTF8()); bool Negative = false; if (Value2.rfind("ALL", 0) == 0) { if (Value2.size() > 3) { if (Value2[3] != __T('-')) return Malformed; Negative = true; Value2 = Value.To_UTF8().substr(4); AllMinus += '-'; AllMinus += Value2; } } if (Value2 != "MP4" && Value2 != "MPEG-4" && Value2 != "MXF" && !Value2.empty()) { //TODO: full list return Malformed; } Item.Parser = Value2 != "MP4" ? Value2 : "MPEG-4"; if (Negative) { Item.Parser.insert(Item.Parser.begin(), __T('-')); } } else if (Pos == Value.size() - 1 && Value[Pos] == __T('%')) { auto Value_Int = Value.To_int64u(); if (Value_Int > 100) { return Malformed; } if (Item.Start_Type == config_probe_none) { Item.Start_Type = config_probe_percent; Item.Start = Value_Int; } else if (Item.Duration_Type == config_probe_none) { Item.Duration_Type = config_probe_percent; Item.Duration = Value_Int; } else { return Malformed; } } else if (Pos == Value.size() - 1 && (Value[Pos] == __T('E') || Value[Pos] == __T('G') || Value[Pos] == __T('K') || Value[Pos] == __T('M') || Value[Pos] == __T('P') || Value[Pos] == __T('T') || Value[Pos] == __T('k'))) { auto Value_Int = Value.To_int64u(); switch (Value[Pos]) { case 'E': Value_Int <<= 10; // Fall through case 'P': Value_Int <<= 10; // Fall through case 'T': Value_Int <<= 10; // Fall through case 'G': Value_Int <<= 10; // Fall through case 'M': Value_Int <<= 10; // Fall through default: Value_Int <<= 10; } if (Item.Start_Type == config_probe_none) { Item.Start_Type = config_probe_size; Item.Start = Value_Int; } else if (Item.Duration_Type == config_probe_none) { Item.Duration_Type = config_probe_size; Item.Duration = Value_Int; } else { return Malformed; } } else { TimeCode TC(Value.To_UTF8(), 999); if (!TC.IsValid()) { return Malformed; } auto Seconds = TC.ToSeconds(); if (Seconds <= 0) { return Malformed; } if (Item.Start_Type == config_probe_none) { Item.Start_Type = config_probe_dur; Item.Start = Seconds; } else if (Item.Duration_Type == config_probe_none) { Item.Duration_Type = config_probe_dur; Item.Duration = Seconds; } else { return Malformed; } } } if (Item.Parser.empty()) { HasForAll=true; } if (Item.Duration_Type == config_probe_none) { Item.Duration_Type = config_probe_dur; Item.Duration = 30; } File_ProbeCaption.push_back(Item); } File_ProbeCaption_Pos=0; if (!HasForAll) { config_probe Probe; Probe.Start_Type = config_probe_percent; Probe.Start = 50; Probe.Duration_Type = config_probe_dur; Probe.Duration = 30; Probe.Parser = AllMinus; File_ProbeCaption.push_back(Probe); } return {}; } config_probe MediaInfo_Config_MediaInfo::File_ProbeCaption_Get(const string& ParserName) { if (ParseSpeed<=0 && ParseSpeed>=1) return {}; CriticalSectionLocker CSL(CS); for (;;) { if (File_ProbeCaption_Pos >= File_ProbeCaption.size()) return {}; const auto& Item = File_ProbeCaption[File_ProbeCaption_Pos]; File_ProbeCaption_Pos++; if (Item.Parser.empty()) { if (Item.Parser[0] == '-') { if (Item.Parser.rfind(ParserName, 1) == 1) { continue; } } } else if (Item.Parser != ParserName) { continue; } return Item; } } //--------------------------------------------------------------------------- #if defined(MEDIAINFO_AC3_YES) void MediaInfo_Config_MediaInfo::File_Ac3_IgnoreCrc_Set (bool NewValue) { CriticalSectionLocker CSL(CS); File_Ac3_IgnoreCrc=NewValue; } bool MediaInfo_Config_MediaInfo::File_Ac3_IgnoreCrc_Get () { CriticalSectionLocker CSL(CS); return File_Ac3_IgnoreCrc; } #endif //defined(MEDIAINFO_AC3_YES) //*************************************************************************** // Analysis internal //*************************************************************************** //--------------------------------------------------------------------------- void MediaInfo_Config_MediaInfo::State_Set (float NewValue) { CriticalSectionLocker CSL(CS); State=NewValue; } float MediaInfo_Config_MediaInfo::State_Get () { CriticalSectionLocker CSL(CS); return State; } } //NameSpace