| 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 "content/renderer/media/media_stream.h" | 10 #include "content/renderer/media/media_stream.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 void MockMediaStreamRegistry::Init(const std::string& stream_url) { | 49 void MockMediaStreamRegistry::Init(const std::string& stream_url) { |
| 50 stream_url_ = stream_url; | 50 stream_url_ = stream_url; |
| 51 const blink::WebVector<blink::WebMediaStreamTrack> webkit_audio_tracks; | 51 const blink::WebVector<blink::WebMediaStreamTrack> webkit_audio_tracks; |
| 52 const blink::WebVector<blink::WebMediaStreamTrack> webkit_video_tracks; | 52 const blink::WebVector<blink::WebMediaStreamTrack> webkit_video_tracks; |
| 53 const blink::WebString label(kTestStreamLabel); | 53 const blink::WebString label(kTestStreamLabel); |
| 54 test_stream_.initialize(label, webkit_audio_tracks, webkit_video_tracks); | 54 test_stream_.initialize(label, webkit_audio_tracks, webkit_video_tracks); |
| 55 test_stream_.setExtraData(new MediaStream()); | 55 test_stream_.setExtraData(new MediaStream()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void MockMediaStreamRegistry::AddVideoTrack(const std::string& track_id) { | 58 void MockMediaStreamRegistry::AddVideoTrack( |
| 59 const std::string& track_id, |
| 60 const blink::WebMediaConstraints& constraints) { |
| 59 blink::WebMediaStreamSource blink_source; | 61 blink::WebMediaStreamSource blink_source; |
| 60 blink_source.initialize("mock video source id", | 62 blink_source.initialize("mock video source id", |
| 61 blink::WebMediaStreamSource::TypeVideo, | 63 blink::WebMediaStreamSource::TypeVideo, |
| 62 "mock video source name", | 64 "mock video source name", |
| 63 false /* remote */); | 65 false /* remote */); |
| 64 MockMediaStreamVideoSource* native_source = | 66 MockMediaStreamVideoSource* native_source = |
| 65 new MockMediaStreamVideoSource(false /* manual get supported formats */); | 67 new MockMediaStreamVideoSource(false /* manual get supported formats */); |
| 66 blink_source.setExtraData(native_source); | 68 blink_source.setExtraData(native_source); |
| 67 blink::WebMediaStreamTrack blink_track; | 69 blink::WebMediaStreamTrack blink_track; |
| 68 blink_track.initialize(base::UTF8ToUTF16(track_id), blink_source); | 70 blink_track.initialize(base::UTF8ToUTF16(track_id), blink_source); |
| 69 blink::WebMediaConstraints constraints; | |
| 70 constraints.initialize(); | |
| 71 | 71 |
| 72 MediaStreamVideoTrack* native_track = new MediaStreamVideoTrack( | 72 MediaStreamVideoTrack* native_track = new MediaStreamVideoTrack( |
| 73 native_source, constraints, MediaStreamVideoSource::ConstraintsCallback(), | 73 native_source, constraints, MediaStreamVideoSource::ConstraintsCallback(), |
| 74 true /* enabled */); | 74 true /* enabled */); |
| 75 blink_track.setTrackData(native_track); | 75 blink_track.setTrackData(native_track); |
| 76 test_stream_.addTrack(blink_track); | 76 test_stream_.addTrack(blink_track); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void MockMediaStreamRegistry::AddVideoTrack(const std::string& track_id) { |
| 80 blink::WebMediaConstraints constraints; |
| 81 constraints.initialize(); |
| 82 AddVideoTrack(track_id, constraints); |
| 83 } |
| 84 |
| 79 void MockMediaStreamRegistry::AddAudioTrack(const std::string& track_id) { | 85 void MockMediaStreamRegistry::AddAudioTrack(const std::string& track_id) { |
| 80 blink::WebMediaStreamSource blink_source; | 86 blink::WebMediaStreamSource blink_source; |
| 81 blink_source.initialize( | 87 blink_source.initialize( |
| 82 "mock audio source id", blink::WebMediaStreamSource::TypeAudio, | 88 "mock audio source id", blink::WebMediaStreamSource::TypeAudio, |
| 83 "mock audio source name", false /* remote */); | 89 "mock audio source name", false /* remote */); |
| 84 MediaStreamAudioSource* const source = new MockCDQualityAudioSource(); | 90 MediaStreamAudioSource* const source = new MockCDQualityAudioSource(); |
| 85 blink_source.setExtraData(source); // Takes ownership. | 91 blink_source.setExtraData(source); // Takes ownership. |
| 86 | 92 |
| 87 blink::WebMediaStreamTrack blink_track; | 93 blink::WebMediaStreamTrack blink_track; |
| 88 blink_track.initialize(blink_source); | 94 blink_track.initialize(blink_source); |
| 89 CHECK(source->ConnectToTrack(blink_track)); | 95 CHECK(source->ConnectToTrack(blink_track)); |
| 90 | 96 |
| 91 test_stream_.addTrack(blink_track); | 97 test_stream_.addTrack(blink_track); |
| 92 } | 98 } |
| 93 | 99 |
| 94 blink::WebMediaStream MockMediaStreamRegistry::GetMediaStream( | 100 blink::WebMediaStream MockMediaStreamRegistry::GetMediaStream( |
| 95 const std::string& url) { | 101 const std::string& url) { |
| 96 return (url != stream_url_) ? blink::WebMediaStream() : test_stream_; | 102 return (url != stream_url_) ? blink::WebMediaStream() : test_stream_; |
| 97 } | 103 } |
| 98 | 104 |
| 99 } // namespace content | 105 } // namespace content |
| OLD | NEW |