#include "VideoThread.h"#include "CppEasyFFmpeg.h"#include "CppEasyAudioPlay.h"//#include "CppEasyAudioPlay.h"#include <list>using namespace std;bool isexit = false;static list<AVPacket> videos;static int apts = -1;VideoThread::VideoThread(){}void VideoThread::run(){char out[10000] = { 0 };while (!isexit){if (!CppEasyFFmpeg::Get()->isPlay) {msleep(10);continue;}while (videos.size() > 0){AVPacket pack = videos.front();int pts = CppEasyFFmpeg::Get()->GetPts(&pack);if (pts > apts){break;}CppEasyFFmpeg::Get()->Decode(&pack);av_packet_unref(&pack);videos.pop_front();}int free = CppEasyAudioPlay::Get()->GetFree();if (free < 10000){msleep(1);continue;}AVPacket pkt = CppEasyFFmpeg::Get()->Read();if (pkt.size <= 0){msleep(10);continue;}if (pkt.stream_index == CppEasyFFmpeg::Get()->audioStream){apts = CppEasyFFmpeg::Get()->Decode(&pkt);av_packet_unref(&pkt);int len = CppEasyFFmpeg::Get()->ToPCM(out);CppEasyAudioPlay::Get()->Write(out, len);continue;}if (pkt.stream_index != CppEasyFFmpeg::Get()->videoStream){av_packet_unref(&pkt);continue;}videos.push_back(pkt);}}VideoThread::~VideoThread(){}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。