diff options
author | wjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-06 22:19:21 +0000 |
---|---|---|
committer | wjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-06 22:19:21 +0000 |
commit | 73347bf7467d72c84997473489b5ab48e1c41a19 (patch) | |
tree | 7d234de80c0fc2e3a4e20ca82e487b2eb57cefa3 /webkit | |
parent | c694427c13725a8d73303fbe2c47e8cbd6abd6c3 (diff) | |
download | chromium_src-73347bf7467d72c84997473489b5ab48e1c41a19.zip chromium_src-73347bf7467d72c84997473489b5ab48e1c41a19.tar.gz chromium_src-73347bf7467d72c84997473489b5ab48e1c41a19.tar.bz2 |
add components for integration test which will detect breakage of media pipeline with video capture as video decoder.
This patch does NOT depend on the WebKit patch (https://bugs.webkit.org/show_bug.cgi?id=74882) any longer, since a utility class MediaStreamUtil has been added in webkit_support. On the opposite, that WebKit patch depends on this one.
There are 2 API's for webkit_support::CreateMediaPlayer in order to be backward compatible with WebKit. Once WebKit patch is landed, the old API (with 2 arguments) can be removed.
In that WebKit patch, WebViewHost uses WebKit::WebUserMediaClientMock to return a userMediaClient.
A mocked webkit_media::MediaStreamClient is used in webkit_support::CreateMediaPlayer.
BUG=none
TEST=run video-capture-preview.html
Review URL: http://codereview.chromium.org/8887004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/support/test_media_stream_client.cc | 37 | ||||
-rw-r--r-- | webkit/support/test_media_stream_client.h | 38 | ||||
-rw-r--r-- | webkit/support/webkit_support.cc | 35 | ||||
-rw-r--r-- | webkit/support/webkit_support.gypi | 2 | ||||
-rw-r--r-- | webkit/support/webkit_support.h | 17 |
5 files changed, 113 insertions, 16 deletions
diff --git a/webkit/support/test_media_stream_client.cc b/webkit/support/test_media_stream_client.cc new file mode 100644 index 0000000..4ca3e81 --- /dev/null +++ b/webkit/support/test_media_stream_client.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/test_media_stream_client.h" + +#include "googleurl/src/gurl.h" +#include "media/base/message_loop_factory.h" +#include "media/base/pipeline.h" +#include "media/filters/video_frame_generator.h" + +namespace { + +static const int kVideoCaptureWidth = 352; +static const int kVideoCaptureHeight = 288; +static const int kVideoCaptureFrameDurationMs = 33; + +} // namespace + +namespace webkit_support { + +TestMediaStreamClient::TestMediaStreamClient(MediaStreamUtil* media_stream_util) + : media_stream_util_(media_stream_util) { +} + +scoped_refptr<media::VideoDecoder> TestMediaStreamClient::GetVideoDecoder( + const GURL& url, media::MessageLoopFactory* message_loop_factory) { + if (!media_stream_util_ || !media_stream_util_->IsMockStream(url)) + return NULL; + + return new media::VideoFrameGenerator( + message_loop_factory->GetMessageLoopProxy("CaptureVideoDecoder").get(), + gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), + base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs)); +} + +} // namespace webkit_support diff --git a/webkit/support/test_media_stream_client.h b/webkit/support/test_media_stream_client.h new file mode 100644 index 0000000..3abb3a4 --- /dev/null +++ b/webkit/support/test_media_stream_client.h @@ -0,0 +1,38 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TestMediaStreamClient is an implementation of webkit_media::MediaStreamClient +// and used with WebKit::WebUserMediaClientMock to provide corresponding video +// decoder to media pipeline. + +#ifndef WEBKIT_SUPPORT_TEST_MEDIA_STREAM_CLIENT_H_ +#define WEBKIT_SUPPORT_TEST_MEDIA_STREAM_CLIENT_H_ + +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" +#include "webkit/media/media_stream_client.h" + +namespace webkit_support { + +class MediaStreamUtil { + public: + virtual bool IsMockStream(const WebKit::WebURL& url) = 0; +}; + +class TestMediaStreamClient : public webkit_media::MediaStreamClient { + public: + explicit TestMediaStreamClient(MediaStreamUtil* media_stream_util); + virtual ~TestMediaStreamClient() {} + + // Implement webkit_media::MediaStreamClient. + virtual scoped_refptr<media::VideoDecoder> GetVideoDecoder( + const GURL& url, + media::MessageLoopFactory* message_loop_factory) OVERRIDE; + + private: + MediaStreamUtil* media_stream_util_; +}; + +} // namespace webkit_support + +#endif // WEBKIT_SUPPORT_TEST_MEDIA_STREAM_CLIENT_H_ diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index 25a7be0..27c7441 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -302,8 +302,10 @@ WebPlugin* CreateWebPlugin(WebFrame* frame, frame, new_params, plugins.front().path); } -WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame, - WebMediaPlayerClient* client) { +WebKit::WebMediaPlayer* CreateMediaPlayer( + WebFrame* frame, + WebMediaPlayerClient* client, + webkit_media::MediaStreamClient* media_stream_client) { #if defined(OS_ANDROID) // TODO: Implement the WebMediaPlayer that will be used for Android. return NULL; @@ -320,7 +322,7 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame, base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), collection.release(), message_loop_factory.release(), - NULL, + media_stream_client, new media::MediaLog())); if (!result->Initialize(frame, false)) { return NULL; @@ -329,6 +331,12 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame, #endif } +WebKit::WebMediaPlayer* CreateMediaPlayer( + WebFrame* frame, + WebMediaPlayerClient* client) { + return CreateMediaPlayer(frame, client, NULL); +} + WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( WebFrame*, WebKit::WebApplicationCacheHostClient* client) { return SimpleAppCacheSystem::CreateApplicationCacheHost(client); @@ -342,7 +350,7 @@ WebKit::WebString GetWebKitRootDir() { } void SetUpGLBindings(GLBindingPreferences bindingPref) { - switch(bindingPref) { + switch (bindingPref) { case GL_BINDING_DEFAULT: gfx::GLSurface::InitializeOneOff(); break; @@ -512,16 +520,16 @@ WebURL LocalFileToDataURL(const WebURL& fileUrl) { // by webkit layout tests. class ScopedTempDirectoryInternal : public ScopedTempDirectory { public: - virtual bool CreateUniqueTempDir() { - return tempDirectory_.CreateUniqueTempDir(); - } + virtual bool CreateUniqueTempDir() { + return tempDirectory_.CreateUniqueTempDir(); + } - virtual std::string path() const { - return tempDirectory_.path().MaybeAsASCII(); - } + virtual std::string path() const { + return tempDirectory_.path().MaybeAsASCII(); + } private: - ScopedTempDir tempDirectory_; + ScopedTempDir tempDirectory_; }; ScopedTempDirectory* CreateScopedTempDirectory() { @@ -559,8 +567,9 @@ std::string MakeURLErrorDescription(const WebKit::WebURLError& error) { code = -1004; // NSURLErrorCannotConnectToHost break; } - } else + } else { DLOG(WARNING) << "Unknown error domain"; + } return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", domain.c_str(), code, error.unreachableURL.spec().data()); diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi index ada63ea..e262855 100644 --- a/webkit/support/webkit_support.gypi +++ b/webkit/support/webkit_support.gypi @@ -44,6 +44,8 @@ 'platform_support_linux.cc', 'platform_support_mac.mm', 'platform_support_win.cc', + 'test_media_stream_client.cc', + 'test_media_stream_client.h', 'test_webkit_platform_support.cc', 'test_webkit_platform_support.h', 'test_webmessageportchannel.cc', diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h index 7ff4cf7..71de1e0 100644 --- a/webkit/support/webkit_support.h +++ b/webkit/support/webkit_support.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,6 +32,10 @@ struct WebPluginParams; struct WebURLError; } +namespace webkit_media { +class MediaStreamClient; +} + // This package provides functions used by DumpRenderTree/chromium. // DumpRenderTree/chromium uses some code in webkit/ of Chromium. In // order to minimize the dependency from WebKit to Chromium, the @@ -63,8 +67,15 @@ WebKit::WebPlugin* CreateWebPlugin(WebKit::WebFrame* frame, const WebKit::WebPluginParams& params); // This is used by WebFrameClient::createMediaPlayer(). -WebKit::WebMediaPlayer* CreateMediaPlayer(WebKit::WebFrame* frame, - WebKit::WebMediaPlayerClient* client); +WebKit::WebMediaPlayer* CreateMediaPlayer( + WebKit::WebFrame* frame, + WebKit::WebMediaPlayerClient* client, + webkit_media::MediaStreamClient* media_stream_client); + +// This is used by WebFrameClient::createMediaPlayer(). +WebKit::WebMediaPlayer* CreateMediaPlayer( + WebKit::WebFrame* frame, + WebKit::WebMediaPlayerClient* client); // This is used by WebFrameClient::createApplicationCacheHost(). WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( |