-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstream_worker.hpp
More file actions
46 lines (35 loc) · 898 Bytes
/
stream_worker.hpp
File metadata and controls
46 lines (35 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by pengx on 2026/2/10.
//
#ifndef GB28181_STREAM_WORKER_HPP
#define GB28181_STREAM_WORKER_HPP
#pragma once
#include <QMutex>
#include <QTimer>
#include <vector>
struct VideoFrame {
std::vector<uint8_t> data;
uint32_t pts;
};
class StreamWorker : public QObject {
Q_OBJECT
public:
explicit StreamWorker(size_t bufferSize = 30, QObject* parent = nullptr);
~StreamWorker() override;
public slots:
// 生产者:快速写入
void frameReceived(const std::vector<uint8_t>& h264Data, uint32_t pts);
// 消费者:处理帧
void handleFrame();
private:
struct FrameBuffer {
std::vector<VideoFrame> frames;
size_t writeIndex = 0;
size_t readIndex = 0;
size_t count = 0;
size_t capacity = 0;
} _ringBuffer;
QMutex _mutex;
bool _isProcessing = false;
};
#endif //GB28181_STREAM_WORKER_HPP