summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormcasas <mcasas@chromium.org>2015-10-07 22:24:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-08 05:25:16 +0000
commit43ff56ff2bc004d542aa020b21655079e36ac441 (patch)
treec09b1bb638fb000cee97bb1e71f8132c175afd64
parentf479e2157cb0278d1859a02f11db6cc993b7aa36 (diff)
downloadchromium_src-43ff56ff2bc004d542aa020b21655079e36ac441.zip
chromium_src-43ff56ff2bc004d542aa020b21655079e36ac441.tar.gz
chromium_src-43ff56ff2bc004d542aa020b21655079e36ac441.tar.bz2
Extend components/test_runner's generated WebMediaStream to have a Chrome VideoTrack and Source
BUG=262211, 532509 Review URL: https://codereview.chromium.org/1391363002 Cr-Commit-Position: refs/heads/master@{#353012}
-rw-r--r--components/html_viewer/web_test_delegate_impl.cc6
-rw-r--r--components/html_viewer/web_test_delegate_impl.h1
-rw-r--r--components/test_runner/mock_web_user_media_client.cc27
-rw-r--r--components/test_runner/mock_web_user_media_client.h1
-rw-r--r--components/test_runner/test_runner.h1
-rw-r--r--components/test_runner/web_test_delegate.h8
-rw-r--r--content/public/renderer/media_stream_api.cc89
-rw-r--r--content/public/renderer/media_stream_api.h20
-rw-r--r--content/shell/renderer/layout_test/blink_test_runner.cc32
-rw-r--r--content/shell/renderer/layout_test/blink_test_runner.h1
-rw-r--r--third_party/WebKit/LayoutTests/TestExpectations3
-rw-r--r--third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-basic-video-expected.txt4
12 files changed, 119 insertions, 74 deletions
diff --git a/components/html_viewer/web_test_delegate_impl.cc b/components/html_viewer/web_test_delegate_impl.cc
index 4e958fd..b2dceec 100644
--- a/components/html_viewer/web_test_delegate_impl.cc
+++ b/components/html_viewer/web_test_delegate_impl.cc
@@ -310,6 +310,12 @@ void WebTestDelegateImpl::ResetPermissions() {
NOTIMPLEMENTED();
}
+bool WebTestDelegateImpl::AddMediaStreamSourceAndTrack(
+ blink::WebMediaStream* stream) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
cc::SharedBitmapManager* WebTestDelegateImpl::GetSharedBitmapManager() {
NOTIMPLEMENTED();
return nullptr;
diff --git a/components/html_viewer/web_test_delegate_impl.h b/components/html_viewer/web_test_delegate_impl.h
index b3ae0e8..e13be3b 100644
--- a/components/html_viewer/web_test_delegate_impl.h
+++ b/components/html_viewer/web_test_delegate_impl.h
@@ -108,6 +108,7 @@ class WebTestDelegateImpl : public test_runner::WebTestDelegate {
const GURL& origin,
const GURL& embedding_origin) override;
void ResetPermissions() override;
+ bool AddMediaStreamSourceAndTrack(blink::WebMediaStream* stream) override;
cc::SharedBitmapManager* GetSharedBitmapManager() override;
void DispatchBeforeInstallPromptEvent(
int request_id,
diff --git a/components/test_runner/mock_web_user_media_client.cc b/components/test_runner/mock_web_user_media_client.cc
index f30fac9..7cff4c3 100644
--- a/components/test_runner/mock_web_user_media_client.cc
+++ b/components/test_runner/mock_web_user_media_client.cc
@@ -18,7 +18,6 @@
#include "third_party/WebKit/public/platform/WebVector.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebMediaDevicesRequest.h"
-#include "third_party/WebKit/public/web/WebMediaStreamRegistry.h"
#include "third_party/WebKit/public/web/WebUserMediaRequest.h"
using blink::WebMediaConstraints;
@@ -161,34 +160,34 @@ void MockWebUserMediaClient::requestUserMedia(
return;
}
- const size_t zero = 0;
- const size_t one = 1;
- WebVector<WebMediaStreamTrack> audio_tracks(request.audio() ? one : zero);
- WebVector<WebMediaStreamTrack> video_tracks(request.video() ? one : zero);
+ WebMediaStream stream;
+ stream.initialize(WebVector<WebMediaStreamTrack>(),
+ WebVector<WebMediaStreamTrack>());
+ stream.setExtraData(new MockExtraData());
if (request.audio()) {
WebMediaStreamSource source;
source.initialize("MockAudioDevice#1",
WebMediaStreamSource::TypeAudio,
"Mock audio device",
- false /* remote */, true /* readonly */);
- audio_tracks[0].initialize(source);
+ false /* remote */,
+ true /* readonly */);
+ WebMediaStreamTrack web_track;
+ web_track.initialize(source);
+ stream.addTrack(web_track);
}
- if (request.video()) {
+ if (request.video() && !delegate_->AddMediaStreamSourceAndTrack(&stream)) {
WebMediaStreamSource source;
source.initialize("MockVideoDevice#1",
WebMediaStreamSource::TypeVideo,
"Mock video device",
false /* remote */, true /* readonly */);
- video_tracks[0].initialize(source);
+ WebMediaStreamTrack web_track;
+ web_track.initialize(source);
+ stream.addTrack(web_track);
}
- WebMediaStream stream;
- stream.initialize(audio_tracks, video_tracks);
-
- stream.setExtraData(new MockExtraData());
-
delegate_->PostTask(new UserMediaRequestTask(this, request, stream));
}
diff --git a/components/test_runner/mock_web_user_media_client.h b/components/test_runner/mock_web_user_media_client.h
index dda0d4df..33b55d5 100644
--- a/components/test_runner/mock_web_user_media_client.h
+++ b/components/test_runner/mock_web_user_media_client.h
@@ -5,7 +5,6 @@
#ifndef COMPONENTS_TEST_RUNNER_MOCK_WEB_USER_MEDIA_CLIENT_H_
#define COMPONENTS_TEST_RUNNER_MOCK_WEB_USER_MEDIA_CLIENT_H_
-#include "base/macros.h"
#include "components/test_runner/web_task.h"
#include "third_party/WebKit/public/web/WebUserMediaClient.h"
diff --git a/components/test_runner/test_runner.h b/components/test_runner/test_runner.h
index 45ee51a..b227a7ee 100644
--- a/components/test_runner/test_runner.h
+++ b/components/test_runner/test_runner.h
@@ -23,6 +23,7 @@ class SkBitmap;
namespace blink {
class WebContentSettingsClient;
class WebFrame;
+class WebMediaStream;
class WebString;
class WebView;
class WebURLResponse;
diff --git a/components/test_runner/web_test_delegate.h b/components/test_runner/web_test_delegate.h
index 26b135a..d53852e 100644
--- a/components/test_runner/web_test_delegate.h
+++ b/components/test_runner/web_test_delegate.h
@@ -27,13 +27,14 @@ class WebGamepads;
class WebHistoryItem;
class WebLayer;
class WebLocalFrame;
+class WebMediaStream;
class WebPlugin;
struct WebPluginParams;
-class WebURLResponse;
-class WebView;
struct WebRect;
struct WebSize;
struct WebURLError;
+class WebURLResponse;
+class WebView;
}
namespace cc {
@@ -244,6 +245,9 @@ class WebTestDelegate {
// Clear all the permissions set via SetPermission().
virtual void ResetPermissions() = 0;
+ // Add content MediaStream classes to the Blink MediaStream ones.
+ virtual bool AddMediaStreamSourceAndTrack(blink::WebMediaStream* stream) = 0;
+
virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0;
// Causes the beforeinstallprompt event to be sent to the renderer with a
diff --git a/content/public/renderer/media_stream_api.cc b/content/public/renderer/media_stream_api.cc
index da39c4b..d668695 100644
--- a/content/public/renderer/media_stream_api.cc
+++ b/content/public/renderer/media_stream_api.cc
@@ -11,9 +11,6 @@
#include "content/renderer/media/media_stream_audio_source.h"
#include "content/renderer/media/media_stream_video_capturer_source.h"
#include "content/renderer/media/media_stream_video_track.h"
-#include "media/base/audio_capturer_source.h"
-#include "media/base/video_capturer_source.h"
-#include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
#include "third_party/WebKit/public/platform/WebMediaStream.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
#include "third_party/WebKit/public/platform/WebURL.h"
@@ -37,61 +34,34 @@ bool AddVideoTrackToMediaStream(
bool is_remote,
bool is_readonly,
const std::string& media_stream_url) {
- blink::WebMediaStream stream =
+ blink::WebMediaStream web_stream =
blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(
GURL(media_stream_url));
-
- if (stream.isNull()) {
- LOG(ERROR) << "Stream not found";
- return false;
- }
- blink::WebString track_id = MakeTrackId();
- blink::WebMediaStreamSource webkit_source;
- scoped_ptr<MediaStreamVideoSource> media_stream_source(
- new MediaStreamVideoCapturerSource(
- MediaStreamSource::SourceStoppedCallback(),
- source.Pass()));
- webkit_source.initialize(
- track_id,
- blink::WebMediaStreamSource::TypeVideo,
- track_id,
- is_remote,
- is_readonly);
- webkit_source.setExtraData(media_stream_source.get());
-
- blink::WebMediaConstraints constraints;
- constraints.initialize();
- stream.addTrack(MediaStreamVideoTrack::CreateVideoTrack(
- media_stream_source.release(),
- constraints,
- MediaStreamVideoSource::ConstraintsCallback(),
- true));
- return true;
+ return AddVideoTrackToMediaStream(source.Pass(), is_remote, is_readonly,
+ &web_stream);
}
bool AddAudioTrackToMediaStream(
- scoped_refptr<media::AudioCapturerSource> source,
+ const scoped_refptr<media::AudioCapturerSource>& source,
const media::AudioParameters& params,
bool is_remote,
bool is_readonly,
const std::string& media_stream_url) {
DCHECK(params.IsValid()) << params.AsHumanReadableString();
- blink::WebMediaStream stream =
+ blink::WebMediaStream web_stream =
blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(
GURL(media_stream_url));
-
- if (stream.isNull()) {
- LOG(ERROR) << "Stream not found";
+ if (web_stream.isNull()) {
+ DLOG(ERROR) << "Stream not found";
return false;
}
blink::WebMediaStreamSource webkit_source;
- blink::WebString track_id = MakeTrackId();
- webkit_source.initialize(
- track_id,
- blink::WebMediaStreamSource::TypeAudio,
- track_id,
- is_remote,
- is_readonly);
+ const blink::WebString track_id = MakeTrackId();
+ webkit_source.initialize(track_id,
+ blink::WebMediaStreamSource::TypeAudio,
+ track_id,
+ is_remote,
+ is_readonly);
MediaStreamAudioSource* audio_source(
new MediaStreamAudioSource(
@@ -114,7 +84,38 @@ bool AddAudioTrackToMediaStream(
RenderThreadImpl::current()->GetPeerConnectionDependencyFactory()->
CreateLocalAudioTrack(web_media_audio_track);
- stream.addTrack(web_media_audio_track);
+ web_stream.addTrack(web_media_audio_track);
+ return true;
+}
+
+bool AddVideoTrackToMediaStream(scoped_ptr<media::VideoCapturerSource> source,
+ bool is_remote,
+ bool is_readonly,
+ blink::WebMediaStream* web_stream) {
+ if (web_stream->isNull()) {
+ DLOG(ERROR) << "Stream not found";
+ return false;
+ }
+ const blink::WebString track_id = MakeTrackId();
+ blink::WebMediaStreamSource webkit_source;
+ scoped_ptr<MediaStreamVideoSource> media_stream_source(
+ new MediaStreamVideoCapturerSource(
+ MediaStreamSource::SourceStoppedCallback(),
+ source.Pass()));
+ webkit_source.initialize(track_id,
+ blink::WebMediaStreamSource::TypeVideo,
+ track_id,
+ is_remote,
+ is_readonly);
+ webkit_source.setExtraData(media_stream_source.get());
+
+ blink::WebMediaConstraints constraints;
+ constraints.initialize();
+ web_stream->addTrack(MediaStreamVideoTrack::CreateVideoTrack(
+ media_stream_source.release(),
+ constraints,
+ MediaStreamVideoSource::ConstraintsCallback(),
+ true));
return true;
}
diff --git a/content/public/renderer/media_stream_api.h b/content/public/renderer/media_stream_api.h
index 71ce675..2e87ff3 100644
--- a/content/public/renderer/media_stream_api.h
+++ b/content/public/renderer/media_stream_api.h
@@ -10,17 +10,19 @@
#include "media/base/video_capturer_source.h"
namespace blink {
-class WebMediaStreamSource;
+class WebMediaStream;
}
-namespace Media {
+namespace media {
class AudioParameters;
}
namespace content {
-
-// These two methods will initialize a WebMediaStreamSource object to take
-// data from the provided audio or video capturer source.
+// These methods create a WebMediaStreamSource + MediaStreamSource pair with the
+// provided audio or video capturer source. A new WebMediaStreamTrack +
+// MediaStreamTrack pair is created, holding the previous MediaStreamSource, and
+// is plugged into the stream identified by |media_stream_url| (or passed as
+// |web_stream|).
// |is_remote| should be true if the source of the data is not a local device.
// |is_readonly| should be true if the format of the data cannot be changed by
// MediaTrackConstraints.
@@ -29,8 +31,14 @@ CONTENT_EXPORT bool AddVideoTrackToMediaStream(
bool is_remote,
bool is_readonly,
const std::string& media_stream_url);
+CONTENT_EXPORT bool AddVideoTrackToMediaStream(
+ scoped_ptr<media::VideoCapturerSource> source,
+ bool is_remote,
+ bool is_readonly,
+ blink::WebMediaStream* web_stream);
+
CONTENT_EXPORT bool AddAudioTrackToMediaStream(
- scoped_refptr<media::AudioCapturerSource> source,
+ const scoped_refptr<media::AudioCapturerSource>& source,
const media::AudioParameters& params,
bool is_remote,
bool is_readonly,
diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc
index 2233563..f5d6dcdf 100644
--- a/content/shell/renderer/layout_test/blink_test_runner.cc
+++ b/content/shell/renderer/layout_test/blink_test_runner.cc
@@ -35,6 +35,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
+#include "content/public/renderer/media_stream_api.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_visitor.h"
@@ -222,6 +223,23 @@ class MockGamepadProvider : public RendererGamepadProvider {
DISALLOW_COPY_AND_ASSIGN(MockGamepadProvider);
};
+class MockVideoCapturerSource : public media::VideoCapturerSource {
+ public:
+ MockVideoCapturerSource() = default;
+ ~MockVideoCapturerSource() override {}
+
+ void GetCurrentSupportedFormats(
+ int max_requested_width,
+ int max_requested_height,
+ double max_requested_frame_rate,
+ const VideoCaptureDeviceFormatsCB& callback) override {}
+ void StartCapture(
+ const media::VideoCaptureParams& params,
+ const VideoCaptureDeliverFrameCB& new_frame_callback,
+ const RunningCallback& running_callback) override {}
+ void StopCapture() override {}
+};
+
} // namespace
BlinkTestRunner::BlinkTestRunner(RenderView* render_view)
@@ -715,6 +733,20 @@ void BlinkTestRunner::OnWebTestProxyBaseDestroy(
test_runner::WebTestProxyBase* proxy) {
}
+bool BlinkTestRunner::AddMediaStreamSourceAndTrack(
+ blink::WebMediaStream* stream) {
+ DCHECK(stream);
+#if defined(ENABLE_WEBRTC)
+ return AddVideoTrackToMediaStream(
+ make_scoped_ptr(new MockVideoCapturerSource()),
+ false /* is_remote */,
+ false /* is_readonly */,
+ stream);
+#else
+ return false;
+#endif
+}
+
// RenderViewObserver --------------------------------------------------------
void BlinkTestRunner::DidClearWindowObject(WebLocalFrame* frame) {
diff --git a/content/shell/renderer/layout_test/blink_test_runner.h b/content/shell/renderer/layout_test/blink_test_runner.h
index 6739bed..8ff5a55 100644
--- a/content/shell/renderer/layout_test/blink_test_runner.h
+++ b/content/shell/renderer/layout_test/blink_test_runner.h
@@ -132,6 +132,7 @@ class BlinkTestRunner : public RenderViewObserver,
const GURL& origin,
const GURL& embedding_origin) override;
void ResetPermissions() override;
+ bool AddMediaStreamSourceAndTrack(blink::WebMediaStream* stream) override;
cc::SharedBitmapManager* GetSharedBitmapManager() override;
void DispatchBeforeInstallPromptEvent(
int request_id,
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 46dd1ba..7841a9b 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -405,9 +405,6 @@ crbug.com/505364 crbug.com/520616 imported/web-platform-tests/shadow-dom/untriag
crbug.com/539623 [ SnowLeopard ] fast/repaint/selection-change-in-iframe-with-relative-parent.html [ Pass Failure ImageOnlyFailure ]
-# Temporarily disabled until Chromium side supports meaningful MediaStreamTracks.
-crbug.com/532509 fast/mediarecorder/MediaRecorder-basic-video.html [ Skip ]
-
crbug.com/387740 imported/web-platform-tests/mediacapture-streams/stream-api/introduction/disabled-audio-silence.html [ Skip ]
crbug.com/387740 imported/web-platform-tests/mediacapture-streams/stream-api/introduction/disabled-video-black.html [ Skip ]
crbug.com/387740 imported/web-platform-tests/mediacapture-streams/stream-api/mediastreamtrack/mediastreamtrack-end.html [ Skip ]
diff --git a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-basic-video-expected.txt b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-basic-video-expected.txt
deleted file mode 100644
index d3482d8..0000000
--- a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-basic-video-expected.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a testharness.js-based test.
-FAIL checks the video-only MediaRecorder API. assert_unreached: Exception while creating MediaRecorder: NotSupportedError: Failed to construct 'MediaRecorder': No MediaRecorder handler can be created. Reached unreachable code
-Harness: the test ran to completion.
-