2013-05-29 13:41:03 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2015-12-09 12:13:30 +01:00
|
|
|
#ifndef WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
|
|
|
|
|
#define WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
|
2013-05-29 13:41:03 +00:00
|
|
|
|
2016-05-01 14:53:46 -07:00
|
|
|
#include <memory>
|
2015-02-18 12:46:06 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2017-01-10 07:44:26 -08:00
|
|
|
#include "webrtc/api/video/video_frame.h"
|
2015-05-01 13:00:41 +02:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2015-11-26 17:45:47 +01:00
|
|
|
#include "webrtc/base/platform_thread.h"
|
2013-10-28 16:32:01 +00:00
|
|
|
#include "webrtc/test/video_capturer.h"
|
2013-05-29 13:41:03 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class CriticalSectionWrapper;
|
2015-04-08 11:24:19 +02:00
|
|
|
class EventTimerWrapper;
|
2013-05-29 13:41:03 +00:00
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
class FrameGenerator;
|
|
|
|
|
|
|
|
|
|
class FrameGeneratorCapturer : public VideoCapturer {
|
|
|
|
|
public:
|
2016-11-01 11:45:46 -07:00
|
|
|
class SinkWantsObserver {
|
|
|
|
|
public:
|
|
|
|
|
// OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
|
|
|
|
|
// is called.
|
|
|
|
|
virtual void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
|
|
|
|
|
const rtc::VideoSinkWants& wants) = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~SinkWantsObserver() {}
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-16 07:53:41 -07:00
|
|
|
static FrameGeneratorCapturer* Create(size_t width,
|
2013-09-19 12:14:03 +00:00
|
|
|
size_t height,
|
|
|
|
|
int target_fps,
|
|
|
|
|
Clock* clock);
|
|
|
|
|
|
2016-09-16 07:53:41 -07:00
|
|
|
static FrameGeneratorCapturer* CreateFromYuvFile(const std::string& file_name,
|
2013-09-19 12:14:03 +00:00
|
|
|
size_t width,
|
|
|
|
|
size_t height,
|
|
|
|
|
int target_fps,
|
|
|
|
|
Clock* clock);
|
2013-05-29 13:41:03 +00:00
|
|
|
virtual ~FrameGeneratorCapturer();
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void Start() override;
|
|
|
|
|
void Stop() override;
|
2016-10-02 23:45:26 -07:00
|
|
|
void ChangeResolution(size_t width, size_t height);
|
2016-09-16 07:53:41 -07:00
|
|
|
|
2016-11-01 11:45:46 -07:00
|
|
|
void SetSinkWantsObserver(SinkWantsObserver* observer);
|
|
|
|
|
|
2016-09-16 07:53:41 -07:00
|
|
|
void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
|
|
|
|
|
const rtc::VideoSinkWants& wants) override;
|
|
|
|
|
void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
|
|
|
|
|
|
2015-08-03 04:38:41 -07:00
|
|
|
void ForceFrame();
|
2016-04-19 15:01:23 +02:00
|
|
|
void SetFakeRotation(VideoRotation rotation);
|
2013-05-29 13:41:03 +00:00
|
|
|
|
2014-04-24 22:10:24 +00:00
|
|
|
int64_t first_frame_capture_time() const { return first_frame_capture_time_; }
|
|
|
|
|
|
2013-09-19 12:14:03 +00:00
|
|
|
FrameGeneratorCapturer(Clock* clock,
|
2013-05-29 13:41:03 +00:00
|
|
|
FrameGenerator* frame_generator,
|
2013-07-09 08:02:33 +00:00
|
|
|
int target_fps);
|
2013-05-29 13:41:03 +00:00
|
|
|
bool Init();
|
2015-02-18 12:46:06 +00:00
|
|
|
|
|
|
|
|
private:
|
2013-05-29 13:41:03 +00:00
|
|
|
void InsertFrame();
|
|
|
|
|
static bool Run(void* obj);
|
|
|
|
|
|
2014-04-28 13:00:21 +00:00
|
|
|
Clock* const clock_;
|
2013-05-29 13:41:03 +00:00
|
|
|
bool sending_;
|
2016-09-16 07:53:41 -07:00
|
|
|
rtc::VideoSinkInterface<VideoFrame>* sink_ GUARDED_BY(&lock_);
|
2016-11-01 11:45:46 -07:00
|
|
|
SinkWantsObserver* sink_wants_observer_ GUARDED_BY(&lock_);
|
2013-05-29 13:41:03 +00:00
|
|
|
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<EventTimerWrapper> tick_;
|
2015-05-01 13:00:41 +02:00
|
|
|
rtc::CriticalSection lock_;
|
2015-11-26 17:45:47 +01:00
|
|
|
rtc::PlatformThread thread_;
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<FrameGenerator> frame_generator_;
|
2013-05-29 13:41:03 +00:00
|
|
|
|
|
|
|
|
int target_fps_;
|
2016-04-19 15:01:23 +02:00
|
|
|
VideoRotation fake_rotation_ = kVideoRotation_0;
|
2014-04-24 22:10:24 +00:00
|
|
|
|
|
|
|
|
int64_t first_frame_capture_time_;
|
2013-05-29 13:41:03 +00:00
|
|
|
};
|
|
|
|
|
} // test
|
|
|
|
|
} // webrtc
|
|
|
|
|
|
2015-12-09 12:13:30 +01:00
|
|
|
#endif // WEBRTC_TEST_FRAME_GENERATOR_CAPTURER_H_
|