1 Star 1 Fork 1

Devin / XPlay3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
XVideoThread.cpp 2.40 KB
一键复制 编辑 原始数据 按行查看 历史
伊兴龙 提交于 2022-09-14 16:29 . 增加了推流
#include "XVideoThread.h"
XVideoThread::XVideoThread()
{
}
XVideoThread::~XVideoThread()
{
}
bool XVideoThread::Open(AVCodecParameters *_pParam,IVideoWidget *_piVideoWidget,int _iWidth,int _iHeight)
{
if(_pParam == nullptr)
{
qDebug()<<"_pParam == nullptr";
return false;
}
if(_piVideoWidget == nullptr)
{
qDebug()<<"_piVideoWidget == nullptr";
return false;
}
if(m_pxDecode == nullptr)
{
qDebug()<<"m_pxDecode == nullptr";
return false;
}
Clear();
qi64Synpts = 0;
m_qmtxVideoThread.lock();
m_piVideoWidget = _piVideoWidget;
m_piVideoWidget->Init(_iWidth, _iHeight);
m_qmtxVideoThread.unlock();
int iResult = m_pxDecode->Open(_pParam);
if(!iResult)
{
qDebug()<<"Video XDecode open failed";
return false;
}
qDebug()<<"Video XDecode open success";
return true;
}
void XVideoThread::run()
{
while(!m_blIsExit)
{
m_qmtxVideoThread.lock();
//音视频同步
//qDebug()<<"111111==yxl== qi64Synpts = "<<qi64Synpts<<" m_pxDecode->qi64Pts=="<<m_pxDecode->qi64Pts;
if(qi64Synpts > 0 && qi64Synpts < m_pxDecode->qi64Pts)
{
//qDebug()<<"2222222==yxl== qi64Synpts = "<<qi64Synpts<<" m_pxDecode->qi64Pts=="<<m_pxDecode->qi64Pts;
m_qmtxVideoThread.unlock();
QThread::msleep(1);
continue;
}
//获取一帧数据
AVPacket *avPacket = Pop();
if(avPacket == nullptr)
{
m_qmtxVideoThread.unlock();
//qDebug()<<"XVideoThread avPacket == nullptr";
continue;
}
bool blResult = m_pxDecode->Send(avPacket);
if(!blResult)
{
qDebug()<<"m_pxDecode->Send error";
m_qmtxVideoThread.unlock();
QThread::msleep(1);
continue;
}
//一次send,多次recv
while(!m_blIsExit)
{
AVFrame *avFrame = m_pxDecode->Recv();
if(avFrame == nullptr)
{
//qDebug()<<"avFrame == nullptr";
break;
}
//显示视频
if(m_piVideoWidget)
{
m_piVideoWidget->Repaint(avFrame);
}
}
//40毫秒25帧每秒
QThread::msleep(40);
m_qmtxVideoThread.unlock();
}
return;
}
1
https://gitee.com/yixinglong/xplay3.git
git@gitee.com:yixinglong/xplay3.git
yixinglong
xplay3
XPlay3
master

搜索帮助