OLD | NEW |
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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // Changes the state of the source to live and notifies the observer. | 29 // Changes the state of the source to live and notifies the observer. |
30 void SetLive(); | 30 void SetLive(); |
31 // Changes the state of the source to ended and notifies the observer. | 31 // Changes the state of the source to ended and notifies the observer. |
32 void SetEnded(); | 32 void SetEnded(); |
33 | 33 |
34 protected: | 34 protected: |
35 virtual ~MockVideoSource(); | 35 virtual ~MockVideoSource(); |
36 | 36 |
37 private: | 37 private: |
38 webrtc::ObserverInterface* observer_; | 38 webrtc::ObserverInterface* observer_; |
39 MediaSourceInterface::SourceState state_; | 39 MediaSourceInterface::SourceState state_; |
40 }; | 40 }; |
41 | 41 |
42 class MockAudioSource : public webrtc::AudioSourceInterface { | 42 class MockAudioSource : public webrtc::AudioSourceInterface { |
43 public: | 43 public: |
44 MockAudioSource(const webrtc::MediaConstraintsInterface* constraints); | 44 explicit MockAudioSource( |
| 45 const webrtc::MediaConstraintsInterface* constraints); |
45 | 46 |
46 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; | 47 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; |
47 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; | 48 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; |
48 virtual MediaSourceInterface::SourceState state() const OVERRIDE; | 49 virtual MediaSourceInterface::SourceState state() const OVERRIDE; |
49 | 50 |
50 // Changes the state of the source to live and notifies the observer. | 51 // Changes the state of the source to live and notifies the observer. |
51 void SetLive(); | 52 void SetLive(); |
52 // Changes the state of the source to ended and notifies the observer. | 53 // Changes the state of the source to ended and notifies the observer. |
53 void SetEnded(); | 54 void SetEnded(); |
54 | 55 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; | 89 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; |
89 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; | 90 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; |
90 virtual webrtc::VideoSourceInterface* GetSource() const OVERRIDE; | 91 virtual webrtc::VideoSourceInterface* GetSource() const OVERRIDE; |
91 | 92 |
92 protected: | 93 protected: |
93 virtual ~MockLocalVideoTrack(); | 94 virtual ~MockLocalVideoTrack(); |
94 | 95 |
95 private: | 96 private: |
96 bool enabled_; | 97 bool enabled_; |
97 std::string id_; | 98 std::string id_; |
| 99 TrackState state_; |
98 scoped_refptr<webrtc::VideoSourceInterface> source_; | 100 scoped_refptr<webrtc::VideoSourceInterface> source_; |
| 101 webrtc::ObserverInterface* observer_; |
99 }; | 102 }; |
100 | 103 |
101 class MockLocalAudioTrack : public webrtc::AudioTrackInterface { | 104 class MockLocalAudioTrack : public webrtc::AudioTrackInterface { |
102 public: | 105 public: |
103 explicit MockLocalAudioTrack(const std::string& id) | 106 explicit MockLocalAudioTrack(const std::string& id) |
104 : enabled_(false), | 107 : enabled_(false), |
105 id_(id) { | 108 id_(id), |
| 109 state_(MediaStreamTrackInterface::kLive), |
| 110 observer_(NULL) { |
106 } | 111 } |
107 virtual std::string kind() const OVERRIDE; | 112 virtual std::string kind() const OVERRIDE; |
108 virtual std::string id() const OVERRIDE; | 113 virtual std::string id() const OVERRIDE; |
109 virtual bool enabled() const OVERRIDE; | 114 virtual bool enabled() const OVERRIDE; |
110 virtual TrackState state() const OVERRIDE; | 115 virtual TrackState state() const OVERRIDE; |
111 virtual bool set_enabled(bool enable) OVERRIDE; | 116 virtual bool set_enabled(bool enable) OVERRIDE; |
112 virtual bool set_state(TrackState new_state) OVERRIDE; | 117 virtual bool set_state(TrackState new_state) OVERRIDE; |
113 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; | 118 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; |
114 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; | 119 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE; |
115 virtual webrtc::AudioSourceInterface* GetSource() const OVERRIDE; | 120 virtual webrtc::AudioSourceInterface* GetSource() const OVERRIDE; |
116 | 121 |
117 protected: | 122 protected: |
118 virtual ~MockLocalAudioTrack() {} | 123 virtual ~MockLocalAudioTrack() {} |
119 | 124 |
120 private: | 125 private: |
121 bool enabled_; | 126 bool enabled_; |
122 std::string id_; | 127 std::string id_; |
| 128 TrackState state_; |
| 129 webrtc::ObserverInterface* observer_; |
123 }; | 130 }; |
124 | 131 |
125 // A mock factory for creating different objects for | 132 // A mock factory for creating different objects for |
126 // RTC MediaStreams and PeerConnections. | 133 // RTC MediaStreams and PeerConnections. |
127 class MockMediaStreamDependencyFactory : public MediaStreamDependencyFactory { | 134 class MockMediaStreamDependencyFactory : public MediaStreamDependencyFactory { |
128 public: | 135 public: |
129 MockMediaStreamDependencyFactory(); | 136 MockMediaStreamDependencyFactory(); |
130 virtual ~MockMediaStreamDependencyFactory(); | 137 virtual ~MockMediaStreamDependencyFactory(); |
131 | 138 |
132 virtual scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( | 139 virtual scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 bool mock_pc_factory_created_; | 180 bool mock_pc_factory_created_; |
174 scoped_refptr <MockAudioSource> last_audio_source_; | 181 scoped_refptr <MockAudioSource> last_audio_source_; |
175 scoped_refptr <MockVideoSource> last_video_source_; | 182 scoped_refptr <MockVideoSource> last_video_source_; |
176 | 183 |
177 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory); | 184 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory); |
178 }; | 185 }; |
179 | 186 |
180 } // namespace content | 187 } // namespace content |
181 | 188 |
182 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ | 189 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_ |
OLD | NEW |