Пример #1
0
static char *get_mime_type(GF_Terminal *term, const char *url, GF_Err *ret_code, GF_DownloadSession **the_session)
{
	char * ret = NULL;
	GF_DownloadSession * sess;
	(*ret_code) = GF_OK;
	if (strnicmp(url, "http", 4)) return NULL;

	/*don't use any NetIO and don't issue a HEAD command, always go for GET and store the session */
	sess = gf_dm_sess_new(term->downloader, (char *) url, GF_NETIO_SESSION_NOT_THREADED | GF_NETIO_SESSION_NOT_CACHED, NULL, NULL, ret_code);
	if (!sess) {
		if (strstr(url, "rtsp://") || strstr(url, "rtp://") || strstr(url, "udp://") || strstr(url, "tcp://") ) (*ret_code) = GF_OK;
		return NULL;
	} else {
		/*start processing the resource, and stop if error or as soon as we get data*/
		while (1) {
			*ret_code = gf_dm_sess_process_headers(sess);
			if (*ret_code) break;
			if (gf_dm_sess_get_status(sess)>=GF_NETIO_DATA_EXCHANGE) {
				const char * mime = gf_dm_sess_mime_type(sess);
				/* The mime type is returned lower case */
				if (mime){
					ret = gf_strdup(mime);
				}
				break;
			}
		}
	}

	if (the_session && (*ret_code == GF_OK)) {
		*the_session = sess;
	} else {
		gf_dm_sess_del(sess);
	}
	return ret;
}
Пример #2
0
const char *mpdin_dash_io_get_mime(GF_DASHFileIO *dashio, GF_DASHFileIOSession session)
{
	return gf_dm_sess_mime_type((GF_DownloadSession *)session);
}