Ejemplo n.º 1
0
LOCAL ICACHE_FLASH_ATTR int handleCommandSchedule(clientInfo_t *cl)
{
    if (cl->argc!=1) {
        client_senderror(cl,"INVALID");
        return -1;
    }
    if (strcmp(cl->argv[0], "START")==0) {
        schedule_start();
    } else if (strcmp(cl->argv[0], "STOP")==0) {
        schedule_stop();
    } else {
        client_senderror(cl,"INVALID");
        return -1;
    }
    client_sendOK(cl,"SCHEDULE");

    return 0;
}
Ejemplo n.º 2
0
int RTSP_play(RTSP_buffer * pRtsp)
{
	char *pStr;
	char pTrash[128];
	long int s32SessionId;
	RTSP_session *pRtspSesn;
	RTP_session *pRtpSesn;

	//获取CSeq
	if ((pStr = strstr(pRtsp->in_buffer, HDR_CSEQ)) == NULL)
	{
		send_reply(400, 0, pRtsp);   /* Bad Request */
		printf("get CSeq!!400");
		return ERR_NOERROR;
	}
	else
	{
		if (sscanf(pStr, "%254s %d", pTrash, &(pRtsp->rtsp_cseq)) != 2)
		{
			send_reply(400, 0, pRtsp);    /* Bad Request */
			printf("get CSeq!! 2 400");
			return ERR_NOERROR;
		}
	}

	//获取session
	if ((pStr = strstr(pRtsp->in_buffer, HDR_SESSION)) != NULL)
	{
		if (sscanf(pStr, "%254s %ld", pTrash, &s32SessionId) != 2)
		{
			send_reply(454, 0, pRtsp);// Session Not Found
			printf("Session Not Found");
			return ERR_NOERROR;
		}
	}
	else
	{
		send_reply(400, 0, pRtsp);// bad request
		printf("Session Not Found bad request");
		return ERR_NOERROR;
	}

	//时间参数,假设都是 0-0,不做设置
/*	if ((pStr = strstr(pRtsp->in_buffer, HDR_RANGE)) != NULL)
	{
		if((pStrTime = strstr(pRtsp->in_buffer, "npt")) != NULL)
		{
			if((pStrTime = strstr(pStrTime, "=")) == NULL)
			{
				send_reply(400, 0, pRtsp);// Bad Request
				return ERR_NOERROR;
			}

		}
		else
		{

		}
	}
*/
	//播放list指向的rtp session
	pRtspSesn = pRtsp->session_list;
	if (pRtspSesn != NULL)
	{
		if (pRtspSesn->session_id == s32SessionId)
		{
			//查找RTP session,播放list中所有的session,本例程只有一个成员.
			for (pRtpSesn = pRtspSesn->rtp_session; pRtpSesn != NULL; pRtpSesn = pRtpSesn->next)
			{
				//播放所有演示
				if (!pRtpSesn->started)
				{
					//开始新的播放
					printf("\t+++++++++++++++++++++\n");
					printf("\tstart to play %d now!\n", pRtpSesn->sched_id);
					printf("\t+++++++++++++++++++++\n");

					if (schedule_start(pRtpSesn->sched_id, NULL) == ERR_ALLOC)
					{
						return ERR_ALLOC;
					}
				}
				else
				{
					//恢复暂停,播放
					if (!pRtpSesn->pause)
					{
						//fnc_log(FNC_LOG_INFO,"PLAY: already playing\n");
					}
					else
					{
//						schedule_resume(pRtpSesn->sched_id, NULL);
					}
				}

			}
		}
		else
		{
			send_reply(454, 0, pRtsp);	// Session not found
			return ERR_NOERROR;
		}
	}
	else
	{
		send_reply(415, 0, pRtsp);  // Internal server error
		return ERR_GENERIC;
	}

	send_play_reply(pRtsp, pRtspSesn);

	return ERR_NOERROR;
}