76 lines
1.9 KiB
C
76 lines
1.9 KiB
C
|
#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
|
|||
|
|
|||
|
|
|||
|
|
|||
|
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;
|
|||
|
void initializeGL() override;
|
|||
|
void resizeGL(int w, int h) override;
|
|||
|
void paintGL() override;
|
|||
|
private:
|
|||
|
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>
|
|||
|
|
|||
|
|
|||
|
GLuint textureUnifromRGB; //rgb32 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
|||
|
GLuint id_rgb;
|
|||
|
GLuint id_y;
|
|||
|
GLuint id_u;
|
|||
|
GLuint id_v; //v<><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
|
|||
|
|
|||
|
QOpenGLTexture* m_pTextureRGB; //RGB <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
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>
|
|||
|
unsigned char *m_pBufYuv420p;
|
|||
|
unsigned char* m_pBufRgb32;
|
|||
|
|
|||
|
FILE* m_pYuvFile;
|
|||
|
|
|||
|
void initShaderYuv();
|
|||
|
void initShaderRgb();
|
|||
|
|
|||
|
int loadYuvTexture();
|
|||
|
int loadRgbTexture();
|
|||
|
};
|
|||
|
#endif
|