Bug 1292500 - Notify WebrtcUI when video capturing is paused/resumed. r=gcp
MozReview-Commit-ID: UkJVR7zCbI
--- 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];