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-01-18 15:41:43 +08:00
|
|
|
|
explicit Channel(QObject* parent = nullptr);
|
|
|
|
|
void init();
|
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
// 录制
|
|
|
|
|
void startRecord();
|
|
|
|
|
void stopRecord();
|
|
|
|
|
|
|
|
|
|
// 回放
|
|
|
|
|
bool startPlayback(QString path);
|
|
|
|
|
void forward();
|
|
|
|
|
void back();
|
|
|
|
|
void togglePause();
|
|
|
|
|
void startPlayLive();
|
|
|
|
|
void showFinishPromot();
|
|
|
|
|
|
|
|
|
|
// 音量
|
|
|
|
|
QVariantMap getVolume();
|
|
|
|
|
void volumeUp();
|
|
|
|
|
void volumeDown();
|
|
|
|
|
|
|
|
|
|
public:
|
2024-01-18 15:41:43 +08:00
|
|
|
|
QString channelName;
|
|
|
|
|
|
|
|
|
|
LinkObject* videoInput;
|
|
|
|
|
LinkObject* videoEncoder;
|
|
|
|
|
QVariantMap videoEncoderParams;
|
|
|
|
|
LinkObject* videoOutput;
|
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
static LinkObject* lineIn; // 外部音频输入
|
|
|
|
|
static LinkObject* resample; // 重采样
|
|
|
|
|
static LinkObject* lineOut; // 外部音频输出
|
|
|
|
|
LinkObject* gain; // 音量增益
|
|
|
|
|
LinkObject* volume; // 音量
|
|
|
|
|
int maxGian = 30;
|
|
|
|
|
int minGain = -30;
|
|
|
|
|
int curGain = 0;
|
|
|
|
|
|
|
|
|
|
LinkObject* audioInput; // 通道音频输入
|
|
|
|
|
LinkObject* audioOutput; // 通道音频输入
|
|
|
|
|
LinkObject* audioEncoder; // 音频编码器
|
|
|
|
|
QVariantMap audioEncoderParams; // 编码参数
|
2024-01-18 15:41:43 +08:00
|
|
|
|
|
|
|
|
|
LinkObject* record;
|
2024-05-11 15:40:07 +08:00
|
|
|
|
int duration = 1 * 60 * 1000; // 单个视频时长
|
2024-01-18 15:41:43 +08:00
|
|
|
|
bool isRecord = false;
|
2024-08-12 11:26:42 +08:00
|
|
|
|
QString startTime; // 本次录制文件的开始时间
|
|
|
|
|
QString currentTime; // 当前录制文件的开始时间
|
|
|
|
|
int segmentId = 0;
|
|
|
|
|
LinkObject* overlay; // 水印,提示是否在录制视频
|
|
|
|
|
QVariantMap recordOverlay; // 录制状态下的水印参数
|
|
|
|
|
QVariantMap norecordOverlay; // 非录制状态下的水印参数
|
2024-01-18 15:41:43 +08:00
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
int playbackDuration = 0; // 当前播放视频的时长,单位ms
|
|
|
|
|
LinkObject* inputFile;
|
2024-03-04 16:22:40 +08:00
|
|
|
|
LinkObject* videoDecoder;
|
|
|
|
|
LinkObject* audioDecoder;
|
2024-08-12 11:26:42 +08:00
|
|
|
|
LinkObject* image;
|
2024-03-04 16:22:40 +08:00
|
|
|
|
PlaybackState state = Stop;
|
2024-01-18 15:41:43 +08:00
|
|
|
|
|
|
|
|
|
static LinkObject* rtspServer;
|
|
|
|
|
LinkObject* rtsp;
|
|
|
|
|
QString pushCode;
|
|
|
|
|
|
2024-08-12 11:26:42 +08:00
|
|
|
|
private slots:
|
|
|
|
|
void onNewEvent(QString msg, QVariant data);
|
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-08-12 11:26:42 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void loadOverlayConfig();
|
2024-01-18 15:41:43 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // CHANNEL_H
|