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

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

Issue 2878893003: VR: Poll media access flags (Closed)
Patch Set: VR: Poll media access flags 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..1200f7a23e556871a86e71c3d1005dc54f4132dc 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"
@@ -60,6 +62,7 @@ namespace vr_shell {
namespace {
vr_shell::VrShell* g_instance;
+float poll_media_access_interval_ = 0.01f;
mthiesse 2017/05/12 22:01:30 Use a constexpr TimeDelta
asimjour1 2017/05/12 22:31:48 Done.
void SetIsInVR(content::WebContents* contents, bool is_in_vr) {
if (contents && contents->GetRenderWidgetHostView())
@@ -512,11 +515,45 @@ 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() {
+ base::TimeDelta interval;
+ interval = base::TimeDelta::FromSecondsD(poll_media_access_interval_);
+ main_thread_task_runner_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&VrShell::PollMediaAccessFlag, weak_ptr_factory_.GetWeakPtr()),
mthiesse 2017/05/12 22:01:30 In order to avoid accidentally starting two loops
asimjour1 2017/05/12 22:31:48 Done.
+ 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