I readded virtual bool Pause(bool paused) for now with a dummy implementation since Chrome remoting override this method. Original cl description: Removed unused cricket::VideoCapturer methods: void UpdateAspectRatio(int ratio_w, int ratio_h); void ClearAspectRatio(); bool Pause(bool paused); Restart(const VideoFormat& capture_format); MuteToBlackThenPause(bool muted); IsMuted() const set_square_pixel_aspect_ratio bool square_pixel_aspect_ratio() This cl also remove the use of messages and posting of state change. Further more - a thread checker is added to make sure methods are called on only one thread. Construction can happen on a separate thred. It does not add restrictions on what thread frames are delivered on though. There is more features in VideoCapturer::Onframe related to screen share in ARGB that probably can be cleaned up in a follow up cl. BUG=webrtc:5426 TBR=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1744153002 . Cr-Commit-Position: refs/heads/master@{#11809}
74 lines
2.5 KiB
C++
74 lines
2.5 KiB
C++
/*
|
|
* Copyright 2012 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.
|
|
*/
|
|
|
|
// FakePeriodicVideoCapturer implements a fake cricket::VideoCapturer that
|
|
// creates video frames periodically after it has been started.
|
|
|
|
#ifndef WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_
|
|
#define WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_
|
|
|
|
#include <vector>
|
|
|
|
#include "webrtc/base/thread.h"
|
|
#include "webrtc/media/base/fakevideocapturer.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class FakePeriodicVideoCapturer : public cricket::FakeVideoCapturer,
|
|
public rtc::MessageHandler {
|
|
public:
|
|
FakePeriodicVideoCapturer() {
|
|
std::vector<cricket::VideoFormat> formats;
|
|
formats.push_back(cricket::VideoFormat(1280, 720,
|
|
cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420));
|
|
formats.push_back(cricket::VideoFormat(640, 480,
|
|
cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420));
|
|
formats.push_back(cricket::VideoFormat(640, 360,
|
|
cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420));
|
|
formats.push_back(cricket::VideoFormat(320, 240,
|
|
cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420));
|
|
formats.push_back(cricket::VideoFormat(160, 120,
|
|
cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420));
|
|
ResetSupportedFormats(formats);
|
|
}
|
|
|
|
virtual cricket::CaptureState Start(const cricket::VideoFormat& format) {
|
|
cricket::CaptureState state = FakeVideoCapturer::Start(format);
|
|
if (state != cricket::CS_FAILED) {
|
|
rtc::Thread::Current()->Post(this, MSG_CREATEFRAME);
|
|
}
|
|
return state;
|
|
}
|
|
virtual void Stop() {
|
|
rtc::Thread::Current()->Clear(this);
|
|
}
|
|
// Inherited from MesageHandler.
|
|
virtual void OnMessage(rtc::Message* msg) {
|
|
if (msg->message_id == MSG_CREATEFRAME) {
|
|
if (IsRunning()) {
|
|
CaptureFrame();
|
|
rtc::Thread::Current()->PostDelayed(static_cast<int>(
|
|
GetCaptureFormat()->interval / rtc::kNumNanosecsPerMillisec),
|
|
this, MSG_CREATEFRAME);
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
enum {
|
|
// Offset 0xFF to make sure this don't collide with base class messages.
|
|
MSG_CREATEFRAME = 0xFF
|
|
};
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_
|