Пример #1
0
static GF_Err RP_CloseService(GF_InputService *plug)
{
	u32 i;
	const char *opt;
	RTSPSession *sess;
	RTPClient *rtp = (RTPClient *)plug->priv;
	GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP] Closing service\n"));

	RP_FlushCommands(rtp);

	if (rtp->session_migration) {
		opt = gf_modules_get_option((GF_BaseInterface *) plug, "Streaming", "SessionMigrationPause");
		if (opt && !strcmp(opt, "yes")) {
			GF_NetworkCommand com;
			com.command_type = GF_NET_CHAN_PAUSE;
			com.base.on_channel = NULL;
			/*send pause on all sessions*/
			i=0;
			while ((sess = (RTSPSession *)gf_list_enum(rtp->sessions, &i))) {
				RP_UserCommand(sess, NULL, &com);
			}
		}
		RP_SaveSessionState(rtp);
	} else {
		/*remove session state file*/
		if (rtp->session_state_data) {
			gf_free(rtp->session_state_data);
			rtp->session_state_data = NULL;
		}

		/*send teardown on all sessions*/
		i=0;
		while ((sess = (RTSPSession *)gf_list_enum(rtp->sessions, &i))) {
			RP_Teardown(sess, NULL);
		}
	}
	RP_FlushCommands(rtp);

	/*shutdown thread*/
	if (rtp->th_state==1) rtp->th_state = 0;

	/*confirm close*/
	gf_term_on_disconnect(rtp->service, NULL, GF_OK);
	return GF_OK;
}
Пример #2
0
void RP_DeleteStream(RTPStream *ch)
{
	if (ch->rtsp) {
		if (ch->status == RTP_Running) {
			RP_Teardown(ch->rtsp, ch);
			ch->status = RTP_Disconnected;
		}
		RP_RemoveStream(ch->owner, ch);
	} else {
		RP_FindChannel(ch->owner, ch->channel, 0, NULL, 1);
	}

	if (ch->depacketizer) gf_rtp_depacketizer_del(ch->depacketizer);
	if (ch->rtp_ch) gf_rtp_del(ch->rtp_ch);
	if (ch->control) gf_free(ch->control);
	if (ch->session_id) gf_free(ch->session_id);
	gf_free(ch);
}