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
3 // found in the LICENSE file.
5 #include "content/renderer/media/mock_media_stream_registry.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
12 #include "third_party/WebKit/public/platform/WebString.h"
13 #include "third_party/WebKit/public/platform/WebVector.h"
14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h"
18 static const std::string kTestStreamLabel
= "stream_label";
20 MockMediaStreamRegistry::MockMediaStreamRegistry(
21 MockMediaStreamDependencyFactory
* factory
)
25 void MockMediaStreamRegistry::Init(const std::string
& stream_url
) {
26 stream_url_
= stream_url
;
27 scoped_refptr
<webrtc::MediaStreamInterface
> stream(
28 factory_
->CreateLocalMediaStream(kTestStreamLabel
));
29 blink::WebVector
<blink::WebMediaStreamTrack
> webkit_audio_tracks
;
30 blink::WebVector
<blink::WebMediaStreamTrack
> webkit_video_tracks
;
31 blink::WebString
webkit_stream_label(base::UTF8ToUTF16(stream
->label()));
32 test_stream_
.initialize(webkit_stream_label
,
33 webkit_audio_tracks
, webkit_video_tracks
);
34 test_stream_
.setExtraData(new MediaStreamExtraData(stream
.get(), false));
37 bool MockMediaStreamRegistry::AddVideoTrack(const std::string
& track_id
) {
38 cricket::VideoCapturer
* capturer
= NULL
;
39 return factory_
->AddNativeVideoMediaTrack(track_id
, &test_stream_
, capturer
);
42 blink::WebMediaStream
MockMediaStreamRegistry::GetMediaStream(
43 const std::string
& url
) {
44 if (url
!= stream_url_
) {
45 return blink::WebMediaStream();
50 const blink::WebMediaStream
MockMediaStreamRegistry::test_stream() const {
54 } // namespace content