Exemple #1
0
int ffmpeg_getmoredata(struct ccx_demuxer *ctx, struct demuxer_data **ppdata)
{
	struct demuxer_data *data;
	int ret = 0;
    if(!*ppdata)
    {
        *ppdata = alloc_demuxer_data();
        if(!*ppdata)
            return -1;
        data = *ppdata;
        //TODO Set to dummy, find and set actual value
        data->program_number = 1;
        data->stream_pid = 1;
        data->codec  = CCX_CODEC_ATSC_CC;
		data->bufferdatatype = CCX_RAW_TYPE;
    }
    else
    {
        data = *ppdata;
    }

	do
	{
		int len = ff_get_ccframe(ctx->ffmpeg_ctx, data->buffer, BUFSIZE);
		if(len == AVERROR(EAGAIN))
		{
			continue;
		}
		else if(len == AVERROR_EOF)
		{
			ret = CCX_EOF;
			break;
		}
		else if(len == 0)
			continue;
		else if(len < 0 )
		{
			mprint("Error extracting Frame\n");
			break;

		}
		else
		{
			data->len = len;
			break;
		}

	}while(1);

	return ret;
}
int wtv_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata)
{
	static struct wtv_chunked_buffer cb;
	int ret = CCX_OK;
	struct demuxer_data *data;

	if(!*ppdata)
	{
		*ppdata = alloc_demuxer_data();
		if(!*ppdata)
			return -1;
		data = *ppdata;
		//TODO Set to dummy, find and set actual value
		data->program_number = 1;
		data->stream_pid = 1;
		data->codec  = CCX_CODEC_ATSC_CC;
	}
	else
	{
		data = *ppdata;
	}

	if(firstcall)
	{
		init_chunked_buffer(&cb);

		if(ccx_options.wtvmpeg2)
			data->bufferdatatype=CCX_PES;
		else
			data->bufferdatatype=CCX_RAW;

		read_header(ctx->demux_ctx, &cb);
		if(ret != CCX_OK)
		{
			// read_header returned an error
			// read_header will have printed the error message
			return ret;
		}
		firstcall=0;
	}
	ret = get_data(ctx, &cb, data);

	return ret;
}