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

Side by Side Diff: content/renderer/media/mock_media_stream_dependency_factory.h

Issue 129923002: Implements MediaStreamVideoSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implements MediaStreamVideoSource. Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 6 #define CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "content/renderer/media/media_stream_dependency_factory.h" 12 #include "content/renderer/media/media_stream_dependency_factory.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" 13 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
14 #include "third_party/libjingle/source/talk/media/base/videorenderer.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 class WebAudioCapturerSource; 18 class WebAudioCapturerSource;
18 19
20 class MockVideoRenderer : public cricket::VideoRenderer {
21 public:
22 MockVideoRenderer();
23 virtual ~MockVideoRenderer();
24 virtual bool SetSize(int width, int height, int reserved) OVERRIDE;
25 virtual bool RenderFrame(const cricket::VideoFrame* frame) OVERRIDE;
26
27 int width() const { return width_; }
28 int height() const { return height_; }
29 int num() const { return num_; }
30
31 private:
32 int width_;
33 int height_;
34 int num_;
35 };
36
19 class MockVideoSource : public webrtc::VideoSourceInterface { 37 class MockVideoSource : public webrtc::VideoSourceInterface {
20 public: 38 public:
21 MockVideoSource(); 39 MockVideoSource();
22 40
23 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 41 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
24 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 42 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
25 virtual MediaSourceInterface::SourceState state() const OVERRIDE; 43 virtual MediaSourceInterface::SourceState state() const OVERRIDE;
26 virtual cricket::VideoCapturer* GetVideoCapturer() OVERRIDE; 44 virtual cricket::VideoCapturer* GetVideoCapturer() OVERRIDE;
27 virtual void AddSink(cricket::VideoRenderer* output) OVERRIDE; 45 virtual void AddSink(cricket::VideoRenderer* output) OVERRIDE;
28 virtual void RemoveSink(cricket::VideoRenderer* output) OVERRIDE; 46 virtual void RemoveSink(cricket::VideoRenderer* output) OVERRIDE;
29 virtual cricket::VideoRenderer* FrameInput() OVERRIDE; 47 virtual cricket::VideoRenderer* FrameInput() OVERRIDE;
30 virtual const cricket::VideoOptions* options() const OVERRIDE; 48 virtual const cricket::VideoOptions* options() const OVERRIDE;
31 49
32 // Changes the state of the source to live and notifies the observer. 50 // Changes the state of the source to live and notifies the observer.
33 void SetLive(); 51 void SetLive();
34 // Changes the state of the source to ended and notifies the observer. 52 // Changes the state of the source to ended and notifies the observer.
35 void SetEnded(); 53 void SetEnded();
36 // Set the video capturer. 54 // Set the video capturer.
37 void SetVideoCapturer(cricket::VideoCapturer* capturer); 55 void SetVideoCapturer(cricket::VideoCapturer* capturer);
38 56
57 // Test helpers.
58 int GetLastFrameWidth() const { return renderer_.width(); }
59 int GetLastFrameHeight() const { return renderer_.height(); }
60 int GetFrameNum() const { return renderer_.num(); }
61
39 protected: 62 protected:
40 virtual ~MockVideoSource(); 63 virtual ~MockVideoSource();
41 64
42 private: 65 private:
43 void FireOnChanged(); 66 void FireOnChanged();
44 67
45 std::vector<webrtc::ObserverInterface*> observers_; 68 std::vector<webrtc::ObserverInterface*> observers_;
46 MediaSourceInterface::SourceState state_; 69 MediaSourceInterface::SourceState state_;
47 scoped_ptr<cricket::VideoCapturer> capturer_; 70 scoped_ptr<cricket::VideoCapturer> capturer_;
71 MockVideoRenderer renderer_;
48 }; 72 };
49 73
50 class MockAudioSource : public webrtc::AudioSourceInterface { 74 class MockAudioSource : public webrtc::AudioSourceInterface {
51 public: 75 public:
52 explicit MockAudioSource( 76 explicit MockAudioSource(
53 const webrtc::MediaConstraintsInterface* constraints); 77 const webrtc::MediaConstraintsInterface* constraints);
54 78
55 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 79 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
56 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 80 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
57 virtual MediaSourceInterface::SourceState state() const OVERRIDE; 81 virtual MediaSourceInterface::SourceState state() const OVERRIDE;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 blink::WebFrame* frame, 145 blink::WebFrame* frame,
122 webrtc::PeerConnectionObserver* observer) OVERRIDE; 146 webrtc::PeerConnectionObserver* observer) OVERRIDE;
123 virtual scoped_refptr<webrtc::AudioSourceInterface> 147 virtual scoped_refptr<webrtc::AudioSourceInterface>
124 CreateLocalAudioSource( 148 CreateLocalAudioSource(
125 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE; 149 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
126 virtual scoped_refptr<webrtc::VideoSourceInterface> 150 virtual scoped_refptr<webrtc::VideoSourceInterface>
127 CreateLocalVideoSource( 151 CreateLocalVideoSource(
128 int video_session_id, 152 int video_session_id,
129 bool is_screencast, 153 bool is_screencast,
130 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE; 154 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
155 virtual scoped_refptr<webrtc::VideoSourceInterface>
156 CreateVideoSource(
157 cricket::VideoCapturer* capturer,
158 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
131 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource( 159 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource(
132 blink::WebMediaStreamSource* source, 160 blink::WebMediaStreamSource* source,
133 const RTCMediaConstraints& constraints) OVERRIDE; 161 const RTCMediaConstraints& constraints) OVERRIDE;
134 virtual scoped_refptr<webrtc::MediaStreamInterface> 162 virtual scoped_refptr<webrtc::MediaStreamInterface>
135 CreateLocalMediaStream(const std::string& label) OVERRIDE; 163 CreateLocalMediaStream(const std::string& label) OVERRIDE;
136 virtual scoped_refptr<webrtc::VideoTrackInterface> 164 virtual scoped_refptr<webrtc::VideoTrackInterface>
137 CreateLocalVideoTrack(const std::string& id, 165 CreateLocalVideoTrack(const std::string& id,
138 webrtc::VideoSourceInterface* source) OVERRIDE; 166 webrtc::VideoSourceInterface* source) OVERRIDE;
139 virtual scoped_refptr<webrtc::VideoTrackInterface> 167 virtual scoped_refptr<webrtc::VideoTrackInterface>
140 CreateLocalVideoTrack(const std::string& id, 168 CreateLocalVideoTrack(const std::string& id,
(...skipping 26 matching lines...) Expand all
167 bool mock_pc_factory_created_; 195 bool mock_pc_factory_created_;
168 scoped_refptr <MockAudioSource> last_audio_source_; 196 scoped_refptr <MockAudioSource> last_audio_source_;
169 scoped_refptr <MockVideoSource> last_video_source_; 197 scoped_refptr <MockVideoSource> last_video_source_;
170 198
171 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory); 199 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory);
172 }; 200 };
173 201
174 } // namespace content 202 } // namespace content
175 203
176 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 204 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698