Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: talk/media/webrtc/fakewebrtcvideocapturemodule.h

Issue 1587193006: Move talk/media to webrtc/media (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased to b647aca12a884a13c1728118586245399b55fa3d (#11493) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/fakewebrtcvcmfactory.h ('k') | talk/media/webrtc/fakewebrtcvideoengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * libjingle
3 * Copyright 2004 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef TALK_SESSION_PHONE_FAKEWEBRTCVIDEOCAPTUREMODULE_H_
29 #define TALK_SESSION_PHONE_FAKEWEBRTCVIDEOCAPTUREMODULE_H_
30
31 #include <vector>
32
33 #include "talk/media/base/testutils.h"
34 #include "talk/media/webrtc/fakewebrtcdeviceinfo.h"
35 #include "talk/media/webrtc/webrtcvideocapturer.h"
36
37 class FakeWebRtcVcmFactory;
38
39 // Fake class for mocking out webrtc::VideoCaptureModule.
40 class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
41 public:
42 FakeWebRtcVideoCaptureModule(FakeWebRtcVcmFactory* factory, int32_t id)
43 : factory_(factory),
44 id_(id),
45 callback_(NULL),
46 running_(false),
47 delay_(0) {
48 }
49 int64_t TimeUntilNextProcess() override { return 0; }
50 int32_t Process() override { return 0; }
51 void RegisterCaptureDataCallback(
52 webrtc::VideoCaptureDataCallback& callback) override {
53 callback_ = &callback;
54 }
55 void DeRegisterCaptureDataCallback() override { callback_ = NULL; }
56 void RegisterCaptureCallback(
57 webrtc::VideoCaptureFeedBack& callback) override {
58 // Not implemented.
59 }
60 void DeRegisterCaptureCallback() override {
61 // Not implemented.
62 }
63 void SetCaptureDelay(int32_t delay) override { delay_ = delay; }
64 int32_t CaptureDelay() override { return delay_; }
65 void EnableFrameRateCallback(const bool enable) override {
66 // not implemented
67 }
68 void EnableNoPictureAlarm(const bool enable) override {
69 // not implemented
70 }
71 int32_t StartCapture(const webrtc::VideoCaptureCapability& cap) override {
72 if (running_) return -1;
73 cap_ = cap;
74 running_ = true;
75 return 0;
76 }
77 int32_t StopCapture() override {
78 running_ = false;
79 return 0;
80 }
81 const char* CurrentDeviceName() const override {
82 return NULL; // not implemented
83 }
84 bool CaptureStarted() override { return running_; }
85 int32_t CaptureSettings(webrtc::VideoCaptureCapability& settings) override {
86 if (!running_) return -1;
87 settings = cap_;
88 return 0;
89 }
90
91 int32_t SetCaptureRotation(webrtc::VideoRotation rotation) override {
92 return -1; // not implemented
93 }
94 bool SetApplyRotation(bool enable) override {
95 return false; // not implemented
96 }
97 bool GetApplyRotation() override {
98 return true; // Rotation compensation is turned on.
99 }
100 VideoCaptureEncodeInterface* GetEncodeInterface(
101 const webrtc::VideoCodec& codec) override {
102 return NULL; // not implemented
103 }
104 int32_t AddRef() const override { return 0; }
105 int32_t Release() const override {
106 delete this;
107 return 0;
108 }
109
110 bool SendFrame(int w, int h) {
111 if (!running_) return false;
112 webrtc::VideoFrame sample;
113 // Setting stride based on width.
114 if (sample.CreateEmptyFrame(w, h, w, (w + 1) / 2, (w + 1) / 2) < 0) {
115 return false;
116 }
117 if (callback_) {
118 callback_->OnIncomingCapturedFrame(id_, sample);
119 }
120 return true;
121 }
122
123 const webrtc::VideoCaptureCapability& cap() const {
124 return cap_;
125 }
126
127 private:
128 // Ref-counted, use Release() instead.
129 ~FakeWebRtcVideoCaptureModule();
130
131 FakeWebRtcVcmFactory* factory_;
132 int id_;
133 webrtc::VideoCaptureDataCallback* callback_;
134 bool running_;
135 webrtc::VideoCaptureCapability cap_;
136 int delay_;
137 };
138
139 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVIDEOCAPTUREMODULE_H_
OLDNEW
« no previous file with comments | « talk/media/webrtc/fakewebrtcvcmfactory.h ('k') | talk/media/webrtc/fakewebrtcvideoengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698