forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYUVReader.h
More file actions
executable file
·40 lines (26 loc) · 747 Bytes
/
YUVReader.h
File metadata and controls
executable file
·40 lines (26 loc) · 747 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
#pragma once
#include <iostream>
#include <fstream>
#include <thread>
#include <functional>
#include <direct.h>
typedef std::function<void(int, int, unsigned char*, int)> IYUVCallback;
class YUVReader
{
public:
const char* FILE_PATH = "sample.yuv";
const static int VIDEO_WIDTH = 320;
const static int VIDEO_HEIGHT = 180;
const static int VIDEO_FRAME_SIZE = VIDEO_WIDTH * VIDEO_HEIGHT * 3 / 2;
const static int VIDEO_FRAME_RATE = 15;
const static int VIDEO_FRAME_INTERVAL_MS = 1000 / VIDEO_FRAME_RATE;
YUVReader();
void start(IYUVCallback callback);
void stop();
private:
IYUVCallback callback = nullptr;
std::thread* thread = nullptr;
bool isReading = false;
unsigned char buffer[VIDEO_FRAME_SIZE]{0};
void run();
};