申明queue和工廠成員
static std::unique_ptr<rtc::TaskQueue> task_queue1_;
static std::unique_ptr<rtc::TaskQueue> task_queue2_;
static webrtc::TaskQueueFactory * task_queue_factory_;
初始化工廠和隊(duì)列
//get default queue factory
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_default_ = webrtc::CreateDefaultTaskQueueFactory();
task_queue_factory_ = task_queue_factory_default_.get();
//set up task queue
RTC_CHECK(task_queue_factory_);
if (!task_queue1_) {
RTC_LOG(LS_INFO) << "Webrtc CreateTaskQueue";
task_queue1_ =
std::make_unique<rtc::TaskQueue>(task_queue_factory_->CreateTaskQueue(
"convert1_thread", webrtc::TaskQueueFactory::Priority::HIGH));
}
posttask
if (task_queue1_ && task_queue2_) {
RTC_LOG(LS_INFO) << "Webrtcoom task_queue1_ and task_queue2_ !=null";
((frameCount%2 ==0) ? task_queue1_:task_queue2_)->PostDelayedTask(webrtc::ToQueuedTask([outBuffer]() {
NativeScreenShare::onFrameCallback(outBuffer, outBuffer->getWidth(),
outBuffer->getHeight(), outBuffer->getStride());
}), 0);
析構(gòu)的時(shí)候重置隊(duì)列
task_queue1_.reset();