Commit 983bedfb authored by Ben Murdoch's avatar Ben Murdoch Committed by Android (Google) Code Review
Browse files

Merge "Have dedicated IPC message for pause/resume video capture stream." into lmp-dev

parents afd2a9f8 7a872e45
......@@ -869,6 +869,7 @@ void AwContents::SetIsPaused(JNIEnv* env, jobject obj, bool paused) {
ContentViewCore::FromWebContents(web_contents_.get());
if (cvc) {
cvc->PauseOrResumeGeolocation(paused);
cvc->PauseOrResumeVideoCaptureStream(paused);
if (paused) {
cvc->PauseVideo();
}
......
......@@ -374,6 +374,17 @@ void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) {
web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause);
}
void ContentViewCoreImpl::PauseOrResumeVideoCaptureStream(bool should_pause) {
RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
web_contents_->GetRenderViewHost());
if (!rvhi)
return;
if (should_pause)
rvhi->Send(new ViewMsg_PauseVideoCaptureStream(rvhi->GetRoutingID()));
else
rvhi->Send(new ViewMsg_ResumeVideoCaptureStream(rvhi->GetRoutingID()));
}
// All positions and sizes are in CSS pixels.
// Note that viewport_width/height is a best effort based.
// ContentViewCore has the actual information about the physical viewport size.
......
......@@ -61,6 +61,7 @@ class ContentViewCoreImpl : public ContentViewCore,
virtual float GetDpiScale() const OVERRIDE;
virtual void PauseVideo() OVERRIDE;
virtual void PauseOrResumeGeolocation(bool should_pause) OVERRIDE;
virtual void PauseOrResumeVideoCaptureStream(bool should_pause) OVERRIDE;
virtual void RequestTextSurroundingSelection(
int max_length,
const base::Callback<void(const base::string16& content,
......
......@@ -952,6 +952,13 @@ IPC_MESSAGE_ROUTED0(ViewMsg_ImeEventAck)
IPC_MESSAGE_ROUTED1(ViewMsg_ExtractSmartClipData,
gfx::Rect /* rect */)
// Send by browser when video capture stream should be suspend.
IPC_MESSAGE_ROUTED0(ViewMsg_PauseVideoCaptureStream)
// Send by browser when video capture stream should be resume.
IPC_MESSAGE_ROUTED0(ViewMsg_ResumeVideoCaptureStream)
#elif defined(OS_MACOSX)
// Let the RenderView know its window has changed visibility.
IPC_MESSAGE_ROUTED1(ViewMsg_SetWindowVisibility,
......
......@@ -61,6 +61,7 @@ class CONTENT_EXPORT ContentViewCore {
virtual float GetDpiScale() const = 0;
virtual void PauseVideo() = 0;
virtual void PauseOrResumeGeolocation(bool should_pause) = 0;
virtual void PauseOrResumeVideoCaptureStream(bool should_pause) = 0;
// Observer callback for frame metadata updates.
typedef base::Callback<void(
......
......@@ -1126,6 +1126,10 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
OnUpdateTopControlsState)
IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
IPC_MESSAGE_HANDLER(ViewMsg_PauseVideoCaptureStream,
OnPauseVideoCaptureStream)
IPC_MESSAGE_HANDLER(ViewMsg_ResumeVideoCaptureStream,
OnResumeVideoCaptureStream)
#elif defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
OnPluginImeCompositionCompleted)
......
......@@ -765,6 +765,8 @@ class CONTENT_EXPORT RenderViewImpl
bool enable_showing,
bool animate);
void OnExtractSmartClipData(const gfx::Rect& rect);
void OnPauseVideoCaptureStream();
void OnResumeVideoCaptureStream();
#elif defined(OS_MACOSX)
void OnPluginImeCompositionCompleted(const base::string16& text,
int plugin_id);
......
......@@ -9,6 +9,8 @@
#include "cc/trees/layer_tree_host.h"
#include "content/common/view_messages.h"
#include "content/renderer/gpu/render_widget_compositor.h"
#include "content/renderer/media/video_capture_impl_manager.h"
#include "content/renderer/render_thread_impl.h"
#include "third_party/WebKit/public/web/WebView.h"
namespace content {
......@@ -73,4 +75,18 @@ void RenderViewImpl::OnExtractSmartClipData(const gfx::Rect& rect) {
routing_id_, clip_text, clip_html, clip_rect));
}
void RenderViewImpl::OnPauseVideoCaptureStream() {
#if defined(ENABLE_WEBRTC)
RenderThreadImpl::current()->video_capture_impl_manager()->
SuspendDevices(true);
#endif
}
void RenderViewImpl::OnResumeVideoCaptureStream() {
#if defined(ENABLE_WEBRTC)
RenderThreadImpl::current()->video_capture_impl_manager()->
SuspendDevices(false);
#endif
}
} // namespace content
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment