in src/media_tools/media_import.c [9176:9361]
GF_Err gf_media_import(GF_MediaImporter *importer)
{
#ifndef GPAC_DISABLE_TTXT
GF_Err gf_import_timed_text(GF_MediaImporter *import);
#endif
GF_Err e;
char *ext, *xml_type;
char *fmt = "";
if (!importer || (!importer->dest && (importer->flags!=GF_IMPORT_PROBE_ONLY)) || (!importer->in_name && !importer->orig) ) return GF_BAD_PARAM;
if (importer->orig) return gf_import_isomedia(importer);
if (importer->force_ext) {
ext = importer->force_ext;
} else {
ext = strrchr(importer->in_name, '.');
if (!ext) ext = "";
}
if (importer->streamFormat) fmt = importer->streamFormat;
/*always try with MP4 - this allows using .m4v extension for both raw CMP and iPod's files*/
if (gf_isom_probe_file(importer->in_name)) {
importer->orig = gf_isom_open(importer->in_name, GF_ISOM_OPEN_READ, NULL);
if (importer->orig) {
e = gf_import_isomedia(importer);
gf_isom_delete(importer->orig);
importer->orig = NULL;
return e;
}
}
#ifndef GPAC_DISABLE_AVILIB
/*AVI audio/video*/
if (!strnicmp(ext, ".avi", 4) || !stricmp(fmt, "AVI") ) {
e = gf_import_avi_video(importer);
if (e) return e;
return gf_import_avi_audio(importer);
}
#endif
#ifndef GPAC_DISABLE_OGG
/*OGG audio/video*/
if (!strnicmp(ext, ".ogg", 4) || !stricmp(fmt, "OGG")) {
e = gf_import_ogg_video(importer);
if (e) return e;
return gf_import_ogg_audio(importer);
}
#endif
#ifndef GPAC_DISABLE_MPEG2PS
/*MPEG PS*/
if (!strnicmp(ext, ".mpg", 4) || !strnicmp(ext, ".mpeg", 5)
|| !strnicmp(ext, ".vob", 4) || !strnicmp(ext, ".vcd", 4) || !strnicmp(ext, ".svcd", 5)
|| !stricmp(fmt, "MPEG1") || !stricmp(fmt, "MPEG-PS") || !stricmp(fmt, "MPEG2-PS")
) {
e = gf_import_mpeg_ps_video(importer);
if (e) return e;
return gf_import_mpeg_ps_audio(importer);
}
#endif
#ifndef GPAC_DISABLE_MPEG2TS
/*MPEG-2 TS*/
if (!strnicmp(ext, ".ts", 3) || !strnicmp(ext, ".m2t", 4) || !strnicmp(ext, ".trp", 4) || !strnicmp(ext, ".mts", 4)
|| !stricmp(fmt, "MPEGTS") || !stricmp(fmt, "MPEG-TS")
|| !stricmp(fmt, "MPGTS") || !stricmp(fmt, "MPG-TS")
|| !stricmp(fmt, "MPEG2TS") || !stricmp(fmt, "MPEG2-TS")
|| !stricmp(fmt, "MPG2TS") || !stricmp(fmt, "MPG2-TS")
) {
return gf_import_mpeg_ts(importer);
}
#endif
#ifndef GPAC_DISABLE_AV_PARSERS
/*MPEG1/2 Audio*/
if (!strnicmp(ext, ".mp2", 4) || !strnicmp(ext, ".mp3", 4) || !strnicmp(ext, ".m1a", 4) || !strnicmp(ext, ".m2a", 4) || !stricmp(fmt, "MP3") || !stricmp(fmt, "MPEG-AUDIO") )
return gf_import_mp3(importer);
/*MPEG-2/4 AAC*/
if (!strnicmp(ext, ".aac", 4) || !stricmp(fmt, "AAC") || !stricmp(fmt, "MPEG4-AUDIO") )
return gf_import_aac_adts(importer);
/*MPEG-4 video*/
if (!strnicmp(ext, ".cmp", 4) || !strnicmp(ext, ".m4v", 4) || !stricmp(fmt, "CMP") || !stricmp(fmt, "MPEG4-Video") )
return gf_import_cmp(importer, GF_FALSE);
/*MPEG-1/2 video*/
if (!strnicmp(ext, ".m2v", 4) || !strnicmp(ext, ".m1v", 4) || !stricmp(fmt, "MPEG2-Video") || !stricmp(fmt, "MPEG1-Video") )
return gf_import_cmp(importer, 2);
/*H2632 video*/
if (!strnicmp(ext, ".263", 4) || !strnicmp(ext, ".h263", 5) || !stricmp(fmt, "H263") )
return gf_import_h263(importer);
/*H264/AVC video*/
if (!strnicmp(ext, ".h264", 5) || !strnicmp(ext, ".264", 4) || !strnicmp(ext, ".x264", 5)
|| !strnicmp(ext, ".h26L", 5) || !strnicmp(ext, ".26l", 4)
|| !stricmp(fmt, "AVC") || !stricmp(fmt, "H264") )
return gf_import_avc_h264(importer);
/*HEVC video*/
if (!strnicmp(ext, ".hevc", 5) || !strnicmp(ext, ".hvc", 4) || !strnicmp(ext, ".265", 4) || !strnicmp(ext, ".h265", 5) || !strnicmp(ext, ".shvc", 5)
|| !stricmp(fmt, "HEVC") || !stricmp(fmt, "SHVC") || !stricmp(fmt, "H265") )
return gf_import_hevc(importer);
/*AC3 and E-AC3*/
if (!strnicmp(ext, ".ac3", 4) || !stricmp(fmt, "AC3") )
return gf_import_ac3(importer, GF_FALSE);
if (!strnicmp(ext, ".ec3", 4) || !stricmp(fmt, "EC3") || !stricmp(fmt, "E-AC3") || !stricmp(fmt, "EAC3") )
return gf_import_ac3(importer, GF_TRUE);
#endif
/*NHNT*/
if (!strnicmp(ext, ".media", 5) || !strnicmp(ext, ".info", 5) || !strnicmp(ext, ".nhnt", 5) || !stricmp(fmt, "NHNT") )
return gf_import_nhnt(importer);
/*NHML*/
if (!strnicmp(ext, ".nhml", 5) || !stricmp(fmt, "NHML") )
return gf_import_nhml_dims(importer, GF_FALSE);
/*jpg & png & jp2*/
if (!strnicmp(ext, ".jpg", 4) || !strnicmp(ext, ".jpeg", 5) || !strnicmp(ext, ".jp2", 4) || !strnicmp(ext, ".png", 4) || !stricmp(fmt, "JPEG") || !stricmp(fmt, "PNG") || !stricmp(fmt, "JP2") )
return gf_import_still_image(importer, GF_TRUE);
/*AMR & 3GPP2 speec codecs*/
if (!strnicmp(ext, ".amr", 4) || !strnicmp(ext, ".awb", 4) || !strnicmp(ext, ".smv", 4) || !strnicmp(ext, ".evc", 4)
|| !stricmp(fmt, "AMR") || !stricmp(fmt, "EVRC") || !stricmp(fmt, "SMV") )
return gf_import_amr_evrc_smv(importer);
/*QCelp & other in QCP file format*/
if (!strnicmp(ext, ".qcp", 4) || !stricmp(fmt, "QCELP") )
return gf_import_qcp(importer);
/*MPEG-4 SAF multiplex*/
if (!strnicmp(ext, ".saf", 4) || !strnicmp(ext, ".lsr", 4) || !stricmp(fmt, "SAF") )
return gf_import_saf(importer);
/*text subtitles*/
if (!strnicmp(ext, ".srt", 4) || !strnicmp(ext, ".sub", 4) || !strnicmp(ext, ".ttxt", 5) || !strnicmp(ext, ".vtt", 4) || !strnicmp(ext, ".ttml", 5)
|| !stricmp(fmt, "SRT") || !stricmp(fmt, "SUB") || !stricmp(fmt, "TEXT") || !stricmp(fmt, "VTT") || !stricmp(fmt, "TTML")) {
#ifndef GPAC_DISABLE_TTXT
return gf_import_timed_text(importer);
#else
return GF_NOT_SUPPORTED;
#endif
}
/*VobSub*/
if (!strnicmp(ext, ".idx", 4) || !stricmp(fmt, "VOBSUB"))
return gf_import_vobsub(importer);
/*raw importer*/
if (!stricmp(fmt, "RAW")) {
return gf_import_raw_unit(importer);
}
/*DIMS*/
if (!strnicmp(ext, ".dml", 4) || !stricmp(fmt, "DIMS") )
return gf_import_nhml_dims(importer, GF_TRUE);
/*SC3DMC*/
if (!strnicmp(ext, ".s3d", 4) || !stricmp(fmt, "SC3DMC") )
return gf_import_afx_sc3dmc(importer, GF_TRUE);
if (!strnicmp(ext, ".txt", 4) || !strnicmp(ext, ".chap", 5) || !stricmp(fmt, "CHAP") )
return gf_media_import_chapters_file(importer);
if (!strnicmp(ext, ".swf", 4) || !strnicmp(ext, ".SWF", 4)) {
#ifndef GPAC_DISABLE_TTXT
return gf_import_timed_text(importer);
#else
return GF_NOT_SUPPORTED;
#endif
}
/*try XML things*/
xml_type = gf_xml_get_root_type(importer->in_name, &e);
if (xml_type) {
if (!stricmp(xml_type, "TextStream") || !stricmp(xml_type, "text3GTrack") ) {
gf_free(xml_type);
#ifndef GPAC_DISABLE_TTXT
return gf_import_timed_text(importer);
#else
return GF_NOT_SUPPORTED;
#endif
}
else if (!stricmp(xml_type, "NHNTStream")) {
gf_free(xml_type);
return gf_import_nhml_dims(importer, GF_FALSE);
}
else if (!stricmp(xml_type, "DIMSStream") ) {
gf_free(xml_type);
return gf_import_nhml_dims(importer, GF_TRUE);
}
gf_free(xml_type);
}
if (gf_m2ts_probe_file(importer->in_name))
return gf_import_mpeg_ts(importer);
return gf_import_message(importer, e, "[Importer] Unknown input file type for \"%s\"", importer->in_name);
}