コード例 #1
0
ファイル: rtsp-client-pause.c プロジェクト: cyzn/media-server
// aggregate control reply
static void rtsp_client_aggregate_pause_onreply(void* rtsp, int r, void* parser)
{
	int code;
	struct rtsp_client_context_t* ctx;

	ctx = (struct rtsp_client_context_t*)rtsp;
	assert(RTSP_PAUSE == ctx->status);
	assert(0 == ctx->progress);
	assert(ctx->aggregate);
	if(0 != r)
	{
		ctx->client.onpause(ctx->param, r);
		return;
	}

	code = rtsp_get_status_code(parser);
	if(459 == code) // 459 Aggregate operation not allowed (p26)
	{
		r = rtsp_client_media_pause(ctx);
		if(0 != r)
			ctx->client.onpause(ctx->param, -1);
	}
	else
	{
		ctx->client.onpause(ctx->param, 200==code ? 0 : -1);
	}
}
コード例 #2
0
ファイル: rtsp-client-pause.c プロジェクト: cyzn/media-server
int rtsp_client_pause(void* rtsp)
{
	struct rtsp_client_context_t *ctx;
	ctx = (struct rtsp_client_context_t*)rtsp;
	if(RTSP_PAUSE == ctx->status)
		return 0;

	assert(RTSP_SETUP==ctx->status || RTSP_PLAY==ctx->status);
	ctx->status = RTSP_PAUSE;
	ctx->progress = 0;

	if(ctx->aggregate)
	{
		assert(ctx->media_count > 0);
		assert(ctx->aggregate_uri[0]);
		snprintf(ctx->req, sizeof(ctx->req), 
			"PAUSE %s RTSP/1.0\r\n"
			"CSeq: %u\r\n"
			"Session: %s\r\n"
			"User-Agent: %s\r\n"
			"\r\n", 
			ctx->aggregate_uri, ctx->cseq++, ctx->media[0].session, USER_AGENT);

		return ctx->client.request(ctx->transport, ctx->aggregate_uri, ctx->req, strlen(ctx->req), ctx, rtsp_client_aggregate_pause_onreply);
	}
	else
	{
		return rtsp_client_media_pause(ctx);
	}
}
コード例 #3
0
// aggregate control reply
static int rtsp_client_aggregate_pause_onreply(struct rtsp_client_t* rtsp, void* parser)
{
	int code;

	assert(rtsp->aggregate);
	code = rtsp_get_status_code(parser);
	if (459 == code) // 459 Aggregate operation not allowed (p26)
	{
		rtsp->aggregate = 0;
		return rtsp_client_media_pause(rtsp);
	}
	else if(200 == code)
	{
		return rtsp->handler.onpause(rtsp->param);
	}

	return -1;
}
コード例 #4
0
int rtsp_client_pause(struct rtsp_client_t *rtsp)
{
	int r;
	assert(RTSP_SETUP == rtsp->state || RTSP_PLAY == rtsp->state || RTSP_PAUSE == rtsp->state);
	rtsp->state = RTSP_PAUSE;
	rtsp->progress = 0;

	if(rtsp->aggregate)
	{
		assert(rtsp->media_count > 0);
		assert(rtsp->aggregate_uri[0]);
		r = rtsp_client_authenrization(rtsp, "PAUSE", rtsp->aggregate_uri, NULL, 0, rtsp->authenrization, sizeof(rtsp->authenrization));
		r = snprintf(rtsp->req, sizeof(rtsp->req), sc_format, rtsp->aggregate_uri, rtsp->cseq++, rtsp->media[0].session.session, rtsp->authenrization, USER_AGENT);
		assert(r > 0 && r < sizeof(rtsp->req));
		return r == rtsp->handler.send(rtsp->param, rtsp->aggregate_uri, rtsp->req, r) ? 0 : -1;
	}
	else
	{
		return rtsp_client_media_pause(rtsp);
	}
}
コード例 #5
0
ファイル: rtsp-client-pause.c プロジェクト: cyzn/media-server
static void rtsp_client_media_pause_onreply(void* rtsp, int r, void* parser)
{
	int code;
	struct rtsp_client_context_t* ctx;

	ctx = (struct rtsp_client_context_t*)rtsp;
	assert(0 == ctx->aggregate);
	assert(RTSP_PAUSE == ctx->status);
	assert(ctx->progress < ctx->media_count);

	if(0 != r)
	{
		ctx->client.onpause(ctx->param, r);
		return;
	}

	code = rtsp_get_status_code(parser);
	assert(460 != code); // 460 Only aggregate operation allowed (p26)

	if(200 == code)
	{
		if(ctx->media_count == ++ctx->progress)
		{
			ctx->client.onpause(ctx->param, 0);
		}
		else
		{
			r = rtsp_client_media_pause(ctx);
			if(0 != r)
			{
				ctx->client.onpause(ctx->param, r);
			}
		}
	}
	else
	{
		ctx->client.onpause(ctx->param, -1);
	}
}
コード例 #6
0
static int rtsp_client_media_pause_onreply(struct rtsp_client_t* rtsp, void* parser)
{
	int code;
	assert(0 == rtsp->aggregate);
	assert(rtsp->progress < rtsp->media_count);

	code = rtsp_get_status_code(parser);
	assert(460 != code); // 460 Only aggregate operation allowed (p26)
	if (200 == code)
	{
		if (rtsp->media_count == ++rtsp->progress)
		{
			return rtsp->handler.onpause(rtsp->param);
		}
		else
		{
			return rtsp_client_media_pause(rtsp);
		}
	}
	else
	{
		return -1;
	}
}