Index: webrtc/test/frame_generator_capturer.cc |
diff --git a/webrtc/test/frame_generator_capturer.cc b/webrtc/test/frame_generator_capturer.cc |
index 95ac624c42188e567f6b3fd863ad1b9bb54379db..7e929095f048a7876569affb59a7fa6fea39e5ab 100644 |
--- a/webrtc/test/frame_generator_capturer.cc |
+++ b/webrtc/test/frame_generator_capturer.cc |
@@ -21,14 +21,12 @@ |
namespace webrtc { |
namespace test { |
-FrameGeneratorCapturer* FrameGeneratorCapturer::Create(VideoCaptureInput* input, |
- size_t width, |
+FrameGeneratorCapturer* FrameGeneratorCapturer::Create(size_t width, |
size_t height, |
int target_fps, |
Clock* clock) { |
FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( |
- clock, input, FrameGenerator::CreateChromaGenerator(width, height), |
- target_fps); |
+ clock, FrameGenerator::CreateChromaGenerator(width, height), target_fps); |
if (!capturer->Init()) { |
delete capturer; |
return NULL; |
@@ -38,16 +36,14 @@ FrameGeneratorCapturer* FrameGeneratorCapturer::Create(VideoCaptureInput* input, |
} |
FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile( |
- VideoCaptureInput* input, |
const std::string& file_name, |
size_t width, |
size_t height, |
int target_fps, |
Clock* clock) { |
FrameGeneratorCapturer* capturer = new FrameGeneratorCapturer( |
- clock, input, |
- FrameGenerator::CreateFromYuvFile(std::vector<std::string>(1, file_name), |
- width, height, 1), |
+ clock, FrameGenerator::CreateFromYuvFile( |
+ std::vector<std::string>(1, file_name), width, height, 1), |
target_fps); |
if (!capturer->Init()) { |
delete capturer; |
@@ -58,20 +54,18 @@ FrameGeneratorCapturer* FrameGeneratorCapturer::CreateFromYuvFile( |
} |
FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, |
- VideoCaptureInput* input, |
FrameGenerator* frame_generator, |
int target_fps) |
- : VideoCapturer(input), |
- clock_(clock), |
+ : clock_(clock), |
sending_(false), |
+ sink_(nullptr), |
tick_(EventTimerWrapper::Create()), |
thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"), |
frame_generator_(frame_generator), |
target_fps_(target_fps), |
first_frame_capture_time_(-1) { |
- assert(input != NULL); |
- assert(frame_generator != NULL); |
- assert(target_fps > 0); |
+ RTC_DCHECK(frame_generator); |
+ RTC_DCHECK_GT(target_fps, 0); |
} |
FrameGeneratorCapturer::~FrameGeneratorCapturer() { |
@@ -113,7 +107,8 @@ void FrameGeneratorCapturer::InsertFrame() { |
if (first_frame_capture_time_ == -1) { |
first_frame_capture_time_ = frame->ntp_time_ms(); |
} |
- input_->IncomingCapturedFrame(*frame); |
+ if (sink_) |
+ sink_->OnFrame(*frame); |
} |
} |
tick_->Wait(WEBRTC_EVENT_INFINITE); |
@@ -129,6 +124,21 @@ void FrameGeneratorCapturer::Stop() { |
sending_ = false; |
} |
+void FrameGeneratorCapturer::AddOrUpdateSink( |
+ rtc::VideoSinkInterface<VideoFrame>* sink, |
+ const rtc::VideoSinkWants& wants) { |
+ rtc::CritScope cs(&lock_); |
+ RTC_CHECK(!sink_); |
+ sink_ = sink; |
+} |
+ |
+void FrameGeneratorCapturer::RemoveSink( |
+ rtc::VideoSinkInterface<VideoFrame>* sink) { |
+ rtc::CritScope cs(&lock_); |
+ RTC_CHECK(sink_ == sink); |
+ sink_ = nullptr; |
+} |
+ |
void FrameGeneratorCapturer::ForceFrame() { |
tick_->Set(); |
} |