AVDecoder.h 1.0 KB
#pragma once
#include "AudioDecoder.h"
#include "VideoDecoder.h"

class CAVDecoder
{
public:
	CAVDecoder();
	virtual ~CAVDecoder();

	int add(media_info &info);

	unsigned int getuid();
	bool get_one_a_frame();
	bool get_one_v_frame();
	std::string get_cur_vfile();
	std::string get_cur_afile();
	double _cur_a_ts_ms;
	double _cur_v_ts_ms;
	media_role _media_role;

	AVFrame * _cur_a_frame;
	AVFrame * _cur_v_frame;
protected:
	list<media_info> _video_info;
	list<media_info> _audio_info;
	CAudioDecoder _audio_decoder;
	CVideoDecoder _video_decoder;
	int64_t _a_start_time_ms;
	int64_t _a_end_time_ms;
	int64_t _v_start_time_ms;
	int64_t _v_end_time_ms;
	int64_t _end_time_ms;
	unsigned int _uid;


protected:
	void free_cur_v_frame();
	void free_cur_a_frame();
public:
	int scale_frame(AVFrame * pFrame, AVFrame * pScaledFrame, int scaled_width, int scaled_height);

protected:
	int _scaled_width;
	int _scaled_height;
	int _src_width;
	int _src_height;
	struct SwsContext * _sws_ctx;

};