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

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: 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 private:
28 int width_;
29 int height_;
30 int num_;
31 };
32
19 class MockVideoSource : public webrtc::VideoSourceInterface { 33 class MockVideoSource : public webrtc::VideoSourceInterface {
20 public: 34 public:
21 MockVideoSource(); 35 MockVideoSource();
22 36
23 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 37 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
24 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 38 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
25 virtual MediaSourceInterface::SourceState state() const OVERRIDE; 39 virtual MediaSourceInterface::SourceState state() const OVERRIDE;
26 virtual cricket::VideoCapturer* GetVideoCapturer() OVERRIDE; 40 virtual cricket::VideoCapturer* GetVideoCapturer() OVERRIDE;
27 virtual void AddSink(cricket::VideoRenderer* output) OVERRIDE; 41 virtual void AddSink(cricket::VideoRenderer* output) OVERRIDE;
28 virtual void RemoveSink(cricket::VideoRenderer* output) OVERRIDE; 42 virtual void RemoveSink(cricket::VideoRenderer* output) OVERRIDE;
29 virtual cricket::VideoRenderer* FrameInput() OVERRIDE; 43 virtual cricket::VideoRenderer* FrameInput() OVERRIDE;
30 virtual const cricket::VideoOptions* options() const OVERRIDE; 44 virtual const cricket::VideoOptions* options() const OVERRIDE;
31 45
32 // Changes the state of the source to live and notifies the observer. 46 // Changes the state of the source to live and notifies the observer.
33 void SetLive(); 47 void SetLive();
34 // Changes the state of the source to ended and notifies the observer. 48 // Changes the state of the source to ended and notifies the observer.
35 void SetEnded(); 49 void SetEnded();
36 // Set the video capturer. 50 // Set the video capturer.
37 void SetVideoCapturer(cricket::VideoCapturer* capturer); 51 void SetVideoCapturer(cricket::VideoCapturer* capturer);
38 52
39 protected: 53 protected:
40 virtual ~MockVideoSource(); 54 virtual ~MockVideoSource();
41 55
42 private: 56 private:
43 void FireOnChanged(); 57 void FireOnChanged();
44 58
45 std::vector<webrtc::ObserverInterface*> observers_; 59 std::vector<webrtc::ObserverInterface*> observers_;
46 MediaSourceInterface::SourceState state_; 60 MediaSourceInterface::SourceState state_;
47 scoped_ptr<cricket::VideoCapturer> capturer_; 61 scoped_ptr<cricket::VideoCapturer> capturer_;
62 MockVideoRenderer renderer_;
48 }; 63 };
49 64
50 class MockAudioSource : public webrtc::AudioSourceInterface { 65 class MockAudioSource : public webrtc::AudioSourceInterface {
51 public: 66 public:
52 explicit MockAudioSource( 67 explicit MockAudioSource(
53 const webrtc::MediaConstraintsInterface* constraints); 68 const webrtc::MediaConstraintsInterface* constraints);
54 69
55 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 70 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
56 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; 71 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
57 virtual MediaSourceInterface::SourceState state() const OVERRIDE; 72 virtual MediaSourceInterface::SourceState state() const OVERRIDE;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 blink::WebFrame* frame, 136 blink::WebFrame* frame,
122 webrtc::PeerConnectionObserver* observer) OVERRIDE; 137 webrtc::PeerConnectionObserver* observer) OVERRIDE;
123 virtual scoped_refptr<webrtc::AudioSourceInterface> 138 virtual scoped_refptr<webrtc::AudioSourceInterface>
124 CreateLocalAudioSource( 139 CreateLocalAudioSource(
125 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE; 140 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
126 virtual scoped_refptr<webrtc::VideoSourceInterface> 141 virtual scoped_refptr<webrtc::VideoSourceInterface>
127 CreateLocalVideoSource( 142 CreateLocalVideoSource(
128 int video_session_id, 143 int video_session_id,
129 bool is_screencast, 144 bool is_screencast,
130 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE; 145 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
146 virtual scoped_refptr<webrtc::VideoSourceInterface>
147 CreateVideoSource(
148 cricket::VideoCapturer* capturer,
149 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
131 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource( 150 virtual scoped_refptr<WebAudioCapturerSource> CreateWebAudioSource(
132 blink::WebMediaStreamSource* source, 151 blink::WebMediaStreamSource* source,
133 RTCMediaConstraints* constraints) OVERRIDE; 152 RTCMediaConstraints* constraints) OVERRIDE;
134 virtual scoped_refptr<webrtc::MediaStreamInterface> 153 virtual scoped_refptr<webrtc::MediaStreamInterface>
135 CreateLocalMediaStream(const std::string& label) OVERRIDE; 154 CreateLocalMediaStream(const std::string& label) OVERRIDE;
136 virtual scoped_refptr<webrtc::VideoTrackInterface> 155 virtual scoped_refptr<webrtc::VideoTrackInterface>
137 CreateLocalVideoTrack(const std::string& id, 156 CreateLocalVideoTrack(const std::string& id,
138 webrtc::VideoSourceInterface* source) OVERRIDE; 157 webrtc::VideoSourceInterface* source) OVERRIDE;
139 virtual scoped_refptr<webrtc::VideoTrackInterface> 158 virtual scoped_refptr<webrtc::VideoTrackInterface>
140 CreateLocalVideoTrack(const std::string& id, 159 CreateLocalVideoTrack(const std::string& id,
(...skipping 26 matching lines...) Expand all
167 bool mock_pc_factory_created_; 186 bool mock_pc_factory_created_;
168 scoped_refptr <MockAudioSource> last_audio_source_; 187 scoped_refptr <MockAudioSource> last_audio_source_;
169 scoped_refptr <MockVideoSource> last_video_source_; 188 scoped_refptr <MockVideoSource> last_video_source_;
170 189
171 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory); 190 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory);
172 }; 191 };
173 192
174 } // namespace content 193 } // namespace content
175 194
176 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ 195 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698