Revert of Rewrite frame generator capturer to use TaskQueue instead of EventTimeWrapper (patchset #4 id:60001 of https://codereview.webrtc.org/2740723002/ )
Reason for revert:
Less precise FrameGeneratorCapturer broke CallPerfTest.ReceivesCpuOveruseAndUnderuse on Android
Original issue's description:
> Rewrite frame generator capturer to use TaskQueue instead of EventTimeWrapper
>
> BUG=webrtc:7301
>
> Review-Url: https://codereview.webrtc.org/2740723002
> Cr-Commit-Position: refs/heads/master@{#17161}
> Committed: 7c5503a8b3
TBR=kjellander@webrtc.org,sprang@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7301
Review-Url: https://codereview.webrtc.org/2739393002
Cr-Commit-Position: refs/heads/master@{#17163}
This commit is contained in:
parent
8602c429be
commit
c37d2b96b8
@ -10,13 +10,10 @@
|
||||
|
||||
#include "webrtc/test/frame_generator_capturer.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/base/task_queue.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/frame_generator.h"
|
||||
#include "webrtc/video_send_stream.h"
|
||||
@ -24,31 +21,6 @@
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
class FrameGeneratorCapturer::InsertFrameTask : public rtc::QueuedTask {
|
||||
public:
|
||||
// Repeats in |repeat_interval_ms|. One-time if |repeat_interval_ms| == 0.
|
||||
InsertFrameTask(
|
||||
webrtc::test::FrameGeneratorCapturer* frame_generator_capturer,
|
||||
uint32_t repeat_interval_ms)
|
||||
: frame_generator_capturer_(frame_generator_capturer),
|
||||
repeat_interval_ms_(repeat_interval_ms) {}
|
||||
|
||||
private:
|
||||
bool Run() override {
|
||||
if (repeat_interval_ms_ > 0) {
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(
|
||||
std::unique_ptr<rtc::QueuedTask>(this),
|
||||
repeat_interval_ms_);
|
||||
}
|
||||
frame_generator_capturer_->InsertFrame();
|
||||
// Task should be deleted only if it's not repeating.
|
||||
return repeat_interval_ms_ == 0;
|
||||
}
|
||||
|
||||
webrtc::test::FrameGeneratorCapturer* const frame_generator_capturer_;
|
||||
const uint32_t repeat_interval_ms_;
|
||||
};
|
||||
|
||||
FrameGeneratorCapturer* FrameGeneratorCapturer::Create(int width,
|
||||
int height,
|
||||
int target_fps,
|
||||
@ -89,7 +61,8 @@ FrameGeneratorCapturer::FrameGeneratorCapturer(
|
||||
sending_(false),
|
||||
sink_(nullptr),
|
||||
sink_wants_observer_(nullptr),
|
||||
task_queue_("FrameGeneratorQueue", rtc::TaskQueue::Priority::HIGH),
|
||||
tick_(EventTimerWrapper::Create()),
|
||||
thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"),
|
||||
frame_generator_(std::move(frame_generator)),
|
||||
target_fps_(target_fps),
|
||||
first_frame_capture_time_(-1) {
|
||||
@ -99,6 +72,8 @@ FrameGeneratorCapturer::FrameGeneratorCapturer(
|
||||
|
||||
FrameGeneratorCapturer::~FrameGeneratorCapturer() {
|
||||
Stop();
|
||||
|
||||
thread_.Stop();
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) {
|
||||
@ -112,11 +87,15 @@ bool FrameGeneratorCapturer::Init() {
|
||||
if (frame_generator_.get() == NULL)
|
||||
return false;
|
||||
|
||||
task_queue_.PostDelayedTask(
|
||||
std::unique_ptr<rtc::QueuedTask>(
|
||||
new InsertFrameTask(this, 1000 / target_fps_)),
|
||||
1000 / target_fps_);
|
||||
if (!tick_->StartTimer(true, 1000 / target_fps_))
|
||||
return false;
|
||||
thread_.Start();
|
||||
thread_.SetPriority(rtc::kHighPriority);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FrameGeneratorCapturer::Run(void* obj) {
|
||||
static_cast<FrameGeneratorCapturer*>(obj)->InsertFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -134,6 +113,7 @@ void FrameGeneratorCapturer::InsertFrame() {
|
||||
sink_->OnFrame(*frame);
|
||||
}
|
||||
}
|
||||
tick_->Wait(WEBRTC_EVENT_INFINITE);
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::Start() {
|
||||
@ -175,11 +155,7 @@ void FrameGeneratorCapturer::RemoveSink(
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::ForceFrame() {
|
||||
// One-time non-repeating task,
|
||||
// therefore repeat_interval_ms is 0 in InsertFrameTask()
|
||||
task_queue_.PostTask(
|
||||
std::unique_ptr<rtc::QueuedTask>(new InsertFrameTask(this, 0)));
|
||||
tick_->Set();
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
} // test
|
||||
} // webrtc
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "webrtc/api/video/video_frame.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/task_queue.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/test/video_capturer.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -74,8 +74,6 @@ class FrameGeneratorCapturer : public VideoCapturer {
|
||||
bool Init();
|
||||
|
||||
private:
|
||||
class InsertFrameTask;
|
||||
|
||||
void InsertFrame();
|
||||
static bool Run(void* obj);
|
||||
|
||||
@ -84,8 +82,9 @@ class FrameGeneratorCapturer : public VideoCapturer {
|
||||
rtc::VideoSinkInterface<VideoFrame>* sink_ GUARDED_BY(&lock_);
|
||||
SinkWantsObserver* sink_wants_observer_ GUARDED_BY(&lock_);
|
||||
|
||||
rtc::TaskQueue task_queue_;
|
||||
std::unique_ptr<EventTimerWrapper> tick_;
|
||||
rtc::CriticalSection lock_;
|
||||
rtc::PlatformThread thread_;
|
||||
std::unique_ptr<FrameGenerator> frame_generator_;
|
||||
|
||||
int target_fps_;
|
||||
@ -93,7 +92,7 @@ class FrameGeneratorCapturer : public VideoCapturer {
|
||||
|
||||
int64_t first_frame_capture_time_;
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
} // test
|
||||
} // webrtc
|
||||
|
||||
#endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user