2024-01-18 15:41:43 +08:00
|
|
|
|
#ifndef CHANNEL_H
|
|
|
|
|
#define CHANNEL_H
|
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
#include "Json.h"
|
2024-01-18 15:41:43 +08:00
|
|
|
|
#include "Link.h"
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
class Channel : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2024-03-04 16:22:40 +08:00
|
|
|
|
enum PlaybackState {
|
|
|
|
|
Stop,
|
|
|
|
|
Playback,
|
|
|
|
|
Pause,
|
2024-05-07 15:06:36 +08:00
|
|
|
|
Error,
|
|
|
|
|
Finish
|
2024-03-04 16:22:40 +08:00
|
|
|
|
};
|
2024-12-24 03:51:48 +08:00
|
|
|
|
|
|
|
|
|
enum Resolution {
|
|
|
|
|
VO_OUTPUT_1080I60,
|
|
|
|
|
VO_OUTPUT_1600x1200_60,
|
|
|
|
|
VO_OUTPUT_1280x1024_60,
|
|
|
|
|
VO_OUTPUT_1280x720_60,
|
|
|
|
|
VO_OUTPUT_1024x768_60,
|
|
|
|
|
VO_OUTPUT_800x600_60
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit Channel(const QString& name, const QVariantMap& params, QObject* parent = nullptr);
|
2024-08-22 15:29:39 +08:00
|
|
|
|
~Channel();
|
2024-01-18 15:41:43 +08:00
|
|
|
|
void init();
|
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 输出分辨率
|
|
|
|
|
void changeOutputResolution(Resolution resolution);
|
|
|
|
|
void changeInputResolution(int width, int height);
|
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
// 录制
|
|
|
|
|
void startRecord();
|
|
|
|
|
void stopRecord();
|
|
|
|
|
|
|
|
|
|
// 回放
|
|
|
|
|
bool startPlayback(QString path);
|
2024-12-24 03:51:48 +08:00
|
|
|
|
void seek(int pos);
|
2024-08-12 11:26:42 +08:00
|
|
|
|
void togglePause();
|
|
|
|
|
void startPlayLive();
|
|
|
|
|
void showFinishPromot();
|
|
|
|
|
|
|
|
|
|
// 音量
|
2024-08-22 15:29:39 +08:00
|
|
|
|
static QVariantMap getVolume();
|
|
|
|
|
static void volumeUp();
|
|
|
|
|
static void volumeDown();
|
2024-08-12 11:26:42 +08:00
|
|
|
|
|
|
|
|
|
public:
|
2024-01-18 15:41:43 +08:00
|
|
|
|
QString channelName;
|
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 视频输入输出
|
|
|
|
|
LinkObject* videoInput = nullptr;
|
|
|
|
|
LinkObject* videoOutput = nullptr;
|
|
|
|
|
QVariantMap videoOutputParams;
|
|
|
|
|
|
|
|
|
|
// 视频编码
|
|
|
|
|
LinkObject* videoEncoder = nullptr;
|
2024-01-18 15:41:43 +08:00
|
|
|
|
QVariantMap videoEncoderParams;
|
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 外接音频输入输出
|
2024-08-12 11:26:42 +08:00
|
|
|
|
static LinkObject* lineIn; // 外部音频输入
|
|
|
|
|
static LinkObject* resample; // 重采样
|
|
|
|
|
static LinkObject* lineOut; // 外部音频输出
|
2024-08-22 15:29:39 +08:00
|
|
|
|
static LinkObject* gain; // 音量增益
|
|
|
|
|
static LinkObject* volume; // 音量
|
|
|
|
|
static int maxGian; // 最大增益
|
|
|
|
|
static int minGain; // 最小增益
|
|
|
|
|
static int curGain; // 当前增益
|
2024-08-12 11:26:42 +08:00
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 通道音频输入输出
|
|
|
|
|
LinkObject* audioInput = nullptr; // 通道音频输入
|
|
|
|
|
LinkObject* audioOutput = nullptr; // 通道音频输入
|
|
|
|
|
LinkObject* audioEncoder = nullptr; // 音频编码器
|
2024-08-12 11:26:42 +08:00
|
|
|
|
QVariantMap audioEncoderParams; // 编码参数
|
2024-01-18 15:41:43 +08:00
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 视频录制
|
|
|
|
|
LinkObject* record = nullptr;
|
|
|
|
|
LinkObject* calDuration = nullptr;
|
|
|
|
|
LinkObject* calAudioDecoder = nullptr;
|
|
|
|
|
LinkObject* calVideoDecoder = nullptr;
|
|
|
|
|
int duration = 10 * 60 * 1000; // 单个视频时长
|
2024-01-18 15:41:43 +08:00
|
|
|
|
bool isRecord = false;
|
2024-08-12 11:26:42 +08:00
|
|
|
|
QString startTime; // 本次录制文件的开始时间
|
2024-08-23 13:34:58 +08:00
|
|
|
|
QString curTime; // 当前录制文件的开始时间
|
2024-12-24 03:51:48 +08:00
|
|
|
|
int segmentId = 0; // 分片录制的id
|
|
|
|
|
|
|
|
|
|
// 水印
|
|
|
|
|
LinkObject* overlay = nullptr; // 水印,提示是否在录制视频
|
2024-08-12 11:26:42 +08:00
|
|
|
|
QVariantMap recordOverlay; // 录制状态下的水印参数
|
|
|
|
|
QVariantMap norecordOverlay; // 非录制状态下的水印参数
|
2024-01-18 15:41:43 +08:00
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 视频回放
|
2024-08-12 11:26:42 +08:00
|
|
|
|
int playbackDuration = 0; // 当前播放视频的时长,单位ms
|
2024-12-24 03:51:48 +08:00
|
|
|
|
LinkObject* inputFile = nullptr;
|
|
|
|
|
LinkObject* videoDecoder = nullptr;
|
|
|
|
|
LinkObject* audioDecoder = nullptr;
|
|
|
|
|
LinkObject* image = nullptr;
|
2024-03-04 16:22:40 +08:00
|
|
|
|
PlaybackState state = Stop;
|
2024-01-18 15:41:43 +08:00
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
// 视频推流
|
2024-01-18 15:41:43 +08:00
|
|
|
|
static LinkObject* rtspServer;
|
2024-12-24 03:51:48 +08:00
|
|
|
|
LinkObject* rtsp = nullptr;
|
2024-01-18 15:41:43 +08:00
|
|
|
|
QString pushCode;
|
|
|
|
|
|
2024-12-24 03:51:48 +08:00
|
|
|
|
QMap<Resolution, QString> resolutionMap; // 分辨率列表
|
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
private slots:
|
|
|
|
|
void onNewEvent(QString msg, QVariant data);
|
2024-12-24 03:51:48 +08:00
|
|
|
|
void saveVideoInfo(QString curTime, int segmentId);
|
2024-05-07 15:06:36 +08:00
|
|
|
|
|
2024-01-18 15:41:43 +08:00
|
|
|
|
signals:
|
2024-01-25 09:57:08 +08:00
|
|
|
|
void playEnd();
|
2024-03-04 16:22:40 +08:00
|
|
|
|
void showRecordState(bool state);
|
2024-12-24 03:51:48 +08:00
|
|
|
|
void appendOneVideo();
|
2024-08-12 11:26:42 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void loadOverlayConfig();
|
2024-01-18 15:41:43 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // CHANNEL_H
|