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 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | 6 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
7 #include "content/renderer/media/mock_peer_connection_impl.h" | 7 #include "content/renderer/media/mock_peer_connection_impl.h" |
8 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h" | |
9 #include "third_party/libjingle/source/talk/base/scoped_ref_ptr.h" | |
8 #include "third_party/libjingle/source/talk/session/phone/webrtcmediaengine.h" | 10 #include "third_party/libjingle/source/talk/session/phone/webrtcmediaengine.h" |
9 | 11 |
12 namespace webrtc { | |
13 | |
14 class MockLocalVideoTrack : public LocalVideoTrackInterface { | |
15 public: | |
16 virtual cricket::VideoCapturer* GetVideoCapture() OVERRIDE { | |
17 NOTIMPLEMENTED(); | |
18 return NULL; | |
19 } | |
20 virtual void SetRenderer(VideoRendererWrapperInterface* renderer) OVERRIDE { | |
21 NOTIMPLEMENTED(); | |
22 } | |
23 virtual VideoRendererWrapperInterface* GetRenderer() OVERRIDE { | |
24 NOTIMPLEMENTED(); | |
25 return NULL; | |
26 } | |
27 virtual std::string kind() const OVERRIDE { | |
28 NOTIMPLEMENTED(); | |
29 return NULL; | |
tommi (sloooow) - chröme
2012/01/24 15:18:56
don't you mean ""?
Henrik Grunell
2012/01/26 13:03:16
Yes, copy paste miss. Fixed.
| |
30 } | |
31 virtual std::string label() const OVERRIDE { | |
32 NOTIMPLEMENTED(); | |
33 return NULL; | |
tommi (sloooow) - chröme
2012/01/24 15:18:56
and here
Henrik Grunell
2012/01/26 13:03:16
Done.
| |
34 } | |
35 virtual bool enabled() const OVERRIDE { | |
36 NOTIMPLEMENTED(); | |
37 return true; | |
38 } | |
39 virtual TrackState state() const OVERRIDE { | |
40 NOTIMPLEMENTED(); | |
41 return kInitializing; | |
42 } | |
43 virtual bool set_enabled(bool enable) OVERRIDE { | |
44 NOTIMPLEMENTED(); | |
45 return false; | |
46 } | |
47 virtual bool set_state(TrackState new_state) OVERRIDE { | |
48 NOTIMPLEMENTED(); | |
49 return NULL; | |
tommi (sloooow) - chröme
2012/01/24 15:18:56
false?
Henrik Grunell
2012/01/26 13:03:16
Yes, fixed.
| |
50 } | |
51 virtual void RegisterObserver(ObserverInterface* observer) OVERRIDE { | |
52 NOTIMPLEMENTED(); | |
53 } | |
54 virtual void UnregisterObserver(ObserverInterface* observer) OVERRIDE { | |
55 NOTIMPLEMENTED(); | |
56 } | |
57 | |
58 protected: | |
59 virtual ~MockLocalVideoTrack() {} | |
60 }; | |
61 | |
62 // TODO(grunell): BEFORE COMMIT. Audio track impl. | |
63 | |
64 class MockLocalMediaStream : public LocalMediaStreamInterface { | |
65 public: | |
66 virtual bool AddTrack(AudioTrackInterface* track) OVERRIDE { | |
67 NOTIMPLEMENTED(); | |
68 return false; | |
69 } | |
70 virtual bool AddTrack(VideoTrackInterface* track) OVERRIDE { | |
71 NOTIMPLEMENTED(); | |
72 return false; | |
73 } | |
74 virtual std::string label() const OVERRIDE { return label_; } | |
tommi (sloooow) - chröme
2012/01/24 15:18:56
should the label() accessor return const std::stri
Henrik Grunell
2012/01/26 13:03:16
The base class is not ours, can't change that.
| |
75 virtual AudioTracks* audio_tracks() OVERRIDE { | |
76 NOTIMPLEMENTED(); | |
77 return NULL; | |
78 } | |
79 virtual VideoTracks* video_tracks() OVERRIDE { | |
80 NOTIMPLEMENTED(); | |
81 return NULL; | |
82 } | |
83 virtual ReadyState ready_state() OVERRIDE { | |
84 NOTIMPLEMENTED(); | |
85 return kInitializing; | |
86 } | |
87 virtual void set_ready_state(ReadyState state) OVERRIDE { NOTIMPLEMENTED(); } | |
88 virtual void RegisterObserver(ObserverInterface* observer) OVERRIDE { | |
89 NOTIMPLEMENTED(); | |
90 } | |
91 virtual void UnregisterObserver(ObserverInterface* observer) { | |
92 NOTIMPLEMENTED(); | |
93 } | |
94 | |
95 protected: | |
96 virtual ~MockLocalMediaStream() {} | |
97 | |
98 private: | |
99 std::string label_; | |
100 }; | |
101 | |
102 } // namespace webrtc | |
103 | |
10 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() | 104 MockMediaStreamDependencyFactory::MockMediaStreamDependencyFactory() |
11 : mock_pc_factory_created_(false) { | 105 : mock_pc_factory_created_(false) { |
12 } | 106 } |
13 | 107 |
14 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} | 108 MockMediaStreamDependencyFactory::~MockMediaStreamDependencyFactory() {} |
15 | 109 |
16 cricket::WebRtcMediaEngine* | |
17 MockMediaStreamDependencyFactory::CreateWebRtcMediaEngine() { | |
18 return new cricket::WebRtcMediaEngine(NULL, NULL, NULL); | |
19 } | |
20 | |
21 bool MockMediaStreamDependencyFactory::CreatePeerConnectionFactory( | 110 bool MockMediaStreamDependencyFactory::CreatePeerConnectionFactory( |
22 cricket::MediaEngineInterface* media_engine, | 111 talk_base::Thread* worker_thread, |
23 talk_base::Thread* worker_thread) { | 112 talk_base::Thread* signaling_thread, |
113 content::P2PSocketDispatcher* socket_dispatcher, | |
114 talk_base::NetworkManager* network_manager, | |
115 talk_base::PacketSocketFactory* socket_factory) { | |
24 mock_pc_factory_created_ = true; | 116 mock_pc_factory_created_ = true; |
25 media_engine_.reset(media_engine); | |
26 return true; | 117 return true; |
27 } | 118 } |
28 | 119 |
29 void MockMediaStreamDependencyFactory::DeletePeerConnectionFactory() { | 120 void MockMediaStreamDependencyFactory::ReleasePeerConnectionFactory() { |
30 mock_pc_factory_created_ = false; | 121 mock_pc_factory_created_ = false; |
31 } | 122 } |
32 | 123 |
33 bool MockMediaStreamDependencyFactory::PeerConnectionFactoryCreated() { | 124 bool MockMediaStreamDependencyFactory::PeerConnectionFactoryCreated() { |
34 return mock_pc_factory_created_; | 125 return mock_pc_factory_created_; |
35 } | 126 } |
36 | 127 |
37 cricket::PortAllocator* MockMediaStreamDependencyFactory::CreatePortAllocator( | 128 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> |
tommi (sloooow) - chröme
2012/01/24 15:18:56
add the same 'using' lines for these types so that
Henrik Grunell
2012/01/26 13:03:16
Same comment. No change.
| |
38 content::P2PSocketDispatcher* socket_dispatcher, | 129 MockMediaStreamDependencyFactory::CreatePeerConnection( |
tommi (sloooow) - chröme
2012/01/24 15:18:56
fix indentation here
Henrik Grunell
2012/01/26 13:03:16
Done.
| |
39 talk_base::NetworkManager* network_manager, | 130 const std::string& config, |
40 talk_base::PacketSocketFactory* socket_factory, | 131 webrtc::PeerConnectionObserver* observer) { |
41 const webkit_glue::P2PTransport::Config& config) { | 132 DCHECK(mock_pc_factory_created_); |
133 // TODO(grunell): BEFORE COMMIT. Implement. | |
134 // return new webrtc::MockPeerConnectionImpl(); | |
135 NOTIMPLEMENTED(); | |
42 return NULL; | 136 return NULL; |
43 } | 137 } |
44 | 138 |
45 webrtc::PeerConnection* MockMediaStreamDependencyFactory::CreatePeerConnection( | 139 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> |
46 cricket::PortAllocator* port_allocator, | 140 MockMediaStreamDependencyFactory::CreateLocalMediaStream( |
47 talk_base::Thread* signaling_thread) { | 141 const std::string& label) { |
48 DCHECK(mock_pc_factory_created_); | 142 talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream( |
49 return new webrtc::MockPeerConnectionImpl(); | 143 new talk_base::RefCountedObject<webrtc::MockLocalMediaStream>()); |
144 return stream; | |
50 } | 145 } |
146 | |
147 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> | |
148 MockMediaStreamDependencyFactory::CreateLocalVideoTrack( | |
149 const std::string& label, | |
150 cricket::VideoCapturer* video_device) { | |
151 talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> stream( | |
152 new talk_base::RefCountedObject<webrtc::MockLocalVideoTrack>()); | |
153 return stream; | |
154 } | |
155 | |
156 talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> | |
157 MockMediaStreamDependencyFactory::CreateLocalAudioTrack( | |
158 const std::string& label, | |
159 webrtc::AudioDeviceModule* audio_device) { | |
160 // TODO(grunell): BEFORE COMMIT. Implement. | |
161 NOTIMPLEMENTED(); | |
162 return NULL; | |
163 } | |
OLD | NEW |