document.getElementById('send-keys-menu')
);
+ /** @type {HTMLMediaElement} @private */
+ this.video_ = null;
+
/** @type {HTMLElement} @private */
this.resizeToClientButton_ =
document.getElementById('screen-resize-to-client');
FAILED: 5
};
+/**
+ * @param {string} state The state name.
+ * @return {remoting.ClientSession.State} The session state enum value.
+ */
+remoting.ClientSession.State.fromString = function(state) {
+ if (!remoting.ClientSession.State.hasOwnProperty(state)) {
+ throw "Invalid ClientSession.State: " + state;
+ }
+ return remoting.ClientSession.State[state];
+}
+
/** @enum {number} */
remoting.ClientSession.ConnectionError = {
UNKNOWN: -1,
HOST_OVERLOAD: 5
};
+/**
+ * @param {string} error The connection error name.
+ * @return {remoting.ClientSession.ConnectionError} The connection error enum.
+ */
+remoting.ClientSession.ConnectionError.fromString = function(error) {
+ if (!remoting.ClientSession.ConnectionError.hasOwnProperty(error)) {
+ console.error('Unexpected ClientSession.ConnectionError string: ', error);
+ return remoting.ClientSession.ConnectionError.UNKNOWN;
+ }
+ return remoting.ClientSession.ConnectionError[error];
+}
+
// The mode of this session.
/** @enum {number} */
remoting.ClientSession.Mode = {
/**
* @param {Element} container The element to add the plugin to.
* @param {string} id Id to use for the plugin element .
+ * @param {function(string, string):boolean} onExtensionMessage The handler for
+ * protocol extension messages. Returns true if a message is recognized;
+ * false otherwise.
* @return {remoting.ClientPlugin} Create plugin object for the locally
* installed plugin.
*/
-remoting.ClientSession.prototype.createClientPlugin_ = function(container, id) {
+remoting.ClientSession.prototype.createClientPlugin_ =
+ function(container, id, onExtensionMessage) {
var plugin = /** @type {remoting.ViewerPlugin} */
document.createElement('embed');
plugin.tabIndex = 0; // Required, otherwise focus() doesn't work.
container.appendChild(plugin);
- return new remoting.ClientPlugin(plugin);
+ return new remoting.ClientPlugin(plugin, onExtensionMessage);
};
/**
* Adds <embed> element to |container| and readies the sesion object.
*
* @param {Element} container The element to add the plugin to.
+ * @param {function(string, string):boolean} onExtensionMessage The handler for
+ * protocol extension messages. Returns true if a message is recognized;
+ * false otherwise.
*/
remoting.ClientSession.prototype.createPluginAndConnect =
- function(container) {
- this.plugin_ = this.createClientPlugin_(container, this.PLUGIN_ID);
+ function(container, onExtensionMessage) {
+ this.plugin_ = this.createClientPlugin_(container, this.PLUGIN_ID,
+ onExtensionMessage);
remoting.HostSettings.load(this.hostId_,
this.onHostSettingsLoaded_.bind(this));
};
this.applyRemapKeys_(true);
}
+ // Enable MediaSource-based rendering if available.
+ if (remoting.settings.USE_MEDIA_SOURCE_RENDERING &&
+ this.plugin_.hasFeature(
+ remoting.ClientPlugin.Feature.MEDIA_SOURCE_RENDERING)) {
+ this.video_ = /** @type {HTMLMediaElement} */(
+ document.getElementById('mediasource-video-output'));
+ // Make sure that the <video> element is hidden until we get the first
+ // frame.
+ this.video_.style.width = '0px';
+ this.video_.style.height = '0px';
+
+ var renderer = new remoting.MediaSourceRenderer(this.video_);
+ this.plugin_.enableMediaSourceRendering(renderer);
+ /** @type {HTMLElement} */(document.getElementById('video-container'))
+ .classList.add('mediasource-rendering');
+ } else {
+ /** @type {HTMLElement} */(document.getElementById('video-container'))
+ .classList.remove('mediasource-rendering');
+ }
+
/** @param {string} msg The IQ stanza to send. */
this.plugin_.onOutgoingIqHandler = this.sendIq_.bind(this);
/** @param {string} msg The message to log. */
// In case the user had selected full-screen mode, cancel it now.
document.webkitCancelFullScreen();
+
+ // Remove mediasource-rendering class from video-contained - this will also
+ // hide the <video> element.
+ /** @type {HTMLElement} */(document.getElementById('video-container'))
+ .classList.remove('mediasource-rendering');
};
/**
}
}
- var pluginWidth = desktopWidth * scale;
- var pluginHeight = desktopHeight * scale;
+ var pluginWidth = Math.round(desktopWidth * scale);
+ var pluginHeight = Math.round(desktopHeight * scale);
+
+ if (this.video_) {
+ this.video_.style.width = pluginWidth + 'px';
+ this.video_.style.height = pluginHeight + 'px';
+ }
// Resize the plugin if necessary.
// TODO(wez): Handle high-DPI to high-DPI properly (crbug.com/135089).
- this.plugin_.element().width = pluginWidth;
- this.plugin_.element().height = pluginHeight;
+ this.plugin_.element().style.width = pluginWidth + 'px';
+ this.plugin_.element().style.height = pluginHeight + 'px';
// Position the container.
// Note that clientWidth/Height take into account scrollbars.