Ejemplo n.º 1
0
void cgit_cleanup_filters(void)
{
	int i;
	reap_filter(ctx.cfg.about_filter);
	reap_filter(ctx.cfg.commit_filter);
	reap_filter(ctx.cfg.source_filter);
	reap_filter(ctx.cfg.email_filter);
	reap_filter(ctx.cfg.auth_filter);
	for (i = 0; i < cgit_repolist.count; ++i) {
		reap_filter(cgit_repolist.repos[i].about_filter);
		reap_filter(cgit_repolist.repos[i].commit_filter);
		reap_filter(cgit_repolist.repos[i].source_filter);
		reap_filter(cgit_repolist.repos[i].email_filter);
	}
}
Ejemplo n.º 2
0
struct lsInput* get_best_input(struct liveStream *ctx)
{
	struct lsInput* input = NULL;
	struct lsInput* best_input = NULL;
	int nb_requests = 0;
	int nb_requests_max = 0;
	int ret = 0;

	if ( ctx->have_filter )
	{
		take_filter_lock(&ctx->filter_lock);
		ret = avfilter_graph_request_oldest(ctx->filter_graph);
		give_filter_lock(&ctx->filter_lock);
		if(ret >= 0)
		{
			reap_filter(ctx);
		}

		for(input = ctx->inputs;input;input = input->next)
		{
			if(input->eof_reached)
				continue;
			take_filter_lock(&ctx->filter_lock);
			nb_requests = av_buffersrc_get_nb_failed_requests(input->in_filter);
			give_filter_lock(&ctx->filter_lock);
			if (nb_requests >  nb_requests_max)
			{
				nb_requests_max = nb_requests;
				best_input = input;
			}
		}
	}
	else
	{
		for(input = ctx->inputs;input;input = input->next)
		{
			if(input->eof_reached)
				continue;
			/* XXX select from PTS or DTS */
			best_input = ctx->inputs;
		}
	}

	return best_input;
}
Ejemplo n.º 3
0
EXPORT int start_capture(void *actx)
{
	struct liveStream *ctx = (struct liveStream *)actx;
	int got_frame;
	int ret;
	AVPacket packet;
	AVFormatContext *ic;
	long long start_time;
	struct lsInput* input = NULL;
	AVRational av_time_base_q = {1, AV_TIME_BASE};

	if(!ctx)
	{
		ret = -1;
		goto end;
	}


	while(1)
	{
		AVCodecContext *dec_ctx = NULL;
		input = get_best_input(ctx);
		if(!input)
		{
			continue;
		}
		dec_ctx = input->dec_ctx;
		ic = input->ic;
		if (ic->start_time != AV_NOPTS_VALUE)
			start_time = ic->start_time;

		ret = get_input_packet(input,&packet);
		if (ret == AVERROR(EAGAIN))
		{
			continue;
		}
		else if (ret == AVERROR_EOF)
		{
			output_packet(input,NULL);
			input->eof_reached = 1;
			continue;
		}
		if(ret < 0)
		{
			av_log(NULL,AV_LOG_ERROR,"No Input packet %x\n",ret);
			break;
		}
		if(input->id != 1)
		{
			if (packet.pts != AV_NOPTS_VALUE)
			{
				packet.pts -= av_rescale_q(start_time, av_time_base_q, ic->streams[0]->time_base);
			}

			if (packet.dts != AV_NOPTS_VALUE)
				packet.dts -= av_rescale_q(start_time, av_time_base_q, ic->streams[0]->time_base);
		}
		if(packet.stream_index == 0)
		{
			ret = avcodec_decode_video2(dec_ctx, input->InFrame, &got_frame, &packet);
			if (ret < 0)
			{
				av_log(NULL, AV_LOG_ERROR, "Error decoding video\n");
				goto end;
			}
			if(!got_frame)
				continue;
		}
		else
		{
			continue;
		}


		av_free_packet(&packet);
		input->InFrame->pts = av_frame_get_best_effort_timestamp(input->InFrame);

		take_filter_lock(&ctx->filter_lock);
		if (av_buffersrc_add_frame_flags(input->in_filter, input->InFrame, AV_BUFFERSRC_FLAG_PUSH) < 0)
		{
			av_log(NULL, AV_LOG_ERROR,
					"Error while feeding the filtergraph\n");
		}
		give_filter_lock(&ctx->filter_lock);
		reap_filter(ctx);

	}
	av_frame_unref(input->InFrame);
end:
	return ret;
}