+// file driver in order of probe precidence
+// can be reordered in preferences->interface
+const char *File::default_probes[] = {
+ "FFMPEG_Early",
+ "Scene",
+ "DB",
+#ifdef HAVE_DV
+ "DV",
+#endif
+ "SndFile",
+ "PNG",
+ "PPM",
+ "JPEG",
+ "GIF",
+#ifdef HAVE_OPENEXR
+ "EXR",
+#endif
+ "FLAC",
+ "CR2",
+ "TGA",
+ "TIFF",
+ "OGG",
+ "Vorbis",
+ "MPEG",
+ "EDL",
+ "FFMPEG_Late",
+};
+const int File::nb_probes =
+ sizeof(File::default_probes)/sizeof(File::default_probes[0]);
+
+
+int File::probe()
+{
+ FILE *fp = fopen(this->asset->path, "rb");
+ if( !fp ) return FILE_NOT_FOUND;
+ char data[16];
+ memset(data,0,sizeof(data));
+ int ret = fread(data, 1, 16, fp);
+ fclose(fp);
+ if( !ret ) return FILE_NOT_FOUND;
+
+ for( int i=0; i<preferences->file_probes.size(); ++i ) {
+ ProbePref *pref = preferences->file_probes[i];
+ if( !pref->armed ) continue;
+ if( !strncmp(pref->name,"FFMPEG",6) ) { // FFMPEG Early/Late
+ if( !FileFFMPEG::check_sig(this->asset) ) continue;
+ file = new FileFFMPEG(this->asset, this);
+ return FILE_OK;
+ }
+#ifdef HAVE_COMMERCIAL
+ if( !strcmp(pref->name,"DB") ) { // MediaDB
+ if( !FileDB::check_sig(this->asset) ) continue;
+ file = new FileDB(this->asset, this);
+ return FILE_OK;
+ }
+#endif
+ if( !strcmp(pref->name,"Scene") ) { // scene file
+ if( !FileScene::check_sig(this->asset, data)) continue;
+ file = new FileScene(this->asset, this);
+ return FILE_OK;
+ }
+#ifdef HAVE_DV
+ if( !strcmp(pref->name,"DV") ) { // libdv
+ if( !FileDV::check_sig(this->asset) ) continue;
+ file = new FileDV(this->asset, this);
+ return FILE_OK;
+ }
+#endif
+ if( !strcmp(pref->name,"SndFile") ) { // libsndfile
+ if( !FileSndFile::check_sig(this->asset) ) continue;
+ file = new FileSndFile(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"PNG") ) { // PNG file
+ if( !FilePNG::check_sig(this->asset) ) continue;
+ file = new FilePNG(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"PPM") ) { // PPM file
+ if( !FilePPM::check_sig(this->asset) ) continue;
+ file = new FilePPM(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"JPEG") ) { // JPEG file
+ if( !FileJPEG::check_sig(this->asset) ) continue;
+ file = new FileJPEG(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"GIF") ) { // GIF file
+ if( !FileGIF::check_sig(this->asset)) continue;
+ file = new FileGIF(this->asset, this);
+ return FILE_OK;
+ }
+#ifdef HAVE_EXR
+ if( !strcmp(pref->name,"EXR") ) { // EXR file
+ if( !FileEXR::check_sig(this->asset, data)) continue;
+ file = new FileEXR(this->asset, this);
+ return FILE_OK;
+ }
+#endif
+ if( !strcmp(pref->name,"FLAC") ) { // FLAC file
+ if( !FileFLAC::check_sig(this->asset, data)) continue;
+ file = new FileFLAC(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"CR2") ) { // CR2 file
+ if( !FileCR2::check_sig(this->asset)) continue;
+ file = new FileCR2(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"TGA") ) { // TGA file
+ if( !FileTGA::check_sig(this->asset) ) continue;
+ file = new FileTGA(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"TIFF") ) { // TIFF file
+ if( !FileTIFF::check_sig(this->asset) ) continue;
+ file = new FileTIFF(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"OGG") ) { // OGG file
+ if( !FileOGG::check_sig(this->asset) ) continue;
+ file = new FileOGG(this->asset, this);
+ return FILE_OK;
+ }
+ if( !strcmp(pref->name,"Vorbis") ) { // VorbisFile file
+ if( !FileVorbis::check_sig(this->asset) ) continue;
+ file = new FileVorbis(this->asset, this);
+ return FILE_OK;
+ }
+#ifdef HAVE_LIBZMPEG
+ if( !strcmp(pref->name,"MPEG") ) { // MPEG file
+ if( !FileMPEG::check_sig(this->asset) ) continue;
+ file = new FileMPEG(this->asset, this);
+ return FILE_OK;
+ }
+#endif
+ if( !strcmp(pref->name,"EDL") ) { // XML file
+ if( data[0] != '<' ) continue;
+ if( !strncmp(&data[1],"EDL>",4) ||
+ !strncmp(&data[1],"HTAL>",5) ||
+ !strncmp(&data[1],"?xml",4) )
+ return FILE_IS_XML;
+ }
+ }
+ return FILE_UNRECOGNIZED_CODEC; // maybe PCM file ?
+}