bug 1116856 - rely on dynamically resizing tab mirror video stream based on window size r=mfinkle

This commit is contained in:
Brad Lassey 2014-12-31 16:48:47 -05:00
parent c7b46e4d82
commit d03ef1cae5
2 changed files with 6 additions and 35 deletions

View File

@ -41,30 +41,16 @@ TabMirror.prototype = {
this._pc.onicecandidate = this._onIceCandidate.bind(this);
let windowId = this._window.BrowserApp.selectedBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
let viewport = this._window.BrowserApp.selectedTab.getViewport();
let maxWidth = Math.max(viewport.cssWidth, viewport.width);
let maxHeight = Math.max(viewport.cssHeight, viewport.height);
let videoWidth = 0;
let videoHeight = 0;
if (this._screenSize.width/this._screenSize.height < maxWidth / maxHeight) {
videoWidth = this._screenSize.width;
videoHeight = Math.ceil(videoWidth * maxHeight / maxWidth);
} else {
videoHeight = this._screenSize.height;
videoWidth = Math.ceil(videoHeight * maxWidth / maxHeight);
}
let constraints = {
video: {
mediaSource: "browser",
browserWindow: windowId,
scrollWithPage: true,
advanced: [
{ width: { min: videoWidth, max: videoWidth },
height: { min: videoHeight, max: videoHeight }
{ width: { min: 0, max: this._screenSize.width },
height: { min: 0, max: this._screenSize.height }
},
{ aspectRatio: maxWidth / maxHeight }
{ aspectRatio: this._screenSize.width / this._screenSize.height }
]
}
};

View File

@ -288,24 +288,9 @@ function RemoteMirror(url, win, viewport, mirrorStartedCallback, contentWindow)
// This code insures the generated tab mirror is not wider than 1280 nor taller than 720
// Better dimensions should be chosen after the Roku Channel is working.
let windowId = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
let cWidth = Math.max(viewport.cssWidth, viewport.width);
let cHeight = Math.max(viewport.cssHeight, viewport.height);
const MAX_WIDTH = 1280;
const MAX_HEIGHT = 720;
let tWidth = 0;
let tHeight = 0;
// division and multiplication by 4 to ensure dimensions are multiples of 4
if ((cWidth / MAX_WIDTH) > (cHeight / MAX_HEIGHT)) {
tHeight = Math.ceil((MAX_WIDTH / (4* cWidth)) * cHeight) * 4;
tWidth = MAX_WIDTH;
} else {
tWidth = Math.ceil((MAX_HEIGHT / (4 * cHeight)) * cWidth) * 4;
tHeight = MAX_HEIGHT;
}
let constraints = {
video: {
mediaSource: "browser",
@ -313,10 +298,10 @@ function RemoteMirror(url, win, viewport, mirrorStartedCallback, contentWindow)
scrollWithPage: true,
advanced: [
{
width: { min: tWidth, max: tWidth },
height: { min: tHeight, max: tHeight }
width: { min: 0, max: MAX_WIDTH },
height: { min: 0, max: MAX_HEIGHT }
},
{ aspectRatio: cWidth / cHeight }
{ aspectRatio: MAX_WIDTH/MAX_HEIGHT }
]
}
};