Bug 1292500 - Notify WebrtcUI when video capturing is paused/resumed. r=gcp, a=lizzard
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 23 Aug 2016 12:36:17 +0200
changeset 342476 f93f04ae8b36cb4ff4a20902173a71925417dfac
parent 342475 8e7e1a4f3520a4171224e9f2729b1b728b336bfe
child 342477 04df1a7cdd48e5a849568c4e6466d6bc2cd3194d
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp, lizzard
bugs1292500
milestone49.0
Bug 1292500 - Notify WebrtcUI when video capturing is paused/resumed. r=gcp, a=lizzard MozReview-Commit-ID: UkJVR7zCbI
media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
mobile/android/chrome/content/WebrtcUI.js
mobile/android/chrome/content/browser.js
--- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
@@ -101,24 +101,26 @@ public class VideoCaptureAndroid impleme
     mCaptureRotation = GetRotateAmount();
   }
 
   @Override
   public synchronized void onPause() {
     if (camera != null) {
       mResumeCapture = true;
       stopCapture();
+      GeckoAppShell.notifyObservers("VideoCapture:Paused", null);
     }
   }
 
   @Override
   public synchronized void onResume() {
     if (mResumeCapture) {
       startCapture(mCaptureWidth, mCaptureHeight, mCaptureMinFPS, mCaptureMaxFPS);
       mResumeCapture = false;
+      GeckoAppShell.notifyObservers("VideoCapture:Resumed", null);
     }
   }
 
   @Override
   public void onOrientationChanged() {
     mCaptureRotation = GetRotateAmount();
   }
 
--- a/mobile/android/chrome/content/WebrtcUI.js
+++ b/mobile/android/chrome/content/WebrtcUI.js
@@ -41,16 +41,23 @@ var WebrtcUI = {
       this.handlePCRequest(aSubject, aTopic, aData);
     } else if (aTopic === "recording-device-events") {
       switch (aData) {
         case "shutdown":
         case "starting":
           this.notify();
           break;
       }
+    } else if (aTopic === "VideoCapture:Paused") {
+      if (this._notificationId) {
+        Notifications.cancel(this._notificationId);
+        this._notificationId = null;
+      }
+    } else if (aTopic === "VideoCapture:Resumed") {
+      this.notify();
     }
   },
 
   notify: function() {
     let windows = MediaManagerService.activeMediaCaptureWindows;
     let count = windows.Count();
     let msg = {};
     if (count == 0) {
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -164,17 +164,19 @@ lazilyLoadedObserverScripts.push(
 ["ActionBarHandler", ["TextSelection:Get", "TextSelection:Action", "TextSelection:End"],
   "chrome://browser/content/ActionBarHandler.js"]
 );
 
 if (AppConstants.MOZ_WEBRTC) {
   lazilyLoadedObserverScripts.push(
     ["WebrtcUI", ["getUserMedia:request",
                   "PeerConnection:request",
-                  "recording-device-events"], "chrome://browser/content/WebrtcUI.js"])
+                  "recording-device-events",
+                  "VideoCapture:Paused",
+                  "VideoCapture:Resumed"], "chrome://browser/content/WebrtcUI.js"])
 }
 
 lazilyLoadedObserverScripts.forEach(function (aScript) {
   let [name, notifications, script] = aScript;
   XPCOMUtils.defineLazyGetter(window, name, function() {
     let sandbox = {};
     Services.scriptloader.loadSubScript(script, sandbox);
     return sandbox[name];