-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture_device.h
48 lines (38 loc) · 956 Bytes
/
capture_device.h
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
47
48
#ifndef CAPTURE_DEVICE_H
#define CAPTURE_DEVICE_H
#include <string>
#include <thread>
#ifdef __cplusplus
extern "C" {
#endif
#include <libavformat/avformat.h>
#ifdef __cplusplus
}
#endif
typedef int (*CaptureCB)(AVStream* input_stream, AVFrame* input_frame, int64_t timestamp);
class CaptureDevice
{
public:
CaptureDevice();
~CaptureDevice();
void SetDeviceName(const std::string& fmt_name, const std::string& device_name, bool prefix);
void SetCaptureCB(CaptureCB cb);
int Open(bool video);
void Close();
int Start(int64_t timestamp);
void Stop();
protected:
static int CaptureThreadFunc(void* args);
int ReadPackets();
protected:
std::string fmt_name_;
std::string device_name_;
bool prefix_;
AVInputFormat* input_fmt_;
AVFormatContext* fmt_ctx_;
int stream_idx_;
std::thread* capture_thread_;
int64_t start_time_;
CaptureCB capture_cb_;
};
#endif // CAPTURE_DEVICE_H