Skip to content

Commit 024cb1d

Browse files
authored
browser(firefox): basic screencast implementation for GTK (#2818)
1 parent 6329cbb commit 024cb1d

File tree

12 files changed

+719
-5
lines changed

12 files changed

+719
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1118
1+
1119

browser_patches/firefox/juggler/moz.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
DIRS += ["components"]
5+
DIRS += ["components", "screencast"]
66

77
JAR_MANIFESTS += ["jar.mn"]
88
#JS_PREFERENCE_FILES += ["prefs/marionette.js"]

browser_patches/firefox/juggler/protocol/PageHandler.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class PageHandler {
9090
this._dialogs = new Map();
9191

9292
this._enabled = false;
93+
this._videoSessionId = -1;
9394
}
9495

9596
_onWorkerCreated({workerId, frameId, url}) {
@@ -284,6 +285,21 @@ class PageHandler {
284285
throw new Error('ERROR: cannot find worker with id ' + workerId);
285286
return await worker.sendMessage(JSON.parse(message));
286287
}
288+
289+
startVideoRecording({file, width, height, scale}) {
290+
const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);
291+
const docShell = this._pageTarget._gBrowser.ownerGlobal.docShell;
292+
this._videoSessionId = screencast.startVideoRecording(docShell, file);
293+
}
294+
295+
stopVideoRecording() {
296+
if (this._videoSessionId === -1)
297+
throw new Error('No video recording in progress');
298+
const videoSessionId = this._videoSessionId;
299+
this._videoSessionId = -1;
300+
const screencast = Cc['@mozilla.org/juggler/screencast;1'].getService(Ci.nsIScreencastService);
301+
screencast.stopVideoRecording(videoSessionId);
302+
}
287303
}
288304

289305
class Dialog {

browser_patches/firefox/juggler/protocol/Protocol.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,16 @@ const Page = {
825825
message: t.String,
826826
},
827827
},
828+
'startVideoRecording': {
829+
params: {
830+
file: t.String,
831+
width: t.Number,
832+
height: t.Number,
833+
scale: t.Optional(t.Number),
834+
},
835+
},
836+
'stopVideoRecording': {
837+
},
828838
},
829839
};
830840

0 commit comments

Comments
 (0)