-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathVideoProcessor.cpp
More file actions
61 lines (52 loc) · 1.73 KB
/
VideoProcessor.cpp
File metadata and controls
61 lines (52 loc) · 1.73 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by DYF on 2020/7/13.
//
#include "VideoProcessor.hpp"
#include <chrono>
namespace agora {
namespace extension {
bool enableGrey = true;
bool YUVImageProcessor::initOpenGL() {
const std::lock_guard<std::mutex> lock(mutex_);
return true;
}
bool YUVImageProcessor::releaseOpenGL() {
const std::lock_guard<std::mutex> lock(mutex_);
return true;
}
int YUVImageProcessor::processFrame(agora::rtc::VideoFrameData &capturedFrame) {
if (wmEffectEnabled_) {
process(capturedFrame);
}
return 0;
}
void YUVImageProcessor::process(const agora::rtc::VideoFrameData &capturedFrame) {
if(!enableGrey){
return;
}
// agora::rtc::RawPixelBuffer::Format format = capturedFrame.pixels.format;
unsigned char* pic = capturedFrame.pixels.data;
int offset = capturedFrame.height * capturedFrame.width;
memset(pic + offset, 128, capturedFrame.height * capturedFrame.width / 2);
}
int YUVImageProcessor::setParameters(std::string parameter) {
const std::lock_guard<std::mutex> lock(mutex_);
if(parameter == "1"){
enableGrey = true;
}
else{
enableGrey = false;
}
return 0;
}
std::thread::id YUVImageProcessor::getThreadId() {
std::thread::id id = std::this_thread::get_id();
return id;
}
void YUVImageProcessor::dataCallback(const char* data){
if (control_) {
control_->postEvent("key", data);
}
}
}
}