multimedia/client/qt_gl_/yuvgl/cplaywidget.h

76 lines
1.9 KiB
C
Raw Normal View History

2020-06-04 15:28:45 +00:00
#ifndef GLPLAYWIDGET_H
#define GLPLAYWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
#include <QFile>
#include "media/CameraCapture.h"
#include <QTimer>
#define ATTRIB_VERTEX 3
#define ATTRIB_TEXTURE 4
2021-10-02 05:58:29 +00:00
2020-06-04 15:28:45 +00:00
class CPlayWidget:public QOpenGLWidget,protected QOpenGLFunctions,public Camera::CameraObserver
{
Q_OBJECT
public slots:
void OnUpdateFrame();
void OnPaintData(const uint8_t *data,uint32_t len);
public:
typedef enum{
TYPE_YUV420P,
TYPE_RGB32,
}IMG_TYPE;
CPlayWidget(QWidget* parent);
~CPlayWidget();
void PlayOneFrame();
int SetDataType(IMG_TYPE);
int OnCameraData(uint8_t *dat, uint32_t size) override;
int SetImgSize(uint32_t width,uint32_t );
protected:
QTimer tm;
2021-10-02 05:58:29 +00:00
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
2020-06-04 15:28:45 +00:00
private:
2021-10-02 05:58:29 +00:00
IMG_TYPE mType; // Ŀǰֻ֧<D6BB>ֵ<EFBFBD>RGB32,YUV420P
GLuint textureUniformY; //y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
GLuint textureUniformU; //u<><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
GLuint textureUniformV; //v<><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
GLuint textureUniformRGB; //RGB<47><42><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2020-06-04 15:28:45 +00:00
2021-10-02 05:58:29 +00:00
GLuint textureUnifromRGB; //rgb32 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2020-06-04 15:28:45 +00:00
GLuint id_rgb;
GLuint id_y;
GLuint id_u;
2021-10-02 05:58:29 +00:00
GLuint id_v; //v<><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
2020-06-04 15:28:45 +00:00
2021-10-02 05:58:29 +00:00
QOpenGLTexture* m_pTextureRGB; //RGB <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2020-06-04 15:28:45 +00:00
2021-10-02 05:58:29 +00:00
QOpenGLTexture* m_pTextureY; //y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QOpenGLTexture* m_pTextureU; //u<><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QOpenGLTexture* m_pTextureV; //v<><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QOpenGLShader *m_pVSHader; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QOpenGLShader *m_pFSHader; //Ƭ<><C6AC><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QOpenGLShaderProgram *m_pShaderProgram; //<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int m_nVideoW; //<2F><>Ƶ<EFBFBD>ֱ<EFBFBD><D6B1>ʿ<EFBFBD>
int m_nVideoH; //<2F><>Ƶ<EFBFBD>ֱ<EFBFBD><D6B1>ʸ<EFBFBD>
2020-06-04 15:28:45 +00:00
unsigned char *m_pBufYuv420p;
unsigned char* m_pBufRgb32;
FILE* m_pYuvFile;
void initShaderYuv();
void initShaderRgb();
int loadYuvTexture();
int loadRgbTexture();
};
#endif