Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3803)

Unified Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2878893003: VR: Poll media access flags (Closed)
Patch Set: Address Comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index 1917ddbef19bccb8195c63e9dc0a1d1bd400e840..9fe8304e000f01722a140f62c61a927ce864cd86 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -30,6 +30,8 @@
#include "chrome/browser/android/vr_shell/vr_shell_gl.h"
#include "chrome/browser/android/vr_shell/vr_usage_monitor.h"
#include "chrome/browser/android/vr_shell/vr_web_contents_observer.h"
+#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
+#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/render_view_host.h"
@@ -61,6 +63,9 @@ namespace vr_shell {
namespace {
vr_shell::VrShell* g_instance;
+constexpr base::TimeDelta poll_media_access_interval_ =
+ base::TimeDelta::FromSecondsD(0.01);
+
void SetIsInVR(content::WebContents* contents, bool is_in_vr) {
if (contents && contents->GetRenderWidgetHostView())
contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
@@ -177,6 +182,7 @@ bool RegisterVrShell(JNIEnv* env) {
VrShell::~VrShell() {
DVLOG(1) << __FUNCTION__ << "=" << this;
+ poll_capturing_media_task_.Cancel();
if (gamepad_source_active_) {
device::GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
device::GAMEPAD_SOURCE_GVR);
@@ -512,11 +518,46 @@ void VrShell::OnVRVsyncProviderRequest(
void VrShell::UpdateVSyncInterval(int64_t timebase_nanos,
double interval_seconds) {
+ PollMediaAccessFlag();
PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateVSyncInterval,
gl_thread_->GetVrShellGl(), timebase_nanos,
interval_seconds));
}
+void VrShell::PollMediaAccessFlag() {
+ poll_capturing_media_task_.Cancel();
+
+ poll_capturing_media_task_.Reset(
+ base::Bind(&VrShell::PollMediaAccessFlag, base::Unretained(this)));
+ main_thread_task_runner_->PostDelayedTask(
+ FROM_HERE, poll_capturing_media_task_.callback(),
+ poll_media_access_interval_);
+
+ scoped_refptr<MediaStreamCaptureIndicator> indicator =
+ MediaCaptureDevicesDispatcher::GetInstance()
+ ->GetMediaStreamCaptureIndicator();
+ bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_);
+ if (is_capturing_audio != is_capturing_audio_)
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetAudioCapturingWarning,
+ gl_thread_->GetVrShellGl(),
+ is_capturing_audio));
+ is_capturing_audio_ = is_capturing_audio;
+
+ bool is_capturing_video = indicator->IsCapturingVideo(web_contents_);
+ if (is_capturing_video != is_capturing_video_)
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetVideoCapturingWarning,
+ gl_thread_->GetVrShellGl(),
+ is_capturing_video));
+ is_capturing_video_ = is_capturing_video;
+
+ bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_);
+ if (is_capturing_screen != is_capturing_screen_)
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetScreenCapturingWarning,
+ gl_thread_->GetVrShellGl(),
+ is_capturing_screen));
+ is_capturing_screen_ = is_capturing_screen;
+}
+
void VrShell::SetContentCssSize(float width, float height, float dpr) {
JNIEnv* env = base::android::AttachCurrentThread();
Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height,
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698