Fix build break
[chromium-blink-merge.git] / content / renderer / media / mock_media_stream_dependency_factory.h
blob9809fabd5bd1bbe16efa0438960e83ded9462212
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_
8 #include <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "content/renderer/media/media_stream_dependency_factory.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
15 namespace content {
17 class MockVideoSource : public webrtc::VideoSourceInterface {
18 public:
19 MockVideoSource();
21 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
22 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
23 virtual MediaSourceInterface::SourceState state() const OVERRIDE;
24 virtual cricket::VideoCapturer* GetVideoCapturer() OVERRIDE;
25 virtual void AddSink(cricket::VideoRenderer* output) OVERRIDE;
26 virtual void RemoveSink(cricket::VideoRenderer* output) OVERRIDE;
27 virtual const cricket::VideoOptions* options() const OVERRIDE;
29 // Changes the state of the source to live and notifies the observer.
30 void SetLive();
31 // Changes the state of the source to ended and notifies the observer.
32 void SetEnded();
34 protected:
35 virtual ~MockVideoSource();
37 private:
38 webrtc::ObserverInterface* observer_;
39 MediaSourceInterface::SourceState state_;
42 class MockAudioSource : public webrtc::AudioSourceInterface {
43 public:
44 MockAudioSource(const webrtc::MediaConstraintsInterface* constraints);
46 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
47 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
48 virtual MediaSourceInterface::SourceState state() const OVERRIDE;
50 // Changes the state of the source to live and notifies the observer.
51 void SetLive();
52 // Changes the state of the source to ended and notifies the observer.
53 void SetEnded();
55 const webrtc::MediaConstraintsInterface::Constraints& optional_constraints() {
56 return optional_constraints_;
59 const webrtc::MediaConstraintsInterface::Constraints&
60 mandatory_constraints() {
61 return mandatory_constraints_;
64 protected:
65 virtual ~MockAudioSource();
67 private:
68 webrtc::ObserverInterface* observer_;
69 MediaSourceInterface::SourceState state_;
70 webrtc::MediaConstraintsInterface::Constraints optional_constraints_;
71 webrtc::MediaConstraintsInterface::Constraints mandatory_constraints_;
74 class MockLocalVideoTrack : public webrtc::VideoTrackInterface {
75 public:
76 MockLocalVideoTrack(std::string id,
77 webrtc::VideoSourceInterface* source);
78 virtual void AddRenderer(webrtc::VideoRendererInterface* renderer) OVERRIDE;
79 virtual void RemoveRenderer(
80 webrtc::VideoRendererInterface* renderer) OVERRIDE;
81 virtual cricket::VideoRenderer* FrameInput() OVERRIDE;
82 virtual std::string kind() const OVERRIDE;
83 virtual std::string id() const OVERRIDE;
84 virtual bool enabled() const OVERRIDE;
85 virtual TrackState state() const OVERRIDE;
86 virtual bool set_enabled(bool enable) OVERRIDE;
87 virtual bool set_state(TrackState new_state) OVERRIDE;
88 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
89 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
90 virtual webrtc::VideoSourceInterface* GetSource() const OVERRIDE;
92 protected:
93 virtual ~MockLocalVideoTrack();
95 private:
96 bool enabled_;
97 std::string id_;
98 scoped_refptr<webrtc::VideoSourceInterface> source_;
101 class MockLocalAudioTrack : public webrtc::AudioTrackInterface {
102 public:
103 explicit MockLocalAudioTrack(const std::string& id)
104 : enabled_(false),
105 id_(id) {
107 virtual std::string kind() const OVERRIDE;
108 virtual std::string id() const OVERRIDE;
109 virtual bool enabled() const OVERRIDE;
110 virtual TrackState state() const OVERRIDE;
111 virtual bool set_enabled(bool enable) OVERRIDE;
112 virtual bool set_state(TrackState new_state) OVERRIDE;
113 virtual void RegisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
114 virtual void UnregisterObserver(webrtc::ObserverInterface* observer) OVERRIDE;
115 virtual webrtc::AudioSourceInterface* GetSource() const OVERRIDE;
117 protected:
118 virtual ~MockLocalAudioTrack() {}
120 private:
121 bool enabled_;
122 std::string id_;
125 // A mock factory for creating different objects for
126 // RTC MediaStreams and PeerConnections.
127 class MockMediaStreamDependencyFactory : public MediaStreamDependencyFactory {
128 public:
129 MockMediaStreamDependencyFactory();
130 virtual ~MockMediaStreamDependencyFactory();
132 virtual scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
133 const webrtc::PeerConnectionInterface::IceServers& ice_servers,
134 const webrtc::MediaConstraintsInterface* constraints,
135 WebKit::WebFrame* frame,
136 webrtc::PeerConnectionObserver* observer) OVERRIDE;
137 virtual scoped_refptr<webrtc::AudioSourceInterface>
138 CreateLocalAudioSource(
139 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
140 virtual scoped_refptr<webrtc::VideoSourceInterface>
141 CreateLocalVideoSource(
142 int video_session_id,
143 bool is_screencast,
144 const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
145 virtual bool InitializeAudioSource(
146 const StreamDeviceInfo& device_info) OVERRIDE;
147 virtual bool CreateWebAudioSource(
148 WebKit::WebMediaStreamSource* source) OVERRIDE;
149 virtual scoped_refptr<webrtc::MediaStreamInterface>
150 CreateLocalMediaStream(const std::string& label) OVERRIDE;
151 virtual scoped_refptr<webrtc::VideoTrackInterface>
152 CreateLocalVideoTrack(const std::string& id,
153 webrtc::VideoSourceInterface* source) OVERRIDE;
154 virtual scoped_refptr<webrtc::AudioTrackInterface>
155 CreateLocalAudioTrack(const std::string& id,
156 webrtc::AudioSourceInterface* source) OVERRIDE;
157 virtual webrtc::SessionDescriptionInterface* CreateSessionDescription(
158 const std::string& type,
159 const std::string& sdp,
160 webrtc::SdpParseError* error) OVERRIDE;
161 virtual webrtc::IceCandidateInterface* CreateIceCandidate(
162 const std::string& sdp_mid,
163 int sdp_mline_index,
164 const std::string& sdp) OVERRIDE;
166 virtual bool EnsurePeerConnectionFactory() OVERRIDE;
167 virtual bool PeerConnectionFactoryCreated() OVERRIDE;
169 MockAudioSource* last_audio_source() { return last_audio_source_; }
170 MockVideoSource* last_video_source() { return last_video_source_; }
172 private:
173 bool mock_pc_factory_created_;
174 scoped_refptr <MockAudioSource> last_audio_source_;
175 scoped_refptr <MockVideoSource> last_video_source_;
177 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDependencyFactory);
180 } // namespace content
182 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DEPENDENCY_FACTORY_H_