播放视频时同时播放音频
This commit is contained in:
		@@ -99,16 +99,19 @@ struct VideoParam
 | 
			
		||||
	int width;
 | 
			
		||||
	int height;
 | 
			
		||||
	int videoStreamIndex;
 | 
			
		||||
 | 
			
		||||
	AVStream* stream;
 | 
			
		||||
	bool eof = false;
 | 
			
		||||
	bool pause = false;
 | 
			
		||||
	bool quit = false;
 | 
			
		||||
	double totalTime = 0;
 | 
			
		||||
	double currentTime = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct AudioParam
 | 
			
		||||
{
 | 
			
		||||
	MediaQueue<AVPacket> packetQueue;
 | 
			
		||||
	AVCodecContext* codecCtx;
 | 
			
		||||
	AVStream* stream;
 | 
			
		||||
	int audioStreamIndex;
 | 
			
		||||
	static constexpr int MAX_BUFFER_SIZE = 192000;
 | 
			
		||||
	uint8_t* buffer = new uint8_t[MAX_BUFFER_SIZE];
 | 
			
		||||
@@ -118,6 +121,16 @@ struct AudioParam
 | 
			
		||||
	bool pause = false;
 | 
			
		||||
	bool isVideo = false;
 | 
			
		||||
	bool quit = false;
 | 
			
		||||
	double currentTime = 0;
 | 
			
		||||
	double totalTime = 0;
 | 
			
		||||
	double lastPts;
 | 
			
		||||
 | 
			
		||||
	double getCurrentTime() const
 | 
			
		||||
	{
 | 
			
		||||
		const int diff = bufferSize - bufferIndex;
 | 
			
		||||
		const int bytePreSec = codecCtx->sample_rate * codecCtx->ch_layout.nb_channels * 2;
 | 
			
		||||
		return currentTime - static_cast<double>(diff) / bytePreSec;
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct MediaParam
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,6 @@
 | 
			
		||||
#include "decodeParam.h"
 | 
			
		||||
 | 
			
		||||
void InitDecoder(const char* filepath, MediaParam& param);
 | 
			
		||||
void RequestVideoPacket(MediaParam& param);
 | 
			
		||||
void RequestMediaPacket(MediaParam& param);
 | 
			
		||||
void RequestVideoFrame(MediaParam& param);
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user