dtkmultimedia
DTK Multimedia module
载入中...
搜索中...
未找到
dscreenrecorder.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSCREENRECORDER_H
6#define DSCREENRECORDER_H
7
8#include <QUrl>
9#include <QMediaRecorder>
10#include <dtkmultimedia.h>
11DMULTIMEDIA_BEGIN_NAMESPACE
12
13typedef void (*VideoStreamCallback)(void *obj, int dataLength, unsigned char *data);
14class DScreenRecorderPrivate;
15
16class Q_MULTIMEDIA_EXPORT DScreenRecorder : public QMediaRecorder
17{
18 Q_OBJECT
19 Q_DECLARE_PRIVATE(DScreenRecorder)
20
21#ifdef BUILD_Qt6
22typedef RecorderState State ;
23#endif
24
25public:
26 enum VCodecID {
27 CODEC_ID_NO,
28 CODEC_ID_H264,
29 CODEC_ID_MPEG4,
30 };
31
32 enum PixFormatID {
33 PIX_FMT_YUV420P,
34 PIX_FMT_YUYV422,
35 PIX_FMT_RGB24,
36 PIX_FMT_BGR24,
37 PIX_FMT_ARGB,
38 PIX_FMT_RGBA,
39 };
40
41public:
42 DScreenRecorder(QObject *parent = nullptr);
44
45 VCodecID codec() const;
46 void setCodec(const VCodecID &codec);
47
48 PixFormatID pixfmt() const;
49 void setPixfmt(const PixFormatID pixfmt);
50
51 int bitRate() const;
52 void setBitRate(int bitrate);
53
54 int frameRate() const;
55 void setFrameRate(int rate);
56
57 void setResolution(const int width, const int height);
58 QSize resolution() const;
59
60 QUrl outputLocation() const;
61 bool setOutputLocation(const QUrl &location);
62
63 void setStreamAcceptFunc(VideoStreamCallback function, void *obj);
64
65 QPoint topLeft() const;
66 void setTopLeft(const int x, const int y);
67
68#if BUILD_Qt6
69 State state() const;
70#else
71 State state() const;
72#endif
73
74Q_SIGNALS:
75 void screenStreamData(QImage);
76public Q_SLOTS:
77 void record();
78 void stop();
79
80protected:
81 QScopedPointer<DScreenRecorderPrivate> d_ptr;
82};
83
84DMULTIMEDIA_END_NAMESPACE
85
86#endif // DSCREENRECORDER_H
DScreenRecorder类提供录屏相关接口,获取屏幕数据裸流.
Definition dscreenrecorder.h:17
QPoint topLeft() const
获取录制桌面位置.
bool setOutputLocation(const QUrl &location)
设置输出文件路径.
PixFormatID pixfmt() const
获取图片格式.
VCodecID codec() const
获取视频编码.
void setBitRate(int bitrate)
设置视频比特率.
State state() const
获取当前状态.
void setPixfmt(const PixFormatID pixfmt)
设置数据图片格式
void setCodec(const VCodecID &codec)
设置视频编码格式.
QSize resolution() const
获取视频宽高
int frameRate() const
获取视频帧率.
void setResolution(const int width, const int height)
设置视频宽高.
int bitRate() const
获取视频比特率.
void setFrameRate(int rate)
设置视频帧率.
void setTopLeft(const int x, const int y)
设置桌面录制坐标.
QUrl outputLocation() const
获取视频输出信息.