Exemple #1
0
static GF_Err AC3_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url)
{
	char szURL[2048];
	char *ext;
	GF_Err reply;
	AC3Reader *read = plug->priv;
	read->service = serv;

	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;

	strcpy(szURL, url);
	ext = strrchr(szURL, '#');
	if (ext) ext[0] = 0;

	/*remote fetch*/
	read->is_remote = !ac3_is_local(szURL);
	if (read->is_remote) {
		ac3_download_file(plug, (char *) szURL);
		return GF_OK;
	}

	reply = GF_OK;
	read->stream = gf_f64_open(szURL, "rb");
	if (!read->stream) {
		reply = GF_URL_ERROR;
	} else if (!AC3_ConfigureFromFile(read)) {
		fclose(read->stream);
		read->stream = NULL;
		reply = GF_NOT_SUPPORTED;
	}
	gf_service_connect_ack(serv, NULL, reply);
	if (!reply && read->is_inline ) AC3_SetupObject(read);
	return GF_OK;
}
Exemple #2
0
GF_Err ISOR_CloseService(GF_InputService *plug)
{
	GF_Err reply;
	ISOMReader *read;
	if (!plug || !plug->priv) return GF_SERVICE_ERROR;
	read = (ISOMReader *) plug->priv;
	reply = GF_OK;

	read->disconnected = GF_TRUE;

	while (gf_list_count(read->channels)) {
		ISOMChannel *ch = (ISOMChannel *)gf_list_get(read->channels, 0);
		gf_list_rem(read->channels, 0);
		isor_delete_channel(read, ch);
	}

	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;

	if (read->mov) gf_isom_close(read->mov);
	read->mov = NULL;

	if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) {
		send_proxy_command(read, GF_TRUE, GF_FALSE, reply, NULL, NULL);
	} else {
		gf_service_disconnect_ack(read->service, NULL, reply);
	}
	return GF_OK;
}
Exemple #3
0
static GF_Err ISMA_GetGPAC_KMS(ISMAEAPriv *priv, GF_Channel *ch, const char *kms_url)
{
	GF_Err e;
	FILE *t;
	GF_DownloadSession * sess;
	if (!strnicmp(kms_url, "(ipmp)", 6)) return GF_NOT_SUPPORTED;
	else if (!strnicmp(kms_url, "(uri)", 5)) kms_url += 5;
	else if (!strnicmp(kms_url, "file://", 7)) kms_url += 7;

	/*try local*/
	t = (strstr(kms_url, "://") == NULL) ? gf_fopen(kms_url, "r") : NULL;
	if (t) {
		gf_fclose(t);
		return gf_ismacryp_gpac_get_info(ch->esd->ESID, (char *)kms_url, priv->key, priv->salt);
	}
	/*note that gpac doesn't have TLS support -> not really usefull. As a general remark, ISMACryp
	is supported as a proof of concept, crypto and IPMP being the last priority on gpac...*/
	GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[CENC/ISMA] Fetching ISMACryp key for channel %d\n", ch->esd->ESID) );

	sess = gf_service_download_new(ch->service, kms_url, 0, ISMA_KMS_NetIO, ch);
	if (!sess) return GF_IO_ERR;
	/*start our download (threaded)*/
	gf_dm_sess_process(sess);

	while (1) {
		e = gf_dm_sess_get_stats(sess, NULL, NULL, NULL, NULL, NULL, NULL);
		if (e) break;
	}
	if (e==GF_EOS) {
		e = gf_ismacryp_gpac_get_info(ch->esd->ESID, (char *) gf_dm_sess_get_cache_name(sess), priv->key, priv->salt);
	}
	gf_service_download_del(sess);
	return e;
}
Exemple #4
0
static GF_Err FFD_CloseService(GF_InputService *plug)
{
	FFDemux *ffd = plug->priv;

	ffd->is_running = 0;

#ifndef FF_API_CLOSE_INPUT_FILE
	if (ffd->ctx) av_close_input_file(ffd->ctx);
#else
	if (ffd->ctx) avformat_close_input(&ffd->ctx);
#endif

	ffd->ctx = NULL;
	ffd->audio_ch = ffd->video_ch = NULL;
	ffd->audio_run = ffd->video_run = 0;

	if (ffd->dnload) {
		if (ffd->is_running) {
			while (!ffd->is_running) gf_sleep(1);
			ffd->is_running = 0;
		}
		gf_service_download_del(ffd->dnload);
		ffd->dnload = NULL;
	}
	if (ffd->buffer) gf_free(ffd->buffer);
	ffd->buffer = NULL;

	gf_service_disconnect_ack(ffd->service, NULL, GF_OK);
#ifdef FFMPEG_DUMP_REMOTE
	if (ffd->outdbg) fclose(ffd->outdbg);
#endif
	return GF_OK;
}
Exemple #5
0
static GF_Err IMG_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url)
{
    char *sExt;
    IMGLoader *read = (IMGLoader *)plug->priv;

    read->service = serv;
    if (!url)
        return GF_BAD_PARAM;
    sExt = strrchr(url, '.');
    if (!stricmp(sExt, ".jpeg") || !stricmp(sExt, ".jpg")) read->img_type = IMG_JPEG;
    else if (!stricmp(sExt, ".png")) read->img_type = IMG_PNG;
    else if (!stricmp(sExt, ".pngd")) read->img_type = IMG_PNGD;
    else if (!stricmp(sExt, ".pngds")) read->img_type = IMG_PNGDS;
    else if (!stricmp(sExt, ".pngs")) read->img_type = IMG_PNGS;
    else if (!stricmp(sExt, ".bmp")) read->img_type = IMG_BMP;

    if (read->dnload) gf_service_download_del(read->dnload);
    read->dnload = NULL;

    /*remote fetch*/
    if (!jp_is_local(url)) {
        jp_download_file(plug, url);
        return GF_OK;
    }

    read->stream = fopen(url, "rb");
    if (read->stream) {
        gf_f64_seek(read->stream, 0, SEEK_END);
        read->data_size = (u32) gf_f64_tell(read->stream);
        gf_f64_seek(read->stream, 0, SEEK_SET);
    }
    gf_service_connect_ack(serv, NULL, read->stream ? GF_OK : GF_URL_ERROR);
    if (read->stream && read->is_inline) IMG_SetupObject(read);
    return GF_OK;
}
Exemple #6
0
static GF_Err VTT_CloseService(GF_InputService *plug)
{
	VTTIn *vttin;
	if (!plug)	return GF_BAD_PARAM;

	vttin = (VTTIn *)plug->priv;
	if (!vttin)	return GF_BAD_PARAM;

	//if (vttin->szFile) {
	//	gf_delete_file(vttin->szFile);
	//	gf_free(vttin->szFile);
	//}
	//vttin->szFile = NULL;

	if (vttin->dnload) {
		gf_service_download_del(vttin->dnload);
	}
	vttin->dnload = NULL;

	if (vttin->service) {
		gf_service_disconnect_ack(vttin->service, NULL, GF_OK);
	}
	vttin->service = NULL;

	return GF_OK;
}
Exemple #7
0
GF_Err DC_CloseService(GF_InputService *plug)
{
	DCReader *read = (DCReader *) plug->priv;
	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;
	gf_service_disconnect_ack(read->service, NULL, GF_OK);
	return GF_OK;
}
Exemple #8
0
u32 RP_Thread(void *param)
{
    u32 i;
    GF_NetworkCommand com;
    RTSPSession *sess;
    RTPStream *ch;
    RTPClient *rtp = (RTPClient *)param;

    rtp->th_state = 1;
    com.command_type = GF_NET_CHAN_BUFFER_QUERY;
    while (rtp->th_state) {
        gf_mx_p(rtp->mx);

        /*fecth data on udp*/
        i=0;
        while ((ch = (RTPStream *)gf_list_enum(rtp->channels, &i))) {
            if ((ch->flags & RTP_EOS) || (ch->status!=RTP_Running) ) continue;
            /*for interleaved channels don't read too fast, query the buffer occupancy*/
            if (ch->flags & RTP_INTERLEAVED) {
                com.base.on_channel = ch->channel;
                gf_service_command(rtp->service, &com, GF_OK);
                /*if no buffering, use a default value (3 sec of data should do it)*/
                if (!com.buffer.max) com.buffer.max = 3000;
                if (com.buffer.occupancy <= com.buffer.max) ch->rtsp->flags |= RTSP_TCP_FLUSH;
            } else {
                RP_ReadStream(ch);
            }
        }

        /*and process commands / flush TCP*/
        i=0;
        while ((sess = (RTSPSession *)gf_list_enum(rtp->sessions, &i))) {
            RP_ProcessCommands(sess);

            if (sess->connect_error) {
                gf_service_connect_ack(sess->owner->service, NULL, sess->connect_error);
                sess->connect_error = 0;
            }

        }

        gf_mx_v(rtp->mx);

        gf_sleep(1);
    }

    if (rtp->dnload) gf_service_download_del(rtp->dnload);
    rtp->dnload = NULL;

    rtp->th_state = 2;
    return 0;
}
Exemple #9
0
static GF_Err AC3_CloseService(GF_InputService *plug)
{
	AC3Reader *read = plug->priv;
	if (read->stream) fclose(read->stream);
	read->stream = NULL;
	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;

	if (read->data) gf_free(read->data);
	read->data = NULL;
	gf_service_disconnect_ack(read->service, NULL, GF_OK);
	return GF_OK;
}
Exemple #10
0
static GF_Err IMG_CloseService(GF_InputService *plug)
{
	IMGLoader *read;
	if (!plug)
		return GF_BAD_PARAM;
	read = (IMGLoader *)plug->priv;
	if (!read)
		return GF_BAD_PARAM;
	if (read->stream) gf_fclose(read->stream);
	read->stream = NULL;
	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;
	if (read->service)
		gf_service_disconnect_ack(read->service, NULL, GF_OK);
	return GF_OK;
}
Exemple #11
0
static GF_Err SAF_CloseService(GF_InputService *plug)
{
	SAFIn *read = (SAFIn *)plug->priv;

	if (read->th) {
		if (read->run_state == 1) {
			read->run_state=0;
			while (read->run_state!=2) gf_sleep(2);
		}
		gf_th_del(read->th);
		read->th = NULL;
	}

	if (read->stream) fclose(read->stream);
	read->stream = NULL;
	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;
	gf_service_disconnect_ack(read->service, NULL, GF_OK);
	return GF_OK;
}
Exemple #12
0
static GF_Err VTT_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url)
{
	GF_Err e;
	VTTIn *vttin = (VTTIn *)plug->priv;
	if (!plug || !url)
		return GF_BAD_PARAM;
	vttin->service = serv;

	if (vttin->dnload) gf_service_download_del(vttin->dnload);
	vttin->dnload = NULL;

	/*remote fetch*/
	if (!VTT_is_local(url)) {
		VTT_download_file(plug, url);
		return GF_OK;
	} else {
		e = GF_OK;
		//e = TTIn_LoadFile(plug, url, 0);
		gf_service_connect_ack(serv, NULL, e);
		//if (!e && !vttin->od_done) tti_setup_object(vttin);
	}
	return GF_OK;
}
Exemple #13
0
static GF_Err SAF_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url)
{
	char szURL[2048];
	char *ext;
	SAFIn *read = (SAFIn *)plug->priv;
	read->service = serv;

	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;

	strcpy(szURL, url);
	ext = strrchr(szURL, '#');
	if (ext) ext[0] = 0;

	read->needs_connection = 1;
	read->duration = 0;

	read->saf_type = SAF_FILE_LOCAL;
	/*remote fetch*/
	if (strnicmp(url, "file://", 7) && strstr(url, "://")) {
		read->saf_type = SAF_FILE_REMOTE;
		SAF_DownloadFile(plug, (char *) szURL);
		return GF_OK;
	}

	read->stream = gf_f64_open(szURL, "rb");
	if (!read->stream) {
		gf_service_connect_ack(serv, NULL, GF_URL_ERROR);
		return GF_OK;
	}
	SAF_CheckFile(read);
	read->th = gf_th_new("SAFDemux");
	/*start playing for tune-in*/
	gf_th_run(read->th, SAF_Run, read);
	return GF_OK;
}
Exemple #14
0
void RP_FetchSDP(RTPClient *rtp, char *url, RTPStream *stream, char *original_url)
{
	SDPFetch *sdp;
	/*if local URL get file*/
	if (strstr(url, "data:application/sdp")) {
		RP_SDPFromData(rtp, url, stream);
		return;
	}
	if (!strnicmp(url, "file://", 7) || !strstr(url, "://")) {
		RP_SDPFromFile(rtp, url, stream);
		return;
	}

	sdp = (SDPFetch*)gf_malloc(sizeof(SDPFetch));
	memset(sdp, 0, sizeof(SDPFetch));
	sdp->client = rtp;
	sdp->remote_url = gf_strdup(url);
	sdp->chan = stream;
	if (original_url) {
		sdp->original_url = gf_strdup(original_url);
	}

	/*otherwise setup download*/
	if (rtp->dnload) gf_service_download_del(rtp->dnload);
	rtp->dnload = NULL;

	rtp->sdp_temp = sdp;
	rtp->dnload = gf_service_download_new(rtp->service, url, 0, SDP_NetIO, rtp);
	if (!rtp->dnload) {
		gf_service_connect_ack(rtp->service, NULL, GF_NOT_SUPPORTED);
	} else {
		/*start our download (threaded)*/
		gf_dm_sess_process(rtp->dnload);
	}
	/*service confirm is done once fetched*/
}
Exemple #15
0
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;
}
Exemple #16
0
void mpdin_dash_io_del(GF_DASHFileIO *dashio, GF_DASHFileIOSession session)
{
	gf_service_download_del((GF_DownloadSession *)session);
}
Exemple #17
0
GF_Err ISOR_ConnectService(GF_InputService *plug, GF_ClientService *serv, const char *url)
{
	char szURL[2048];
	char *tmp;
	ISOMReader *read;
	if (!plug || !plug->priv || !serv) return GF_SERVICE_ERROR;
	read = (ISOMReader *) plug->priv;

	read->input = plug;
	read->service = serv;

	if (read->dnload) gf_service_download_del(read->dnload);
	read->dnload = NULL;

	if (!url) return GF_URL_ERROR;

	strcpy(szURL, url);
	tmp = strrchr(szURL, '.');
	if (tmp) {
		tmp = strchr(tmp, '#');
		if (tmp) {
			if (!strnicmp(tmp, "#trackID=", 9)) {
				read->play_only_track_id = atoi(tmp+9);
			} else {
				read->play_only_track_id = atoi(tmp+1);
			}
			tmp[0] = 0;
		}
	}

	if (isor_is_local(szURL)) {
		GF_Err e;
		u64 start_range, end_range;
		start_range = end_range = 0;
		if (plug->query_proxy) {
			GF_NetworkCommand param;
			param.command_type = GF_NET_SERVICE_QUERY_INIT_RANGE;
			if (read->input->query_proxy(read->input, &param)==GF_OK) {
				start_range = param.url_query.start_range;
				end_range = param.url_query.end_range;
			}
		}
		e = gf_isom_open_progressive(szURL, start_range, end_range, &read->mov, &read->missing_bytes);
		if (e != GF_OK) {
			GF_LOG(GF_LOG_ERROR, GF_LOG_NETWORK, ("[IsoMedia] : error while opening %s, error=%s\n", szURL, gf_error_to_string(e)));
			if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) {
				send_proxy_command(read, 0, 0, e, NULL, NULL);
			} else {
				gf_service_connect_ack(read->service, NULL, e);
			}
			return GF_OK;
		}
		read->frag_type = gf_isom_is_fragmented(read->mov) ? 1 : 0;
		read->seg_opened = 2;

		read->time_scale = gf_isom_get_timescale(read->mov);
		/*reply to user*/
		if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) {
			send_proxy_command(read, GF_FALSE, GF_FALSE, GF_OK, NULL, NULL);
		} else {
			gf_service_connect_ack(read->service, NULL, GF_OK);
		}

		if (read->no_service_desc) isor_declare_objects(read);

	} else {
		/*setup downloader*/
		isor_setup_download(plug, szURL);
	}
	return GF_OK;
}
Exemple #18
0
GF_Err RP_ConnectServiceEx(GF_InputService *plug, GF_ClientService *serv, const char *url, Bool skip_migration)
{
    char *session_cache;
    RTSPSession *sess;
    RTPClient *priv = (RTPClient *)plug->priv;

    /*store user address*/
    priv->service = serv;

    if (priv->dnload) gf_service_download_del(priv->dnload);
    priv->dnload = NULL;

    GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] Opening service %s\n", url));

    /*load preferences*/
    RT_LoadPrefs(plug, priv);

    /*start thread*/
    gf_th_run(priv->th, RP_Thread, priv);

    if (!skip_migration) {
        session_cache = (char *) gf_modules_get_option((GF_BaseInterface *) plug, "Streaming", "SessionMigrationFile");
        if (session_cache && session_cache[0]) {
            FILE *f = gf_f64_open(session_cache, "rb");
            if (f) {
                fclose(f);
                GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] Restarting RTSP session from %s\n", session_cache));
                RP_FetchSDP(priv, (char *) session_cache, NULL, (char *) url);
                return GF_OK;
            }
            if (!strncmp(session_cache, "http://", 7)) {
                GF_LOG(GF_LOG_INFO, GF_LOG_RTP, ("[RTP] Restarting RTSP session from %s\n", session_cache));
                RP_FetchSDP(priv, (char *) session_cache, NULL, (char *) url);
                return GF_OK;
            }
        }
    }


    /*local or remote SDP*/
    if (strstr(url, "data:application/sdp") || (strnicmp(url, "rtsp", 4) && strstr(url, ".sdp")) ) {
        RP_FetchSDP(priv, (char *) url, NULL, NULL);
        return GF_OK;
    }

    /*rtsp and rtsp over udp*/
    if (!strnicmp(url, "rtsp://", 7) || !strnicmp(url, "rtspu://", 8)) {
        char *the_url = gf_strdup(url);
        char *the_ext = strrchr(the_url, '#');
        if (the_ext) {
            if (!stricmp(the_ext, "#audio")) priv->media_type = GF_MEDIA_OBJECT_AUDIO;
            else if (!stricmp(the_ext, "#video")) priv->media_type = GF_MEDIA_OBJECT_VIDEO;
            the_ext[0] = 0;
        }
        sess = RP_NewSession(priv, (char *) the_url);
        gf_free(the_url);
        if (!sess) {
            gf_service_connect_ack(serv, NULL, GF_NOT_SUPPORTED);
        } else {
            RP_Describe(sess, 0, NULL);
        }
        return GF_OK;
    }

    /*direct RTP (no control) or embedded data - this means the service is attached to a single channel (no IOD)
    reply right away*/
    gf_service_connect_ack(serv, NULL, GF_OK);
    RP_SetupObjects(priv);
    return GF_OK;
}