| OLD | NEW |
| 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 that wraps low-level details of interacting with the client plugin. | 7 * Class that wraps low-level details of interacting with the client plugin. |
| 8 * | 8 * |
| 9 * This abstracts a <embed> element and controls the plugin which does | 9 * This abstracts a <embed> element and controls the plugin which does |
| 10 * the actual remoting work. It also handles differences between | 10 * the actual remoting work. It also handles differences between |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 */ | 113 */ |
| 114 this.updateMouseCursorImage_ = function(url, hotspotX, hotspotY) {}; | 114 this.updateMouseCursorImage_ = function(url, hotspotX, hotspotY) {}; |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * @param {string} data Remote cast extension message. | 117 * @param {string} data Remote cast extension message. |
| 118 * @private | 118 * @private |
| 119 */ | 119 */ |
| 120 this.onCastExtensionHandler_ = function(data) {}; | 120 this.onCastExtensionHandler_ = function(data) {}; |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * @type {remoting.MediaSourceRenderer} | |
| 124 * @private | |
| 125 */ | |
| 126 this.mediaSourceRenderer_ = null; | |
| 127 | |
| 128 /** | |
| 129 * @type {number} | 123 * @type {number} |
| 130 * @private | 124 * @private |
| 131 */ | 125 */ |
| 132 this.pluginApiVersion_ = -1; | 126 this.pluginApiVersion_ = -1; |
| 133 /** | 127 /** |
| 134 * @type {Array.<string>} | 128 * @type {Array.<string>} |
| 135 * @private | 129 * @private |
| 136 */ | 130 */ |
| 137 this.pluginApiFeatures_ = []; | 131 this.pluginApiFeatures_ = []; |
| 138 /** | 132 /** |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 console.log('Got echo reply: ' + extMsgData); | 496 console.log('Got echo reply: ' + extMsgData); |
| 503 break; | 497 break; |
| 504 case 'cast_message': | 498 case 'cast_message': |
| 505 this.onCastExtensionHandler_(extMsgData); | 499 this.onCastExtensionHandler_(extMsgData); |
| 506 break; | 500 break; |
| 507 default: | 501 default: |
| 508 this.onExtensionMessage_(extMsgType, extMsgData); | 502 this.onExtensionMessage_(extMsgType, extMsgData); |
| 509 break; | 503 break; |
| 510 } | 504 } |
| 511 | 505 |
| 512 } else if (message.method == 'mediaSourceReset') { | |
| 513 if (!this.mediaSourceRenderer_) { | |
| 514 console.error('Unexpected mediaSourceReset.'); | |
| 515 return; | |
| 516 } | |
| 517 this.mediaSourceRenderer_.reset(getStringAttr(message.data, 'format')) | |
| 518 | |
| 519 } else if (message.method == 'mediaSourceData') { | |
| 520 if (!(message.data['buffer'] instanceof ArrayBuffer)) { | |
| 521 console.error('Invalid mediaSourceData message:', message.data); | |
| 522 return; | |
| 523 } | |
| 524 if (!this.mediaSourceRenderer_) { | |
| 525 console.error('Unexpected mediaSourceData.'); | |
| 526 return; | |
| 527 } | |
| 528 // keyframe flag may be absent from the message. | |
| 529 var keyframe = !!message.data['keyframe']; | |
| 530 this.mediaSourceRenderer_.onIncomingData( | |
| 531 (/** @type {ArrayBuffer} */ message.data['buffer']), keyframe); | |
| 532 | |
| 533 } else if (message.method == 'unsetCursorShape') { | 506 } else if (message.method == 'unsetCursorShape') { |
| 534 this.updateMouseCursorImage_('', 0, 0); | 507 this.updateMouseCursorImage_('', 0, 0); |
| 535 | 508 |
| 536 } else if (message.method == 'setCursorShape') { | 509 } else if (message.method == 'setCursorShape') { |
| 537 var width = getNumberAttr(message.data, 'width'); | 510 var width = getNumberAttr(message.data, 'width'); |
| 538 var height = getNumberAttr(message.data, 'height'); | 511 var height = getNumberAttr(message.data, 'height'); |
| 539 var hotspotX = getNumberAttr(message.data, 'hotspotX'); | 512 var hotspotX = getNumberAttr(message.data, 'hotspotX'); |
| 540 var hotspotY = getNumberAttr(message.data, 'hotspotY'); | 513 var hotspotY = getNumberAttr(message.data, 'hotspotY'); |
| 541 var srcArrayBuffer = getObjectAttr(message.data, 'data'); | 514 var srcArrayBuffer = getObjectAttr(message.data, 'data'); |
| 542 | 515 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 function(type, message) { | 883 function(type, message) { |
| 911 if (!this.hasFeature(remoting.ClientPlugin.Feature.EXTENSION_MESSAGE)) { | 884 if (!this.hasFeature(remoting.ClientPlugin.Feature.EXTENSION_MESSAGE)) { |
| 912 return; | 885 return; |
| 913 } | 886 } |
| 914 this.plugin_.postMessage(JSON.stringify( | 887 this.plugin_.postMessage(JSON.stringify( |
| 915 { method: 'extensionMessage', | 888 { method: 'extensionMessage', |
| 916 data: { type: type, data: message } })); | 889 data: { type: type, data: message } })); |
| 917 | 890 |
| 918 }; | 891 }; |
| 919 | 892 |
| 920 /** | |
| 921 * Request MediaStream-based rendering. | |
| 922 * | |
| 923 * @param {remoting.MediaSourceRenderer} mediaSourceRenderer | |
| 924 */ | |
| 925 remoting.ClientPluginImpl.prototype.enableMediaSourceRendering = | |
| 926 function(mediaSourceRenderer) { | |
| 927 if (!this.hasFeature(remoting.ClientPlugin.Feature.MEDIA_SOURCE_RENDERING)) { | |
| 928 return; | |
| 929 } | |
| 930 this.mediaSourceRenderer_ = mediaSourceRenderer; | |
| 931 this.plugin_.postMessage(JSON.stringify( | |
| 932 { method: 'enableMediaSourceRendering', data: {} })); | |
| 933 }; | |
| 934 | |
| 935 remoting.ClientPluginImpl.prototype.getDesktopWidth = function() { | 893 remoting.ClientPluginImpl.prototype.getDesktopWidth = function() { |
| 936 return this.desktopWidth_; | 894 return this.desktopWidth_; |
| 937 } | 895 } |
| 938 | 896 |
| 939 remoting.ClientPluginImpl.prototype.getDesktopHeight = function() { | 897 remoting.ClientPluginImpl.prototype.getDesktopHeight = function() { |
| 940 return this.desktopHeight_; | 898 return this.desktopHeight_; |
| 941 } | 899 } |
| 942 | 900 |
| 943 remoting.ClientPluginImpl.prototype.getDesktopXDpi = function() { | 901 remoting.ClientPluginImpl.prototype.getDesktopXDpi = function() { |
| 944 return this.desktopXDpi_; | 902 return this.desktopXDpi_; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() { | 961 remoting.DefaultClientPluginFactory.prototype.preloadPlugin = function() { |
| 1004 if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') { | 962 if (remoting.settings.CLIENT_PLUGIN_TYPE != 'pnacl') { |
| 1005 return; | 963 return; |
| 1006 } | 964 } |
| 1007 | 965 |
| 1008 var plugin = remoting.ClientPluginImpl.createPluginElement_(); | 966 var plugin = remoting.ClientPluginImpl.createPluginElement_(); |
| 1009 plugin.addEventListener( | 967 plugin.addEventListener( |
| 1010 'loadend', function() { document.body.removeChild(plugin); }, false); | 968 'loadend', function() { document.body.removeChild(plugin); }, false); |
| 1011 document.body.appendChild(plugin); | 969 document.body.appendChild(plugin); |
| 1012 }; | 970 }; |
| OLD | NEW |