Skip to content

Commit

Permalink
Merge pull request crosswalk-project#9 from PeterWangIntel/meida-17
Browse files Browse the repository at this point in the history
To disable media
  • Loading branch information
heke123 committed Dec 29, 2015
2 parents 7b7fe90 + e4d239e commit 239c7ca
Show file tree
Hide file tree
Showing 50 changed files with 683 additions and 1 deletion.
2 changes: 2 additions & 0 deletions content/browser/android/browser_jni_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
content::InterstitialPageDelegateAndroid::
RegisterInterstitialPageDelegateAndroid},
{"LoadUrlParams", content::RegisterLoadUrlParams},
#ifndef DISABLE_MEDIA
{"MediaDrmCredentialManager",
content::MediaDrmCredentialManager::RegisterMediaDrmCredentialManager},
{"MediaResourceGetterImpl",
content::MediaResourceGetterImpl::RegisterMediaResourceGetter},
{"MediaSession", content::MediaSession::RegisterMediaSession},
#endif
{"MotionEventAndroid",
content::MotionEventAndroid::RegisterMotionEventAndroid},
{"MotionEventSynthesizer",
Expand Down
4 changes: 4 additions & 0 deletions content/browser/android/browser_surface_texture_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "content/browser/android/child_process_launcher_android.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#ifndef DISABLE_MEDIA
#include "content/browser/media/android/browser_media_player_manager.h"
#endif
#include "content/public/browser/browser_thread.h"
#include "ui/gl/android/scoped_java_surface.h"
#include "ui/gl/android/surface_texture.h"
Expand Down Expand Up @@ -66,10 +68,12 @@ void BrowserSurfaceTextureManager::EstablishSurfaceTexturePeer(
if (!surface_texture.get())
return;

#ifndef DISABLE_MEDIA
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&BrowserMediaPlayerManager::SetSurfacePeer, surface_texture,
render_process_handle, render_frame_id, player_id));
#endif
}

BrowserSurfaceTextureManager::BrowserSurfaceTextureManager() {
Expand Down
4 changes: 4 additions & 0 deletions content/browser/android/child_process_launcher_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#ifndef DISABLE_MEDIA
#include "content/browser/media/android/browser_media_player_manager.h"
#include "content/browser/media/media_web_contents_observer.h"
#endif
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -52,6 +54,7 @@ static void SetSurfacePeer(
return;
}

#ifndef DISABLE_MEDIA
RenderFrameHostImpl* frame =
RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
if (!frame) {
Expand All @@ -78,6 +81,7 @@ static void SetSurfacePeer(
gfx::ScopedJavaSurface scoped_surface(surface);
player->SetVideoSurface(scoped_surface.Pass());
}
#endif // ifndef DISABLE_MEDIA
}

} // anonymous namespace
Expand Down
2 changes: 2 additions & 0 deletions content/browser/android/in_process_surface_texture_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ void InProcessSurfaceTextureManager::EstablishSurfaceTexturePeer(
if (!surface_texture.get())
return;

#ifndef DISABLE_MEDIA
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&BrowserMediaPlayerManager::SetSurfacePeer, surface_texture,
render_process_handle, render_frame_id, player_id));
#endif
}

InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {
Expand Down
10 changes: 10 additions & 0 deletions content/browser/browser_main_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/histogram_synchronizer.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#ifndef DISABLE_MEDIA
#include "content/browser/media/media_internals.h"
#endif
#include "content/browser/mojo/mojo_shell_context.h"
#include "content/browser/net/browser_online_state_observer.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
Expand All @@ -61,10 +63,12 @@
#include "content/public/common/result_codes.h"
#include "crypto/nss_util.h"
#include "device/battery/battery_status_service.h"
#ifndef DISABLE_MEDIA
#include "media/audio/audio_manager.h"
#include "media/base/media.h"
#include "media/base/user_input_monitor.h"
#include "media/midi/midi_manager.h"
#endif
#include "net/base/network_change_notifier.h"
#include "net/socket/client_socket_factory.h"
#include "net/ssl/ssl_config_service.h"
Expand Down Expand Up @@ -544,10 +548,12 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
}

#if !defined(OS_IOS)
#ifndef DISABLE_MEDIA
{
TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MediaFeatures");
media::InitializeMediaLibrary();
}
#endif
{
TRACE_EVENT0("startup",
"BrowserMainLoop::Subsystem:ContentWebUIController");
Expand Down Expand Up @@ -1152,6 +1158,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
BrowserGpuMemoryBufferManager::current(), io_thread_->task_runner());

#ifndef DISABLE_MEDIA
{
TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:AudioMan");
audio_manager_.reset(media::AudioManager::CreateWithHangTimer(
Expand All @@ -1162,6 +1169,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
TRACE_EVENT0("startup", "BrowserThreadsStarted::Subsystem:MidiManager");
midi_manager_.reset(media::midi::MidiManager::Create());
}
#endif

#if defined(OS_LINUX) && defined(USE_UDEV)
device_monitor_linux_.reset(new DeviceMonitorLinux());
Expand All @@ -1180,6 +1188,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl());
}

