Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: remoting/webapp/crd/js/client_session.js

Issue 825793002: Remove MediaStream renderer from the webapp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 * properly handle mouse lock and delegated large cursors at the same time. 44 * properly handle mouse lock and delegated large cursors at the same time.
45 * This should be re-enabled (by removing this flag) once a version of 45 * This should be re-enabled (by removing this flag) once a version of
46 * the plugin that supports both has reached Chrome Stable channel. 46 * the plugin that supports both has reached Chrome Stable channel.
47 * (crbug.com/429322). 47 * (crbug.com/429322).
48 * 48 *
49 * @type {boolean} 49 * @type {boolean}
50 */ 50 */
51 remoting.enableMouseLock = false; 51 remoting.enableMouseLock = false;
52 52
53 /** 53 /**
54 * True to enable MediaSource rendering, if available.
55 * The plugin also needs to support MediaSource rendering.
56 *
57 * TODO(sergeyu): Remove mediaSource renderer from the plugin and
58 * everywhere else.
59 *
60 * @type {boolean}
61 */
62 remoting.enableMediaSourceRendering = false;
63
64 /**
65 * @param {remoting.SignalStrategy} signalStrategy Signal strategy. 54 * @param {remoting.SignalStrategy} signalStrategy Signal strategy.
66 * @param {HTMLElement} container Container element for the client view. 55 * @param {HTMLElement} container Container element for the client view.
67 * @param {string} hostDisplayName A human-readable name for the host. 56 * @param {string} hostDisplayName A human-readable name for the host.
68 * @param {string} accessCode The IT2Me access code. Blank for Me2Me. 57 * @param {string} accessCode The IT2Me access code. Blank for Me2Me.
69 * @param {function(boolean, function(string): void): void} fetchPin 58 * @param {function(boolean, function(string): void): void} fetchPin
70 * Called by Me2Me connections when a PIN needs to be obtained 59 * Called by Me2Me connections when a PIN needs to be obtained
71 * interactively. 60 * interactively.
72 * @param {function(string, string, string, 61 * @param {function(string, string, string,
73 * function(string, string): void): void} 62 * function(string, string): void): void}
74 * fetchThirdPartyToken Called by Me2Me connections when a third party 63 * fetchThirdPartyToken Called by Me2Me connections when a third party
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 */ 165 */
177 this.logHostOfflineErrors_ = true; 166 this.logHostOfflineErrors_ = true;
178 167
179 /** @private */ 168 /** @private */
180 this.callPluginLostFocus_ = this.pluginLostFocus_.bind(this); 169 this.callPluginLostFocus_ = this.pluginLostFocus_.bind(this);
181 /** @private */ 170 /** @private */
182 this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this); 171 this.callPluginGotFocus_ = this.pluginGotFocus_.bind(this);
183 /** @private */ 172 /** @private */
184 this.callOnFullScreenChanged_ = this.onFullScreenChanged_.bind(this) 173 this.callOnFullScreenChanged_ = this.onFullScreenChanged_.bind(this)
185 174
186 /** @type {HTMLMediaElement} @private */
187 this.video_ = null;
188
189 /** @type {Element} @private */ 175 /** @type {Element} @private */
190 this.mouseCursorOverlay_ = 176 this.mouseCursorOverlay_ =
191 this.container_.querySelector('.mouse-cursor-overlay'); 177 this.container_.querySelector('.mouse-cursor-overlay');
192 178
193 /** @type {Element} */ 179 /** @type {Element} */
194 var img = this.mouseCursorOverlay_; 180 var img = this.mouseCursorOverlay_;
195 /** @param {Event} event @private */ 181 /** @param {Event} event @private */
196 this.updateMouseCursorPosition_ = function(event) { 182 this.updateMouseCursorPosition_ = function(event) {
197 img.style.top = event.y + 'px'; 183 img.style.top = event.y + 'px';
198 img.style.left = event.x + 'px'; 184 img.style.left = event.x + 'px';
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 this.applyRemapKeys_(true); 562 this.applyRemapKeys_(true);
577 } 563 }
578 564
579 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission. 565 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission.
580 // Enable automatic mouse-lock. 566 // Enable automatic mouse-lock.
581 if (remoting.enableMouseLock && 567 if (remoting.enableMouseLock &&
582 this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) { 568 this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) {
583 this.plugin_.allowMouseLock(); 569 this.plugin_.allowMouseLock();
584 } 570 }
585 571
586 // MediaSource-based rendering is only supported on Chrome 37 and above.
587 var chromeVersionMajor =
588 parseInt((remoting.getChromeVersion() || '0').split('.')[0], 10);
589 if (chromeVersionMajor >= 37 &&
590 remoting.enableMediaSourceRendering &&
591 this.plugin_.hasFeature(
592 remoting.ClientPlugin.Feature.MEDIA_SOURCE_RENDERING)) {
593 this.video_ = /** @type {HTMLMediaElement} */(
594 this.container_.querySelector('video'));
595 // Make sure that the <video> element is hidden until we get the first
596 // frame.
597 this.video_.style.width = '0px';
598 this.video_.style.height = '0px';
599
600 var renderer = new remoting.MediaSourceRenderer(this.video_);
601 this.plugin_.enableMediaSourceRendering(renderer);
602 this.container_.classList.add('mediasource-rendering');
603 } else {
604 this.container_.classList.remove('mediasource-rendering');
605 }
606
607 this.plugin_.setOnOutgoingIqHandler(this.sendIq_.bind(this)); 572 this.plugin_.setOnOutgoingIqHandler(this.sendIq_.bind(this));
608 this.plugin_.setOnDebugMessageHandler(this.onDebugMessage_.bind(this)); 573 this.plugin_.setOnDebugMessageHandler(this.onDebugMessage_.bind(this));
609 574
610 this.plugin_.setConnectionStatusUpdateHandler( 575 this.plugin_.setConnectionStatusUpdateHandler(
611 this.onConnectionStatusUpdate_.bind(this)); 576 this.onConnectionStatusUpdate_.bind(this));
612 this.plugin_.setRouteChangedHandler(this.onRouteChanged_.bind(this)); 577 this.plugin_.setRouteChangedHandler(this.onRouteChanged_.bind(this));
613 this.plugin_.setConnectionReadyHandler(this.onConnectionReady_.bind(this)); 578 this.plugin_.setConnectionReadyHandler(this.onConnectionReady_.bind(this));
614 this.plugin_.setDesktopShapeUpdateHandler( 579 this.plugin_.setDesktopShapeUpdateHandler(
615 this.onDesktopShapeChanged_.bind(this)); 580 this.onDesktopShapeChanged_.bind(this));
616 this.plugin_.setDesktopSizeUpdateHandler( 581 this.plugin_.setDesktopSizeUpdateHandler(
(...skipping 26 matching lines...) Expand all
643 608
644 // Leave full-screen mode, and stop listening for related events. 609 // Leave full-screen mode, and stop listening for related events.
645 var listener = this.callOnFullScreenChanged_; 610 var listener = this.callOnFullScreenChanged_;
646 remoting.fullscreen.activate( 611 remoting.fullscreen.activate(
647 false, 612 false,
648 function() { 613 function() {
649 remoting.fullscreen.removeListener(listener); 614 remoting.fullscreen.removeListener(listener);
650 }); 615 });
651 this.updateClientSessionUi_(null); 616 this.updateClientSessionUi_(null);
652 617
653 // Remove mediasource-rendering class from the container - this will also
654 // hide the <video> element.
655 this.container_.classList.remove('mediasource-rendering');
656
657 this.container_.removeEventListener('mousemove', 618 this.container_.removeEventListener('mousemove',
658 this.updateMouseCursorPosition_, 619 this.updateMouseCursorPosition_,
659 true); 620 true);
660 }; 621 };
661 622
662 /** 623 /**
663 * @param {remoting.ClientSession} clientSession The active session, or null if 624 * @param {remoting.ClientSession} clientSession The active session, or null if
664 * there is no connection. 625 * there is no connection.
665 */ 626 */
666 remoting.ClientSession.prototype.updateClientSessionUi_ = function( 627 remoting.ClientSession.prototype.updateClientSessionUi_ = function(
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 } 1299 }
1339 if (scale <= scaleFitWidth * 0.65) { 1300 if (scale <= scaleFitWidth * 0.65) {
1340 scale = scaleFitWidth; 1301 scale = scaleFitWidth;
1341 } 1302 }
1342 } 1303 }
1343 } 1304 }
1344 1305
1345 var pluginWidth = Math.round(desktopWidth * scale); 1306 var pluginWidth = Math.round(desktopWidth * scale);
1346 var pluginHeight = Math.round(desktopHeight * scale); 1307 var pluginHeight = Math.round(desktopHeight * scale);
1347 1308
1348 if (this.video_) {
1349 this.video_.style.width = pluginWidth + 'px';
1350 this.video_.style.height = pluginHeight + 'px';
1351 }
1352
1353 // Resize the plugin if necessary. 1309 // Resize the plugin if necessary.
1354 // TODO(wez): Handle high-DPI to high-DPI properly (crbug.com/135089). 1310 // TODO(wez): Handle high-DPI to high-DPI properly (crbug.com/135089).
1355 this.plugin_.element().style.width = pluginWidth + 'px'; 1311 this.plugin_.element().style.width = pluginWidth + 'px';
1356 this.plugin_.element().style.height = pluginHeight + 'px'; 1312 this.plugin_.element().style.height = pluginHeight + 'px';
1357 1313
1358 // Position the container. 1314 // Position the container.
1359 // Note that clientWidth/Height take into account scrollbars. 1315 // Note that clientWidth/Height take into account scrollbars.
1360 var clientWidth = document.documentElement.clientWidth; 1316 var clientWidth = document.documentElement.clientWidth;
1361 var clientHeight = document.documentElement.clientHeight; 1317 var clientHeight = document.documentElement.clientHeight;
1362 var parentNode = this.plugin_.element().parentNode; 1318 var parentNode = this.plugin_.element().parentNode;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 * @param {string} data Contents of the extension message. 1724 * @param {string} data Contents of the extension message.
1769 * @return {boolean} True if the message was recognized, false otherwise. 1725 * @return {boolean} True if the message was recognized, false otherwise.
1770 */ 1726 */
1771 remoting.ClientSession.prototype.handleExtensionMessage = 1727 remoting.ClientSession.prototype.handleExtensionMessage =
1772 function(type, data) { 1728 function(type, data) {
1773 if (this.videoFrameRecorder_) { 1729 if (this.videoFrameRecorder_) {
1774 return this.videoFrameRecorder_.handleMessage(type, data); 1730 return this.videoFrameRecorder_.handleMessage(type, data);
1775 } 1731 }
1776 return false; 1732 return false;
1777 } 1733 }
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/client_plugin_impl.js ('k') | remoting/webapp/crd/js/media_source_renderer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698