Bug 1292500 - Notify WebrtcUI when video capturing is paused/resumed. r=gcp draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 23 Aug 2016 12:36:17 +0200
changeset 404370 cf18e6d233d3cdda42d363d240f5375e79ef356d
parent 404025 78b89cc4c3d3f09f73077d02cb6cae7bae0e07c3
child 529177 b3d58ef81a1a5fb17adb85a49decbbe8eae7f05f
push id27202
push users.kaspari@gmail.com
push dateTue, 23 Aug 2016 11:23: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];