From 5325efce80798feca0ccda01093f41fa4413abd4 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 9 Nov 2013 12:49:03 -0800 Subject: [PATCH 1/8] Bug 917583 - part 1: make function's definition site its own request in the RDP; r=past --- toolkit/devtools/client/dbg-client.jsm | 11 ++++ toolkit/devtools/server/actors/script.js | 48 ++++++++++++-- .../server/tests/unit/test_objectgrips-12.js | 66 +++++++++++++++++++ .../devtools/server/tests/unit/xpcshell.ini | 1 + 4 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 toolkit/devtools/server/tests/unit/test_objectgrips-12.js diff --git a/toolkit/devtools/client/dbg-client.jsm b/toolkit/devtools/client/dbg-client.jsm index 2cd71f8ef65..9ac9a8bfcae 100644 --- a/toolkit/devtools/client/dbg-client.jsm +++ b/toolkit/devtools/client/dbg-client.jsm @@ -1828,6 +1828,17 @@ ObjectClient.prototype = { get isSealed() this._grip.sealed, get isExtensible() this._grip.extensible, + getDefinitionSite: DebuggerClient.requester({ + type: "definitionSite" + }, { + before: function (aPacket) { + if (this._grip.class != "Function") { + throw new Error("getDefinitionSite is only valid for function grips."); + } + return aPacket; + } + }), + /** * Request the names of a function's formal parameters. * diff --git a/toolkit/devtools/server/actors/script.js b/toolkit/devtools/server/actors/script.js index 66b0d8efd9e..c7b82e140b8 100644 --- a/toolkit/devtools/server/actors/script.js +++ b/toolkit/devtools/server/actors/script.js @@ -2700,12 +2700,6 @@ ObjectActor.prototype = { // with "permission denied" errors for some functions. dumpn(e); } - - // Add source location information. - if (this.obj.script) { - g.url = this.obj.script.url; - g.line = this.obj.script.startLine; - } } return g; @@ -2742,6 +2736,47 @@ ObjectActor.prototype = { this._forcedMagicProps = true; }, + /** + * Handle a protocol request to provide the definition site of this function + * object. + * + * @param aRequest object + * The protocol request object. + */ + onDefinitionSite: function OA_onDefinitionSite(aRequest) { + if (this.obj.class != "Function") { + return { + error: "objectNotFunction", + message: this.actorID + " is not a function." + }; + } + + if (!this.obj.script) { + return { + from: this.actorID, + error: "noScript", + message: this.actorID + " has no Debugger.Script" + }; + } + + const generatedLocation = { + url: this.obj.script.url, + line: this.obj.script.startLine, + // TODO bug 901138: use Debugger.Script.prototype.startColumn. + column: 0 + }; + + return this.threadActor.sources.getOriginalLocation(generatedLocation) + .then(({ url, line, column }) => { + return { + from: this.actorID, + url: url, + line: line, + column: column + }; + }); + }, + /** * Handle a protocol request to provide the names of the properties defined on * the object and not its prototype. @@ -3074,6 +3109,7 @@ ObjectActor.prototype = { }; ObjectActor.prototype.requestTypes = { + "definitionSite": ObjectActor.prototype.onDefinitionSite, "parameterNames": ObjectActor.prototype.onParameterNames, "prototypeAndProperties": ObjectActor.prototype.onPrototypeAndProperties, "prototype": ObjectActor.prototype.onPrototype, diff --git a/toolkit/devtools/server/tests/unit/test_objectgrips-12.js b/toolkit/devtools/server/tests/unit/test_objectgrips-12.js new file mode 100644 index 00000000000..eabd77eac72 --- /dev/null +++ b/toolkit/devtools/server/tests/unit/test_objectgrips-12.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that ObjectClient.prototype.getDefinitionSite and the "definitionSite" +// request work properly. + +var gDebuggee; +var gClient; +var gThreadClient; + +function run_test() +{ + initTestDebuggerServer(); + gDebuggee = addTestGlobal("test-grips"); + gDebuggee.eval(function stopMe() { + debugger; + }.toString()); + + gClient = new DebuggerClient(DebuggerServer.connectPipe()); + gClient.connect(function() { + attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { + gThreadClient = aThreadClient; + add_pause_listener(); + }); + }); + do_test_pending(); +} + +function add_pause_listener() +{ + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { + const [funcGrip, objGrip] = aPacket.frame.arguments; + const func = gThreadClient.pauseGrip(funcGrip); + const obj = gThreadClient.pauseGrip(objGrip); + test_definition_site(func, obj); + }); + + eval_code(); +} + +function eval_code() { + gDebuggee.eval([ + "this.line0 = Error().lineNumber;", + "function f() {}", + "stopMe(f, {});" + ].join("\n")); +} + +function test_definition_site(func, obj) { + func.getDefinitionSite(({ error, url, line, column }) => { + do_check_true(!error); + do_check_eq(url, getFilePath("test_objectgrips-12.js")); + do_check_eq(line, gDebuggee.line0 + 1); + do_check_eq(column, 0); + + test_bad_definition_site(obj); + }); +} + +function test_bad_definition_site(obj) { + try { + obj.getDefinitionSite(() => do_check_true(false)); + } catch (e) { + gThreadClient.resume(() => finishClient(gClient)); + } +} diff --git a/toolkit/devtools/server/tests/unit/xpcshell.ini b/toolkit/devtools/server/tests/unit/xpcshell.ini index 3fd568e7012..4ec229176ca 100644 --- a/toolkit/devtools/server/tests/unit/xpcshell.ini +++ b/toolkit/devtools/server/tests/unit/xpcshell.ini @@ -147,6 +147,7 @@ reason = bug 820380 [test_objectgrips-09.js] [test_objectgrips-10.js] [test_objectgrips-11.js] +[test_objectgrips-12.js] [test_interrupt.js] [test_stepping-01.js] [test_stepping-02.js] From 4834c387ce11a73ab1708972d5e550d82e4379c0 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 9 Nov 2013 12:49:03 -0800 Subject: [PATCH 2/8] Bug 917583 - part 2: request definitionSite before adding listeners to the view; r=vporof --- .../devtools/debugger/debugger-controller.js | 47 +++++++++++++------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/browser/devtools/debugger/debugger-controller.js b/browser/devtools/debugger/debugger-controller.js index f6ca29d0d5f..0b70fd9a677 100644 --- a/browser/devtools/debugger/debugger-controller.js +++ b/browser/devtools/debugger/debugger-controller.js @@ -1398,12 +1398,36 @@ EventListeners.prototype = { */ scheduleEventListenersFetch: function() { let getListeners = aCallback => gThreadClient.eventListeners(aResponse => { - this._onEventListeners(aResponse); + if (aResponse.error) { + let msg = "Error getting event listeners: " + aResponse.message; + DevToolsUtils.reportException("scheduleEventListenersFetch", msg); + return; + } - // Notify that event listeners were fetched and shown in the view, - // and callback to resume the active thread if necessary. - window.emit(EVENTS.EVENT_LISTENERS_FETCHED); - aCallback && aCallback(); + promise.all(aResponse.listeners.map(listener => { + const deferred = promise.defer(); + + gThreadClient.pauseGrip(listener.function).getDefinitionSite(aResponse => { + if (aResponse.error) { + const msg = "Error getting function definition site: " + aResponse.message; + DevToolsUtils.reportException("scheduleEventListenersFetch", msg); + deferred.reject(msg); + return; + } + + listener.function.url = aResponse.url; + deferred.resolve(listener); + }); + + return deferred.promise; + })).then(listeners => { + this._onEventListeners(listeners); + + // Notify that event listeners were fetched and shown in the view, + // and callback to resume the active thread if necessary. + window.emit(EVENTS.EVENT_LISTENERS_FETCHED); + aCallback && aCallback(); + }); }); // Make sure we're not sending a batch of closely repeated requests. @@ -1418,18 +1442,11 @@ EventListeners.prototype = { }, /** - * Callback for the debugger's active thread eventListeners() method. + * Callback for a debugger's successful active thread eventListeners() call. */ - _onEventListeners: function(aResponse) { - if (aResponse.error) { - let msg = "Error getting event listeners: " + aResponse.message; - Cu.reportError(msg); - dumpn(msg); - return; - } - + _onEventListeners: function(aListeners) { // Add all the listeners in the debugger view event linsteners container. - for (let listener of aResponse.listeners) { + for (let listener of aListeners) { DebuggerView.EventListeners.addListener(listener, { staged: true }); } From 3b7de1f0353114b0237a51f5d0d883e37704365c Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Sat, 9 Nov 2013 23:26:47 -0800 Subject: [PATCH 3/8] Back out 854623def9c6:a976c1645d70 (bug 917583) for Linux/Windows bc bustage CLOSED TREE --- .../devtools/debugger/debugger-controller.js | 47 +++++-------- toolkit/devtools/client/dbg-client.jsm | 11 ---- toolkit/devtools/server/actors/script.js | 48 ++------------ .../server/tests/unit/test_objectgrips-12.js | 66 ------------------- .../devtools/server/tests/unit/xpcshell.ini | 1 - 5 files changed, 21 insertions(+), 152 deletions(-) delete mode 100644 toolkit/devtools/server/tests/unit/test_objectgrips-12.js diff --git a/browser/devtools/debugger/debugger-controller.js b/browser/devtools/debugger/debugger-controller.js index 0b70fd9a677..f6ca29d0d5f 100644 --- a/browser/devtools/debugger/debugger-controller.js +++ b/browser/devtools/debugger/debugger-controller.js @@ -1398,36 +1398,12 @@ EventListeners.prototype = { */ scheduleEventListenersFetch: function() { let getListeners = aCallback => gThreadClient.eventListeners(aResponse => { - if (aResponse.error) { - let msg = "Error getting event listeners: " + aResponse.message; - DevToolsUtils.reportException("scheduleEventListenersFetch", msg); - return; - } + this._onEventListeners(aResponse); - promise.all(aResponse.listeners.map(listener => { - const deferred = promise.defer(); - - gThreadClient.pauseGrip(listener.function).getDefinitionSite(aResponse => { - if (aResponse.error) { - const msg = "Error getting function definition site: " + aResponse.message; - DevToolsUtils.reportException("scheduleEventListenersFetch", msg); - deferred.reject(msg); - return; - } - - listener.function.url = aResponse.url; - deferred.resolve(listener); - }); - - return deferred.promise; - })).then(listeners => { - this._onEventListeners(listeners); - - // Notify that event listeners were fetched and shown in the view, - // and callback to resume the active thread if necessary. - window.emit(EVENTS.EVENT_LISTENERS_FETCHED); - aCallback && aCallback(); - }); + // Notify that event listeners were fetched and shown in the view, + // and callback to resume the active thread if necessary. + window.emit(EVENTS.EVENT_LISTENERS_FETCHED); + aCallback && aCallback(); }); // Make sure we're not sending a batch of closely repeated requests. @@ -1442,11 +1418,18 @@ EventListeners.prototype = { }, /** - * Callback for a debugger's successful active thread eventListeners() call. + * Callback for the debugger's active thread eventListeners() method. */ - _onEventListeners: function(aListeners) { + _onEventListeners: function(aResponse) { + if (aResponse.error) { + let msg = "Error getting event listeners: " + aResponse.message; + Cu.reportError(msg); + dumpn(msg); + return; + } + // Add all the listeners in the debugger view event linsteners container. - for (let listener of aListeners) { + for (let listener of aResponse.listeners) { DebuggerView.EventListeners.addListener(listener, { staged: true }); } diff --git a/toolkit/devtools/client/dbg-client.jsm b/toolkit/devtools/client/dbg-client.jsm index 9ac9a8bfcae..2cd71f8ef65 100644 --- a/toolkit/devtools/client/dbg-client.jsm +++ b/toolkit/devtools/client/dbg-client.jsm @@ -1828,17 +1828,6 @@ ObjectClient.prototype = { get isSealed() this._grip.sealed, get isExtensible() this._grip.extensible, - getDefinitionSite: DebuggerClient.requester({ - type: "definitionSite" - }, { - before: function (aPacket) { - if (this._grip.class != "Function") { - throw new Error("getDefinitionSite is only valid for function grips."); - } - return aPacket; - } - }), - /** * Request the names of a function's formal parameters. * diff --git a/toolkit/devtools/server/actors/script.js b/toolkit/devtools/server/actors/script.js index c7b82e140b8..66b0d8efd9e 100644 --- a/toolkit/devtools/server/actors/script.js +++ b/toolkit/devtools/server/actors/script.js @@ -2700,6 +2700,12 @@ ObjectActor.prototype = { // with "permission denied" errors for some functions. dumpn(e); } + + // Add source location information. + if (this.obj.script) { + g.url = this.obj.script.url; + g.line = this.obj.script.startLine; + } } return g; @@ -2736,47 +2742,6 @@ ObjectActor.prototype = { this._forcedMagicProps = true; }, - /** - * Handle a protocol request to provide the definition site of this function - * object. - * - * @param aRequest object - * The protocol request object. - */ - onDefinitionSite: function OA_onDefinitionSite(aRequest) { - if (this.obj.class != "Function") { - return { - error: "objectNotFunction", - message: this.actorID + " is not a function." - }; - } - - if (!this.obj.script) { - return { - from: this.actorID, - error: "noScript", - message: this.actorID + " has no Debugger.Script" - }; - } - - const generatedLocation = { - url: this.obj.script.url, - line: this.obj.script.startLine, - // TODO bug 901138: use Debugger.Script.prototype.startColumn. - column: 0 - }; - - return this.threadActor.sources.getOriginalLocation(generatedLocation) - .then(({ url, line, column }) => { - return { - from: this.actorID, - url: url, - line: line, - column: column - }; - }); - }, - /** * Handle a protocol request to provide the names of the properties defined on * the object and not its prototype. @@ -3109,7 +3074,6 @@ ObjectActor.prototype = { }; ObjectActor.prototype.requestTypes = { - "definitionSite": ObjectActor.prototype.onDefinitionSite, "parameterNames": ObjectActor.prototype.onParameterNames, "prototypeAndProperties": ObjectActor.prototype.onPrototypeAndProperties, "prototype": ObjectActor.prototype.onPrototype, diff --git a/toolkit/devtools/server/tests/unit/test_objectgrips-12.js b/toolkit/devtools/server/tests/unit/test_objectgrips-12.js deleted file mode 100644 index eabd77eac72..00000000000 --- a/toolkit/devtools/server/tests/unit/test_objectgrips-12.js +++ /dev/null @@ -1,66 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Test that ObjectClient.prototype.getDefinitionSite and the "definitionSite" -// request work properly. - -var gDebuggee; -var gClient; -var gThreadClient; - -function run_test() -{ - initTestDebuggerServer(); - gDebuggee = addTestGlobal("test-grips"); - gDebuggee.eval(function stopMe() { - debugger; - }.toString()); - - gClient = new DebuggerClient(DebuggerServer.connectPipe()); - gClient.connect(function() { - attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - add_pause_listener(); - }); - }); - do_test_pending(); -} - -function add_pause_listener() -{ - gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { - const [funcGrip, objGrip] = aPacket.frame.arguments; - const func = gThreadClient.pauseGrip(funcGrip); - const obj = gThreadClient.pauseGrip(objGrip); - test_definition_site(func, obj); - }); - - eval_code(); -} - -function eval_code() { - gDebuggee.eval([ - "this.line0 = Error().lineNumber;", - "function f() {}", - "stopMe(f, {});" - ].join("\n")); -} - -function test_definition_site(func, obj) { - func.getDefinitionSite(({ error, url, line, column }) => { - do_check_true(!error); - do_check_eq(url, getFilePath("test_objectgrips-12.js")); - do_check_eq(line, gDebuggee.line0 + 1); - do_check_eq(column, 0); - - test_bad_definition_site(obj); - }); -} - -function test_bad_definition_site(obj) { - try { - obj.getDefinitionSite(() => do_check_true(false)); - } catch (e) { - gThreadClient.resume(() => finishClient(gClient)); - } -} diff --git a/toolkit/devtools/server/tests/unit/xpcshell.ini b/toolkit/devtools/server/tests/unit/xpcshell.ini index 4ec229176ca..3fd568e7012 100644 --- a/toolkit/devtools/server/tests/unit/xpcshell.ini +++ b/toolkit/devtools/server/tests/unit/xpcshell.ini @@ -147,7 +147,6 @@ reason = bug 820380 [test_objectgrips-09.js] [test_objectgrips-10.js] [test_objectgrips-11.js] -[test_objectgrips-12.js] [test_interrupt.js] [test_stepping-01.js] [test_stepping-02.js] From 73521ac811b5f99d65c5d17b1a32626e94cfcfee Mon Sep 17 00:00:00 2001 From: Mihai Sucan Date: Sat, 9 Nov 2013 20:09:36 +0200 Subject: [PATCH 4/8] Bug 934852 - Fix for intermittent browser_scratchpad_throw_output.js | Test timed out; r=me --- .../test/browser_scratchpad_throw_output.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js b/browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js index 85daeb5e061..ba26151dc33 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_throw_output.js @@ -2,8 +2,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -let temp = {}; -Cu.import("resource://gre/modules/devtools/dbg-server.jsm", temp); function test() { @@ -33,14 +31,19 @@ function testThrowOutput() }); }); - let longString = Array(temp.DebuggerServer.LONG_STRING_LENGTH + 1).join("a"), - shortedString = longString.substring(0, - temp.DebuggerServer.LONG_STRING_INITIAL_LENGTH - ) + "\u2026"; + let server = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}) + .DebuggerServer; + + let longLength = server.LONG_STRING_LENGTH + 1; + let longString = new Array(longLength).join("a"); + let shortedString = longString.substring(0, server.LONG_STRING_INITIAL_LENGTH) + + "\u2026"; + tests.push({ method: "display", - code: "throw '" + longString + "';", - result: "throw '" + longString + "';\n/*\nException: " + shortedString + "\n*/", + code: "throw (new Array(" + longLength + ").join('a'));", + result: "throw (new Array(" + longLength + ").join('a'));\n" + + "/*\nException: " + shortedString + "\n*/", label: "Correct exception message for a longString is shown" }); From 35960eba2821ffcaa2aa97c0f74c0e7a770b66bc Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Sun, 10 Nov 2013 18:53:03 +0100 Subject: [PATCH 5/8] Bug 936911 - Export TabState.onSwapDocShells() in TabState.jsm r=billm From adcf642ed40bccc0b6fed3232bcc733228d7b7da Mon Sep 17 00:00:00 2001 --- .../components/sessionstore/src/TabState.jsm | 4 ++ .../components/sessionstore/test/browser.ini | 1 + .../test/browser_swapDocShells.js | 39 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 browser/components/sessionstore/test/browser_swapDocShells.js diff --git a/browser/components/sessionstore/src/TabState.jsm b/browser/components/sessionstore/src/TabState.jsm index 11a9a972018..63934f4b1a9 100644 --- a/browser/components/sessionstore/src/TabState.jsm +++ b/browser/components/sessionstore/src/TabState.jsm @@ -27,6 +27,10 @@ this.TabState = Object.freeze({ TabStateInternal.setSyncHandler(browser, handler); }, + onSwapDocShells: function (browser, otherBrowser) { + TabStateInternal.onSwapDocShells(browser, otherBrowser); + }, + collect: function (tab) { return TabStateInternal.collect(tab); }, diff --git a/browser/components/sessionstore/test/browser.ini b/browser/components/sessionstore/test/browser.ini index 2259f467a89..9f88928523e 100644 --- a/browser/components/sessionstore/test/browser.ini +++ b/browser/components/sessionstore/test/browser.ini @@ -54,6 +54,7 @@ support-files = [browser_input.js] [browser_pageshow.js] [browser_sessionStorage.js] +[browser_swapDocShells.js] [browser_tabStateCache.js] [browser_upgrade_backup.js] [browser_windowRestore_perwindowpb.js] diff --git a/browser/components/sessionstore/test/browser_swapDocShells.js b/browser/components/sessionstore/test/browser_swapDocShells.js new file mode 100644 index 00000000000..e81cd51eeb4 --- /dev/null +++ b/browser/components/sessionstore/test/browser_swapDocShells.js @@ -0,0 +1,39 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + waitForExplicitFinish(); + + Task.spawn(function task() { + let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla"); + yield promiseBrowserLoaded(gBrowser.selectedBrowser); + + let win = gBrowser.replaceTabWithWindow(tab); + yield promiseDelayedStartupFinished(win); + yield promiseBrowserHasURL(win.gBrowser.browsers[0], "about:mozilla"); + + win.duplicateTabIn(win.gBrowser.selectedTab, "tab"); + let browser = win.gBrowser.browsers[1]; + yield promiseBrowserLoaded(browser); + is(browser.currentURI.spec, "about:mozilla", "tab was duplicated"); + + win.close(); + }).then(finish); +} + +function promiseDelayedStartupFinished(win) { + let deferred = Promise.defer(); + whenDelayedStartupFinished(win, deferred.resolve); + return deferred.promise; +} + +function promiseBrowserHasURL(browser, url) { + let promise = Promise.resolve(); + + if (browser.contentDocument.readyState === "complete" && + browser.currentURI.spec === url) { + return promise; + } + + return promise.then(() => promiseBrowserHasURL(browser, url)); +} From a7d9da507a63b63ab3298442b1bc4904a40bcd1c Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Sat, 2 Nov 2013 16:56:26 +0100 Subject: [PATCH 6/8] Bug 934206 - Disable browser_248970_b_perwindowpb.js for leaking r=ehsan From 77547f79a335d3e84c717ea8757f59f06007900b Mon Sep 17 00:00:00 2001 --- browser/components/sessionstore/test/browser.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/browser/components/sessionstore/test/browser.ini b/browser/components/sessionstore/test/browser.ini index 9f88928523e..d3461a524f9 100644 --- a/browser/components/sessionstore/test/browser.ini +++ b/browser/components/sessionstore/test/browser.ini @@ -59,6 +59,9 @@ support-files = [browser_upgrade_backup.js] [browser_windowRestore_perwindowpb.js] [browser_248970_b_perwindowpb.js] +# Disabled because of leaks. +# Re-enabling and rewriting this test is tracked in bug 936919. +skip-if = true [browser_339445.js] [browser_345898.js] [browser_346337.js] From 7ee547334b2b3c41857a45219e2cc1b13c65315e Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Sun, 10 Nov 2013 16:24:37 -0500 Subject: [PATCH 7/8] bug 936549 - Tab sharing capture device won't stream, add rgb image support to media pipeline r=jesup --- media/webrtc/signaling/signaling.gyp | 1 + .../src/mediapipeline/MediaPipeline.cpp | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/media/webrtc/signaling/signaling.gyp b/media/webrtc/signaling/signaling.gyp index 618bf04693d..349dd2e5299 100644 --- a/media/webrtc/signaling/signaling.gyp +++ b/media/webrtc/signaling/signaling.gyp @@ -61,6 +61,7 @@ '../trunk/webrtc/voice_engine/include', '../trunk/webrtc/modules/interface', '../trunk/webrtc/peerconnection', + '../trunk/third_party/libyuv/include/', '../../../netwerk/srtp/src/include', '../../../netwerk/srtp/src/crypto/include', '../../../ipc/chromium/src', diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 68e579fd999..e589715eca6 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -37,6 +37,8 @@ #include "transportlayerdtls.h" #include "transportlayerice.h" #include "runnable_utils.h" +#include "gfxImageSurface.h" +#include "libyuv/convert.h" using namespace mozilla; @@ -922,6 +924,48 @@ void MediaPipelineTransmit::PipelineListener::ProcessVideoChunk( MOZ_MTLOG(ML_DEBUG, "Sending a video frame"); // Not much for us to do with an error conduit->SendVideoFrame(y, length, width, height, mozilla::kVideoI420, 0); + } else if(format == CAIRO_SURFACE) { + layers::CairoImage* rgb = + const_cast( + static_cast(img)); + + gfxIntSize size = rgb->GetSize(); + int half_width = (size.width + 1) >> 1; + int half_height = (size.height + 1) >> 1; + int c_size = half_width * half_height; + int buffer_size = size.width * size.height + 2 * c_size; + uint8* yuv = (uint8*) malloc(buffer_size); + if (!yuv) + return; + + int cb_offset = size.width * size.height; + int cr_offset = cb_offset + c_size; + nsRefPtr surf = rgb->mSurface->GetAsImageSurface(); + + switch (surf->Format()) { + case gfxImageFormatARGB32: + case gfxImageFormatRGB24: + libyuv::ARGBToI420(static_cast(surf->Data()), surf->Stride(), + yuv, size.width, + yuv + cb_offset, half_width, + yuv + cr_offset, half_width, + size.width, size.height); + break; + case gfxImageFormatRGB16_565: + libyuv::RGB565ToI420(static_cast(surf->Data()), surf->Stride(), + yuv, size.width, + yuv + cb_offset, half_width, + yuv + cr_offset, half_width, + size.width, size.height); + break; + case gfxImageFormatA1: + case gfxImageFormatA8: + case gfxImageFormatUnknown: + default: + MOZ_MTLOG(ML_ERROR, "Unsupported RGB video format"); + MOZ_ASSERT(PR_FALSE); + } + conduit->SendVideoFrame(yuv, buffer_size, size.width, size.height, mozilla::kVideoI420, 0); } else { MOZ_MTLOG(ML_ERROR, "Unsupported video format"); MOZ_ASSERT(PR_FALSE); From 2f86f92c0f9826ed601fdf99f5dd66bcd2665170 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Fri, 8 Nov 2013 13:26:20 -0500 Subject: [PATCH 8/8] bug 936549 - Tab sharing capture device won't stream, use FormatStrideForWidth in tab stream r=jesup --- content/media/webrtc/MediaEngineTabVideoSource.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/media/webrtc/MediaEngineTabVideoSource.cpp b/content/media/webrtc/MediaEngineTabVideoSource.cpp index 01eef2c6491..a73cf2c9ed9 100644 --- a/content/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/content/media/webrtc/MediaEngineTabVideoSource.cpp @@ -235,12 +235,13 @@ MediaEngineTabVideoSource::Draw() { nsPresContext::CSSPixelsToAppUnits(srcW / scale), nsPresContext::CSSPixelsToAppUnits(srcH / scale)); - uint32_t stride = size.width * 4; + gfxImageFormat format = gfxImageFormatRGB24; + uint32_t stride = gfxASurface::FormatStrideForWidth(format, size.width); nsRefPtr container = layers::LayerManager::CreateImageContainer(); nsRefPtr surf; surf = new gfxImageSurface(static_cast(mData), size, - stride, gfxImageFormatRGB24); + stride, format); if (surf->CairoStatus() != 0) { return; }