-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEncodingQueue.h
More file actions
42 lines (33 loc) · 849 Bytes
/
EncodingQueue.h
File metadata and controls
42 lines (33 loc) · 849 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
#pragma once
#include <cstddef>
#include <condition_variable>
#include <deque>
#include <functional>
#include <mutex>
#include <thread>
#include <vector>
#include "LogBuffer.h"
#include "ScreenCapture.h"
namespace vr_image_client
{
class EncodingQueue
{
public:
EncodingQueue(std::size_t max_size, std::size_t worker_count);
~EncodingQueue();
void Start();
void Stop();
void Enqueue(RawFrame frame, LogBuffer &logs);
void SetEncoder(std::function<void(RawFrame &&)> encoder);
private:
void WorkerLoop();
std::mutex mutex_;
std::condition_variable cond_;
std::deque<RawFrame> queue_;
std::function<void(RawFrame &&)> encoder_;
std::vector<std::thread> workers_;
bool stop_requested_{false};
std::size_t max_size_{0};
std::size_t worker_count_{1};
};
} // namespace vr_image_client