OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/media/mock_media_stream_registry.h" | 5 #include "content/renderer/media/mock_media_stream_registry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
12 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
13 #include "third_party/WebKit/public/platform/WebVector.h" | 13 #include "third_party/WebKit/public/platform/WebVector.h" |
14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" | 14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 static const std::string kTestStreamLabel = "stream_label"; | 18 static const std::string kTestStreamLabel = "stream_label"; |
19 | 19 |
20 MockMediaStreamRegistry::MockMediaStreamRegistry( | 20 MockMediaStreamRegistry::MockMediaStreamRegistry( |
21 MockMediaStreamDependencyFactory* factory) | 21 MockMediaStreamDependencyFactory* factory) |
22 : factory_(factory) { | 22 : factory_(factory) { |
23 } | 23 } |
24 | 24 |
25 void MockMediaStreamRegistry::Init(const std::string& stream_url) { | 25 void MockMediaStreamRegistry::Init(const std::string& stream_url) { |
26 stream_url_ = stream_url; | 26 stream_url_ = stream_url; |
27 scoped_refptr<webrtc::MediaStreamInterface> stream( | 27 scoped_refptr<webrtc::MediaStreamInterface> stream( |
28 factory_->CreateLocalMediaStream(kTestStreamLabel)); | 28 factory_->CreateLocalMediaStream(kTestStreamLabel)); |
29 WebKit::WebVector<WebKit::WebMediaStreamTrack> webkit_audio_tracks; | 29 blink::WebVector<blink::WebMediaStreamTrack> webkit_audio_tracks; |
30 WebKit::WebVector<WebKit::WebMediaStreamTrack> webkit_video_tracks; | 30 blink::WebVector<blink::WebMediaStreamTrack> webkit_video_tracks; |
31 WebKit::WebString webkit_stream_label(UTF8ToUTF16(stream->label())); | 31 blink::WebString webkit_stream_label(UTF8ToUTF16(stream->label())); |
32 test_stream_.initialize(webkit_stream_label, | 32 test_stream_.initialize(webkit_stream_label, |
33 webkit_audio_tracks, webkit_video_tracks); | 33 webkit_audio_tracks, webkit_video_tracks); |
34 test_stream_.setExtraData(new MediaStreamExtraData(stream.get(), false)); | 34 test_stream_.setExtraData(new MediaStreamExtraData(stream.get(), false)); |
35 } | 35 } |
36 | 36 |
37 bool MockMediaStreamRegistry::AddVideoTrack(const std::string& track_id) { | 37 bool MockMediaStreamRegistry::AddVideoTrack(const std::string& track_id) { |
38 cricket::VideoCapturer* capturer = NULL; | 38 cricket::VideoCapturer* capturer = NULL; |
39 return factory_->AddNativeVideoMediaTrack(track_id, &test_stream_, capturer); | 39 return factory_->AddNativeVideoMediaTrack(track_id, &test_stream_, capturer); |
40 } | 40 } |
41 | 41 |
42 WebKit::WebMediaStream MockMediaStreamRegistry::GetMediaStream( | 42 blink::WebMediaStream MockMediaStreamRegistry::GetMediaStream( |
43 const std::string& url) { | 43 const std::string& url) { |
44 if (url != stream_url_) { | 44 if (url != stream_url_) { |
45 return WebKit::WebMediaStream(); | 45 return blink::WebMediaStream(); |
46 } | 46 } |
47 return test_stream_; | 47 return test_stream_; |
48 } | 48 } |
49 | 49 |
50 const WebKit::WebMediaStream MockMediaStreamRegistry::test_stream() const { | 50 const blink::WebMediaStream MockMediaStreamRegistry::test_stream() const { |
51 return test_stream_; | 51 return test_stream_; |
52 } | 52 } |
53 | 53 |
54 } // namespace content | 54 } // namespace content |
OLD | NEW |