Bug 1292500 - Notify WebrtcUI when video capturing is paused/resumed. r=gcp
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 23 Aug 2016 12:36:17 +0200
changeset 341654 fd2938bd35dee332fb9928a504cec80136911c87
parent 341653 f11c01bf62a143aa419c146abd36072d515ffb52
child 341655 2c2e88b8bdcff6791718504310ad316558f2b6b6
push id5
push userfmarier@mozilla.com
push dateFri, 26 Aug 2016 00:45:46 +0000
reviewersgcp
bugs1292500
milestone51.0a1
Bug 1292500 - Notify WebrtcUI when video capturing is paused/resumed. r=gcp 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
@@ -161,17 +161,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];