#ifndef DISABLE_MEDIA
// MediaStreamManager needs the IO thread to be created.
{
TRACE_EVENT0("startup",
Expand All @@ -1203,6 +1212,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
user_input_monitor_ = media::UserInputMonitor::Create(
io_thread_->task_runner(), main_thread_->task_runner());
}
#endif // ifndef DISABLE_MEDIA

{
TRACE_EVENT0("startup",
Expand Down
8 changes: 8 additions & 0 deletions content/browser/browser_main_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class TraceEventSystemStatsMonitor;
} // namespace trace_event
} // namespace base

#ifndef DISABLE_MEDIA
namespace media {
class AudioManager;
class UserInputMonitor;
namespace midi {
class MidiManager;
} // namespace midi
} // namespace media
#endif // ifndef DISABLE_MEDIA

namespace net {
class NetworkChangeNotifier;
Expand Down Expand Up @@ -106,14 +108,18 @@ class CONTENT_EXPORT BrowserMainLoop {

int GetResultCode() const { return result_code_; }

#ifndef DISABLE_MEDIA
media::AudioManager* audio_manager() const { return audio_manager_.get(); }
#endif
MediaStreamManager* media_stream_manager() const {
return media_stream_manager_.get();
}
#ifndef DISABLE_MEDIA
media::UserInputMonitor* user_input_monitor() const {
return user_input_monitor_.get();
}
media::midi::MidiManager* midi_manager() const { return midi_manager_.get(); }
#endif
base::Thread* indexed_db_thread() const { return indexed_db_thread_.get(); }

bool is_tracing_startup() const { return is_tracing_startup_; }
Expand Down Expand Up @@ -240,11 +246,13 @@ class CONTENT_EXPORT BrowserMainLoop {
scoped_ptr<base::Thread> indexed_db_thread_;
scoped_ptr<MojoShellContext> mojo_shell_context_;

#ifndef DISABLE_MEDIA
// |user_input_monitor_| has to outlive |audio_manager_|, so declared first.
scoped_ptr<media::UserInputMonitor> user_input_monitor_;
scoped_ptr<media::AudioManager> audio_manager_;

scoped_ptr<media::midi::MidiManager> midi_manager_;
#endif

#if defined(USE_UDEV)
scoped_ptr<DeviceMonitorLinux> device_monitor_linux_;
Expand Down
2 changes: 2 additions & 0 deletions content/browser/media/media_web_contents_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
#include "ipc/ipc_message_macros.h"

#if defined(OS_ANDROID)
#ifndef DISABLE_MEDIA
#include "content/browser/android/media_players_observer.h"
#include "content/browser/media/android/browser_media_player_manager.h"
#include "content/common/media/media_player_messages_android.h"
#include "media/base/android/media_player_android.h"
#endif
#endif // defined(OS_ANDROID)

namespace content {
Expand Down
24 changes: 24 additions & 0 deletions content/browser/renderer_host/render_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#ifndef DISABLE_MEDIA
#include "content/browser/media/media_internals.h"
#endif
#include "content/browser/plugin_process_host.h"
#include "content/browser/renderer_host/pepper/pepper_security_helper.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
Expand Down Expand Up @@ -53,10 +55,12 @@
#include "content/public/common/webplugininfo.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_platform_file.h"
#ifndef DISABLE_MEDIA
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_parameters.h"
#include "media/base/media_log_event.h"
#endif
#include "net/base/io_buffer.h"
#include "net/base/keygen_handler.h"
#include "net/base/mime_util.h"
Expand Down Expand Up @@ -84,8 +88,10 @@
#include "content/common/sandbox_win.h"
#endif
#if defined(OS_ANDROID)
#ifndef DISABLE_MEDIA
#include "media/base/android/webaudio_media_codec_bridge.h"
#endif
#endif

#if defined(ENABLE_PLUGINS)
#include "content/browser/plugin_service_impl.h"
Expand Down Expand Up @@ -314,9 +320,13 @@ RenderMessageFilter::RenderMessageFilter(
render_widget_helper_(render_widget_helper),
incognito_(browser_context->IsOffTheRecord()),
dom_storage_context_(dom_storage_context),
#ifndef DISABLE_MEDIA
render_process_id_(render_process_id),
audio_manager_(audio_manager),
media_internals_(media_internals) {
#else
render_process_id_(render_process_id) {
#endif
DCHECK(request_context_.get());

if (render_widget_helper)
Expand Down Expand Up @@ -423,17 +433,23 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata,
OnCacheableMetadataAvailable)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_Keygen, OnKeygen)
#ifndef DISABLE_MEDIA
IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioHardwareConfig,
OnGetAudioHardwareConfig)
#endif
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetMonitorColorProfile,
OnGetMonitorColorProfile)
#endif
#ifndef DISABLE_MEDIA
IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents)
#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_Are3DAPIsBlocked, OnAre3DAPIsBlocked)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidLose3DContext, OnDidLose3DContext)
#ifndef DISABLE_MEDIA
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ViewHostMsg_RunWebAudioMediaCodec, OnWebAudioMediaCodec)
#endif
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
Expand All @@ -458,9 +474,11 @@ base::TaskRunner* RenderMessageFilter::OverrideTaskRunnerForMessage(
if (message.type() == ViewHostMsg_GetMonitorColorProfile::ID)
return BrowserThread::GetBlockingPool();
#endif
#ifndef DISABLE_MEDIA
// Always query audio device parameters on the audio thread.
if (message.type() == ViewHostMsg_GetAudioHardwareConfig::ID)
return audio_manager_->GetTaskRunner().get();
#endif
return NULL;
}

Expand Down Expand Up @@ -795,6 +813,7 @@ void RenderMessageFilter::OnGenerateRoutingID(int* route_id) {
*route_id = render_widget_helper_->GetNextRoutingID();
}

#ifndef DISABLE_MEDIA
void RenderMessageFilter::OnGetAudioHardwareConfig(
media::AudioParameters* input_params,
media::AudioParameters* output_params) {
Expand All @@ -806,6 +825,7 @@ void RenderMessageFilter::OnGetAudioHardwareConfig(
*input_params = audio_manager_->GetInputStreamParameters(
media::AudioManagerBase::kDefaultDeviceId);
}
#endif

#if defined(OS_WIN)
void RenderMessageFilter::OnGetMonitorColorProfile(std::vector<char>* profile) {
Expand Down Expand Up @@ -1049,6 +1069,7 @@ void RenderMessageFilter::OnKeygenOnWorkerThread(
Send(reply_msg);
}

#ifndef DISABLE_MEDIA
void RenderMessageFilter::OnMediaLogEvents(
const std::vector<media::MediaLogEvent>& events) {
// OnMediaLogEvents() is always dispatched to the UI thread for handling.
Expand All @@ -1057,6 +1078,7 @@ void RenderMessageFilter::OnMediaLogEvents(
if (media_internals_)
media_internals_->OnMediaEvents(render_process_id_, events);
}
#endif

void RenderMessageFilter::CheckPolicyForCookies(
int render_frame_id,
Expand Down Expand Up @@ -1173,6 +1195,7 @@ void RenderMessageFilter::OnPreCacheFontCharacters(const LOGFONT& font,
}
#endif

#ifndef DISABLE_MEDIA
#if defined(OS_ANDROID)
void RenderMessageFilter::OnWebAudioMediaCodec(
base::SharedMemoryHandle encoded_data_handle,
Expand All @@ -1188,6 +1211,7 @@ void RenderMessageFilter::OnWebAudioMediaCodec(
true);
}
#endif
#endif

void RenderMessageFilter::OnAllocateGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
uint32 width,
Expand Down
10 changes: 10 additions & 0 deletions content/browser/renderer_host/render_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
#include "content/public/browser/browser_message_filter.h"
#include "content/public/common/three_d_api_types.h"
#include "ipc/message_filter.h"
#ifndef DISABLE_MEDIA
#include "media/audio/audio_parameters.h"
#include "media/base/channel_layout.h"
#endif
#include "net/cookies/canonical_cookie.h"
#include "third_party/WebKit/public/web/WebPopupType.h"
#include "ui/gfx/geometry/rect.h"
Expand Down Expand Up @@ -213,8 +215,10 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {
const base::string16& suggested_name);
void OnSaveImageFromDataURL(int render_view_id, const std::string& url_str);

#ifndef DISABLE_MEDIA
void OnGetAudioHardwareConfig(media::AudioParameters* input_params,
media::AudioParameters* output_params);
#endif

#if defined(OS_WIN)
// Used to look up the monitor color profile.
Expand Down Expand Up @@ -259,7 +263,9 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {
scoped_ptr<net::KeygenHandler> keygen_handler);
void OnKeygenOnWorkerThread(scoped_ptr<net::KeygenHandler> keygen_handler,
IPC::Message* reply_msg);
#ifndef DISABLE_MEDIA
void OnMediaLogEvents(const std::vector<media::MediaLogEvent>&);
#endif

// Check the policy for getting cookies. Gets the cookies if allowed.
void CheckPolicyForCookies(int render_frame_id,
Expand All @@ -286,10 +292,12 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {
ThreeDAPIType context_type,
int arb_robustness_status_code);

#ifndef DISABLE_MEDIA
#if defined(OS_ANDROID)
void OnWebAudioMediaCodec(base::SharedMemoryHandle encoded_data_handle,
base::FileDescriptor pcm_output,
uint32_t data_size);
#endif
#endif

void OnAllocateGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
Expand Down Expand Up @@ -333,8 +341,10 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {

std::set<OpenChannelToNpapiPluginCallback*> plugin_host_clients_;

#ifndef DISABLE_MEDIA
media::AudioManager* audio_manager_;
MediaInternals* media_internals_;
#endif

DISALLOW_COPY_AND_ASSIGN(RenderMessageFilter);
};
Expand Down
Loading

0 comments on commit 239c7ca

Please sign in to comment.