Bool DC_CanHandleURL(GF_InputService *plug, const char *url) { char *sExt; if (!plug || !url) return GF_FALSE; sExt = strrchr(url, '.'); if (sExt) { Bool ok = GF_FALSE; char *cgi_par; if (!strnicmp(sExt, ".gz", 3)) sExt = strrchr(sExt, '.'); if (!strnicmp(url, "rtsp://", 7)) return GF_FALSE; cgi_par = strchr(sExt, '?'); if (cgi_par) cgi_par[0] = 0; { u32 i; for (i = 0 ; DC_MIME_TYPES[i] ; i+=3) if (0 != (ok = gf_service_check_mime_register(plug, DC_MIME_TYPES[i], DC_MIME_TYPES[i+1], DC_MIME_TYPES[i+2], sExt))) break; } if (cgi_par) cgi_par[0] = '?'; if (ok) return GF_TRUE; } /*views:// internal URI*/ if (!strnicmp(url, "views://", 8)) return GF_TRUE; if (!strncmp(url, "\\\\", 2)) return GF_FALSE; if (!strnicmp(url, "file://", 7) || !strstr(url, "://")) { char *rtype = gf_xml_get_root_type(url, NULL); if (rtype) { Bool handled = GF_FALSE; if (!strcmp(rtype, "SAFSession")) handled = GF_TRUE; else if (!strcmp(rtype, "XMT-A")) handled = GF_TRUE; else if (!strcmp(rtype, "X3D")) handled = GF_TRUE; else if (!strcmp(rtype, "svg")) handled = GF_TRUE; else if (!strcmp(rtype, "bindings")) handled = GF_TRUE; else if (!strcmp(rtype, "widget")) handled = GF_TRUE; gf_free(rtype); return handled; } } return GF_FALSE; }
/*initializes the context loader*/ GF_EXPORT GF_Err gf_sm_load_init(GF_SceneLoader *load) { GF_Err e = GF_NOT_SUPPORTED; char *ext, szExt[50]; /*we need at least a scene graph*/ if (!load || (!load->ctx && !load->scene_graph) #ifndef GPAC_DISABLE_ISOM || (!load->fileName && !load->isom && !(load->flags & GF_SM_LOAD_FOR_PLAYBACK) ) #endif ) return GF_BAD_PARAM; if (!load->type) { #ifndef GPAC_DISABLE_ISOM if (load->isom) { load->type = GF_SM_LOAD_MP4; } else #endif { ext = strrchr(load->fileName, '.'); if (!ext) return GF_NOT_SUPPORTED; if (!stricmp(ext, ".gz")) { char *anext; ext[0] = 0; anext = strrchr(load->fileName, '.'); ext[0] = '.'; ext = anext; } strcpy(szExt, &ext[1]); strlwr(szExt); if (strstr(szExt, "bt")) load->type = GF_SM_LOAD_BT; else if (strstr(szExt, "wrl")) load->type = GF_SM_LOAD_VRML; else if (strstr(szExt, "x3dv")) load->type = GF_SM_LOAD_X3DV; #ifndef GPAC_DISABLE_LOADER_XMT else if (strstr(szExt, "xmt") || strstr(szExt, "xmta")) load->type = GF_SM_LOAD_XMTA; else if (strstr(szExt, "x3d")) load->type = GF_SM_LOAD_X3D; #endif else if (strstr(szExt, "swf")) load->type = GF_SM_LOAD_SWF; else if (strstr(szExt, "mov")) load->type = GF_SM_LOAD_QT; else if (strstr(szExt, "svg")) load->type = GF_SM_LOAD_SVG; else if (strstr(szExt, "xsr")) load->type = GF_SM_LOAD_XSR; else if (strstr(szExt, "xbl")) load->type = GF_SM_LOAD_XBL; else if (strstr(szExt, "xml")) { char *rtype = gf_xml_get_root_type(load->fileName, &e); if (rtype) { if (!strcmp(rtype, "SAFSession")) load->type = GF_SM_LOAD_XSR; else if (!strcmp(rtype, "XMT-A")) load->type = GF_SM_LOAD_XMTA; else if (!strcmp(rtype, "X3D")) load->type = GF_SM_LOAD_X3D; else if (!strcmp(rtype, "bindings")) load->type = GF_SM_LOAD_XBL; gf_free(rtype); } } } } if (!load->type) return e; if (!load->scene_graph) load->scene_graph = load->ctx->scene_graph; switch (load->type) { #ifndef GPAC_DISABLE_LOADER_BT case GF_SM_LOAD_BT: case GF_SM_LOAD_VRML: case GF_SM_LOAD_X3DV: return gf_sm_load_init_bt(load); #endif #ifndef GPAC_DISABLE_LOADER_XMT case GF_SM_LOAD_XMTA: case GF_SM_LOAD_X3D: return gf_sm_load_init_xmt(load); #endif #ifndef GPAC_DISABLE_SVG case GF_SM_LOAD_SVG: case GF_SM_LOAD_XSR: case GF_SM_LOAD_DIMS: return gf_sm_load_init_svg(load); case GF_SM_LOAD_XBL: e = gf_sm_load_init_xbl(load); load->process = gf_sm_load_run_xbl;; load->done = gf_sm_load_done_xbl; return e; #endif #ifndef GPAC_DISABLE_SWF_IMPORT case GF_SM_LOAD_SWF: return gf_sm_load_init_swf(load); #endif #ifndef GPAC_DISABLE_LOADER_ISOM case GF_SM_LOAD_MP4: return gf_sm_load_init_isom(load); #endif #ifndef GPAC_DISABLE_QTVR case GF_SM_LOAD_QT: return gf_sm_load_init_qt(load); #endif } return GF_NOT_SUPPORTED; }
GF_Err DC_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url) { DCReader *read = (DCReader *) plug->priv; FILE *test; char *tmp, *ext; if (!read || !serv || !url) return GF_BAD_PARAM; if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; read->url = gf_strdup(url); ext = strchr(read->url, '#'); if (ext) { char *anext; ext[0] = 0; anext = strrchr(read->url, '.'); ext[0] = '#'; ext = anext; } else { ext = strrchr(read->url, '.'); } if (ext && !stricmp(ext, ".gz")) { char *anext; ext[0] = 0; anext = strrchr(read->url, '.'); ext[0] = '.'; ext = anext; } read->service = serv; if (!strnicmp(url, "views://", 8)) { read->is_views_url = GF_TRUE; gf_service_connect_ack(serv, NULL, GF_OK); read->is_service_connected = GF_TRUE; return GF_OK; } if (ext) { char *cgi_par = NULL; ext += 1; if (ext) { tmp = strchr(ext, '#'); if (tmp) tmp[0] = 0; /* Warning the '?' sign should not be present in local files but it is convenient to have it to test web content locally */ cgi_par = strchr(ext, '?'); if (cgi_par) cgi_par[0] = 0; } if (!stricmp(ext, "bt") || !stricmp(ext, "btz") || !stricmp(ext, "bt.gz") || !stricmp(ext, "xmta") || !stricmp(ext, "xmt") || !stricmp(ext, "xmt.gz") || !stricmp(ext, "xmtz") || !stricmp(ext, "wrl") || !stricmp(ext, "wrl.gz") || !stricmp(ext, "x3d") || !stricmp(ext, "x3d.gz") || !stricmp(ext, "x3dz") || !stricmp(ext, "x3dv") || !stricmp(ext, "x3dv.gz") || !stricmp(ext, "x3dvz") || !stricmp(ext, "swf") ) read->oti = GPAC_OTI_PRIVATE_SCENE_GENERIC; else if (!stricmp(ext, "svg") || !stricmp(ext, "svgz") || !stricmp(ext, "svg.gz")) { read->oti = GPAC_OTI_PRIVATE_SCENE_SVG; } /*XML LASeR*/ else if (!stricmp(ext, "xsr")) read->oti = GPAC_OTI_PRIVATE_SCENE_LASER; else if (!stricmp(ext, "xbl")) read->oti = GPAC_OTI_PRIVATE_SCENE_XBL; else if (!stricmp(ext, "wgt") || !stricmp(ext, "mgt")) read->oti = GPAC_OTI_PRIVATE_SCENE_WGT; if (cgi_par) cgi_par[0] = '?'; } if (!read->oti && (!strnicmp(url, "file://", 7) || !strstr(url, "://"))) { char *rtype = gf_xml_get_root_type(url, NULL); if (rtype) { if (!strcmp(rtype, "SAFSession")) read->oti = GPAC_OTI_PRIVATE_SCENE_LASER; else if (!strcmp(rtype, "svg")) read->oti = GPAC_OTI_PRIVATE_SCENE_SVG; else if (!strcmp(rtype, "XMT-A")) read->oti = GPAC_OTI_PRIVATE_SCENE_GENERIC; else if (!strcmp(rtype, "X3D")) read->oti = GPAC_OTI_PRIVATE_SCENE_GENERIC; else if (!strcmp(rtype, "bindings")) read->oti = GPAC_OTI_PRIVATE_SCENE_XBL; else if (!strcmp(rtype, "widget")) read->oti = GPAC_OTI_PRIVATE_SCENE_WGT; gf_free(rtype); } } /*remote fetch*/ if (!strnicmp(url, "file://", 7)) { url += 7; } else if (strstr(url, "://")) { DC_DownloadFile(plug, read->url); return GF_OK; } test = gf_fopen(read->url, "rt"); if (!test) { gf_service_connect_ack(serv, NULL, GF_URL_ERROR); return GF_OK; } gf_fclose(test); if (!read->is_service_connected) { gf_service_connect_ack(serv, NULL, GF_OK); read->is_service_connected = GF_TRUE; } return GF_OK; }
/*initializes the context loader*/ GF_EXPORT GF_Err gf_sm_load_init(GF_SceneLoader *load) { GF_Err e = GF_NOT_SUPPORTED; char *ext, szExt[50]; /*we need at least a scene graph*/ if (!load || (!load->ctx && !load->scene_graph) || (!load->fileName && !load->isom)) return GF_BAD_PARAM; if (!load->type) { if (load->isom) { load->type = GF_SM_LOAD_MP4; } else { ext = strrchr(load->fileName, '.'); if (!ext) return GF_NOT_SUPPORTED; if (!stricmp(ext, ".gz")) { char *anext; ext[0] = 0; anext = strrchr(load->fileName, '.'); ext[0] = '.'; ext = anext; } strcpy(szExt, &ext[1]); strlwr(szExt); if (strstr(szExt, "bt")) load->type = GF_SM_LOAD_BT; else if (strstr(szExt, "wrl")) load->type = GF_SM_LOAD_VRML; else if (strstr(szExt, "x3dv")) load->type = GF_SM_LOAD_X3DV; else if (strstr(szExt, "xmt") || strstr(szExt, "xmta")) load->type = GF_SM_LOAD_XMTA; else if (strstr(szExt, "x3d")) load->type = GF_SM_LOAD_X3D; else if (strstr(szExt, "swf")) load->type = GF_SM_LOAD_SWF; else if (strstr(szExt, "mov")) load->type = GF_SM_LOAD_QT; else if (strstr(szExt, "svg")) load->type = GF_SM_LOAD_SVG_DA; else if (strstr(szExt, "xsr")) load->type = GF_SM_LOAD_XSR; else if (strstr(szExt, "xml")) { char *rtype = gf_xml_get_root_type(load->fileName, &e); if (rtype) { if (!strcmp(rtype, "SAFSession")) load->type = GF_SM_LOAD_XSR; else if (!strcmp(rtype, "XMT-A")) load->type = GF_SM_LOAD_XMTA; else if (!strcmp(rtype, "X3D")) load->type = GF_SM_LOAD_X3D; free(rtype); } } } } if (!load->type) return e; if (!load->scene_graph) load->scene_graph = load->ctx->scene_graph; switch (load->type) { case GF_SM_LOAD_BT: case GF_SM_LOAD_VRML: case GF_SM_LOAD_X3DV: return gf_sm_load_init_BT(load); case GF_SM_LOAD_XMTA: case GF_SM_LOAD_X3D: return gf_sm_load_init_xmt(load); #ifndef GPAC_DISABLE_SVG #ifdef GPAC_ENABLE_SVG_SA case GF_SM_LOAD_SVG_SA: return gf_sm_load_init_svg_sa(load); #endif #ifdef GPAC_ENABLE_SVG_SANI case GF_SM_LOAD_SVG_SANI: return gf_sm_load_init_svg_sani(load); #endif case GF_SM_LOAD_SVG_DA: case GF_SM_LOAD_XSR: return gf_sm_load_init_svg(load); #endif #ifndef GPAC_READ_ONLY case GF_SM_LOAD_SWF: return gf_sm_load_init_SWF(load); case GF_SM_LOAD_QT: return gf_sm_load_init_QT(load); case GF_SM_LOAD_MP4: return gf_sm_load_init_MP4(load); #endif } return GF_NOT_SUPPORTED; }