qt_rtmp_demo/cplaywidget.h

82 lines
2.1 KiB
C
Raw Normal View History

2023-11-12 16:13:24 +00:00
#ifndef GLPLAYWIDGET_H
#define GLPLAYWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
#include <QFile>
#include "media/CameraCapture.h"
2024-06-16 16:14:06 +00:00
#include "media/screen_capture.h"
2023-11-12 16:13:24 +00:00
#include <QTimer>
#define ATTRIB_VERTEX 3
#define ATTRIB_TEXTURE 4
2024-06-16 16:14:06 +00:00
class CPlayWidget:public QOpenGLWidget,
protected QOpenGLFunctions,
public Camera::CameraObserver,
public ScreenCapture::CaptureVideoObserver
2023-11-12 16:13:24 +00:00
{
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 );
2024-06-16 16:14:06 +00:00
void OnScreenData(const void *frameaddress, uint32_t framelen) override;
2023-11-12 16:13:24 +00:00
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;
2024-06-16 16:14:06 +00:00
QTimer mTimer;
2023-11-12 16:13:24 +00:00
FILE* m_pYuvFile;
void initShaderYuv();
void initShaderRgb();
int loadYuvTexture();
int loadRgbTexture();
};
#endif