MCPcopy Create free account
hub / github.com/MediaArea/MediaInfoLib / Format_Test

Method Format_Test

Source/MediaInfo/Reader/Reader_File.cpp:162–224  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

160
161//---------------------------------------------------------------------------
162size_t Reader_File::Format_Test(MediaInfo_Internal* MI, String File_Name)
163{
164 //std::cout<<Ztring(File_Name).To_Local().c_str()<<std::endl;
165 #if MEDIAINFO_EVENTS
166 {
167 string File_Name_Local=Ztring(File_Name).To_Local();
168 wstring File_Name_Unicode=Ztring(File_Name).To_Unicode();
169 struct MediaInfo_Event_General_Start_0 Event;
170 memset(&Event, 0xFF, sizeof(struct MediaInfo_Event_Generic));
171 Event.EventCode=MediaInfo_EventCode_Create(MediaInfo_Parser_None, MediaInfo_Event_General_Start, 0);
172 Event.EventSize=sizeof(struct MediaInfo_Event_General_Start_0);
173 Event.StreamIDs_Size=0;
174 Event.Stream_Size=File::Size_Get(File_Name);
175 Event.FileName=File_Name_Local.c_str();
176 Event.FileName_Unicode=File_Name_Unicode.c_str();
177 MI->Config.Event_Send(NULL, (const int8u*)&Event, sizeof(MediaInfo_Event_General_Start_0));
178 }
179 #endif //MEDIAINFO_EVENTS
180
181 //With Parser MultipleParsing
182 /*
183 MI->Open_Buffer_Init((int64u)-1, File_Name);
184 if (Format_Test_PerParser(MI, File_Name))
185 return 1;
186 return 0; //There is a problem
187 */
188
189 //Get the Extension
190 Ztring Extension=FileName::Extension_Get(File_Name);
191 Extension.MakeLowerCase();
192
193 //Search the theorical format from extension
194 InfoMap &FormatList=MediaInfoLib::Config.Format_Get();
195 InfoMap::iterator Format=FormatList.end();
196 if (!MI->Config.File_ForceParser_Get().empty())
197 Format=FormatList.find(MI->Config.File_ForceParser_Get());
198 if (Format==FormatList.end())
199 {
200 Format=FormatList.begin();
201 while (Format!=FormatList.end())
202 {
203 ZtringList Extensions;
204 Extensions.Separator_Set(0, __T(" "));
205 Extensions.Write(FormatList.Get(Format->first, InfoFormat_Extensions));
206 if (Extensions.Find(Extension)!=Error)
207 break;
208 ++Format;
209 }
210 }
211 if (Format!=FormatList.end())
212 {
213 const Ztring &Parser=Format->second(InfoFormat_Parser);
214 if (MI->SelectFromExtension(Parser))
215 {
216 //Test the theorical format
217 if (Format_Test_PerParser(MI, File_Name)>0)
218 return 1;
219 }

Callers 1

EntryMethod · 0.45

Calls 10

File_ForceParser_GetMethod · 0.80
SelectFromExtensionMethod · 0.80
GetMethod · 0.65
c_strMethod · 0.45
Event_SendMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
WriteMethod · 0.45
ListFormatsMethod · 0.45

Tested by

no test coverage detected