2 // Copyright 2004 Google Inc.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
7 // 1. Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright notice,
10 // this list of conditions and the following disclaimer in the documentation
11 // and/or other materials provided with the distribution.
12 // 3. The name of the author may not be used to endorse or promote products
13 // derived from this software without specific prior written permission.
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef TALK_SESSION_PHONE_FAKEWEBRTCVIDEOCAPTUREMODULE_H_
27 #define TALK_SESSION_PHONE_FAKEWEBRTCVIDEOCAPTUREMODULE_H_
31 #include "talk/media/base/testutils.h"
32 #include "talk/media/webrtc/fakewebrtcdeviceinfo.h"
33 #include "talk/media/webrtc/webrtcvideocapturer.h"
35 class FakeWebRtcVcmFactory;
37 // Fake class for mocking out webrtc::VideoCaptureModule.
38 class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
40 FakeWebRtcVideoCaptureModule(FakeWebRtcVcmFactory* factory, int32_t id)
47 virtual int32_t Version(char* version,
48 uint32_t& remaining_buffer_in_bytes,
49 uint32_t& position) const {
52 virtual int32_t TimeUntilNextProcess() {
55 virtual int32_t Process() {
58 virtual int32_t ChangeUniqueId(const int32_t id) {
62 virtual void RegisterCaptureDataCallback(
63 webrtc::VideoCaptureDataCallback& callback) {
64 callback_ = &callback;
66 virtual void DeRegisterCaptureDataCallback() { callback_ = NULL; }
67 virtual void RegisterCaptureCallback(webrtc::VideoCaptureFeedBack& callback) {
70 virtual void DeRegisterCaptureCallback() {
73 virtual void SetCaptureDelay(int32_t delay) { delay_ = delay; }
74 virtual int32_t CaptureDelay() { return delay_; }
75 virtual void EnableFrameRateCallback(const bool enable) {
78 virtual void EnableNoPictureAlarm(const bool enable) {
81 virtual int32_t StartCapture(
82 const webrtc::VideoCaptureCapability& cap) {
83 if (running_) return -1;
88 virtual int32_t StopCapture() {
92 virtual const char* CurrentDeviceName() const {
93 return NULL; // not implemented
95 virtual bool CaptureStarted() {
98 virtual int32_t CaptureSettings(
99 webrtc::VideoCaptureCapability& settings) {
100 if (!running_) return -1;
105 virtual int32_t SetCaptureRotation(
106 webrtc::VideoCaptureRotation rotation) {
107 return -1; // not implemented
109 virtual VideoCaptureEncodeInterface* GetEncodeInterface(
110 const webrtc::VideoCodec& codec) {
111 return NULL; // not implemented
113 virtual int32_t AddRef() {
116 virtual int32_t Release() {
121 bool SendFrame(int w, int h) {
122 if (!running_) return false;
123 webrtc::I420VideoFrame sample;
124 // Setting stride based on width.
125 if (sample.CreateEmptyFrame(w, h, w, (w + 1) / 2, (w + 1) / 2) < 0) {
129 callback_->OnIncomingCapturedFrame(id_, sample);
134 const webrtc::VideoCaptureCapability& cap() const {
139 // Ref-counted, use Release() instead.
140 ~FakeWebRtcVideoCaptureModule();
142 FakeWebRtcVcmFactory* factory_;
144 webrtc::VideoCaptureDataCallback* callback_;
146 webrtc::VideoCaptureCapability cap_;
150 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVIDEOCAPTUREMODULE_H_