| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 Keeps track of all the existing PlayerInfo and | 6 * @fileoverview Keeps track of all the existing PlayerInfo and |
| 7 * audio stream objects and is the entry-point for messages from the backend. | 7 * audio stream objects and is the entry-point for messages from the backend. |
| 8 * | 8 * |
| 9 * The events captured by Manager (add, remove, update) are relayed | 9 * The events captured by Manager (add, remove, update) are relayed |
| 10 * to the clientRenderer which it can choose to use to modify the UI. | 10 * to the clientRenderer which it can choose to use to modify the UI. |
| 11 */ | 11 */ |
| 12 var Manager = (function() { | 12 var Manager = (function() { |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 function Manager(clientRenderer) { | 15 function Manager(clientRenderer) { |
| 16 this.players_ = {}; | 16 this.players_ = {}; |
| 17 this.audioComponents_ = []; | 17 this.audioComponents_ = []; |
| 18 this.clientRenderer_ = clientRenderer; | 18 this.clientRenderer_ = clientRenderer; |
| 19 | |
| 20 this.hidePlayersButton = document.getElementById('hide-players-button'); | |
| 21 this.hidePlayersButton.onclick = this.hidePlayers_.bind(this); | |
| 22 } | 19 } |
| 23 | 20 |
| 24 Manager.prototype = { | 21 Manager.prototype = { |
| 25 /** | 22 /** |
| 26 * Updates an audio-component. | 23 * Updates an audio-component. |
| 27 * @param componentType Integer AudioComponent enum value; must match values | 24 * @param componentType Integer AudioComponent enum value; must match values |
| 28 * from the AudioLogFactory::AudioComponent enum. | 25 * from the AudioLogFactory::AudioComponent enum. |
| 29 * @param componentId The unique-id of the audio-component. | 26 * @param componentId The unique-id of the audio-component. |
| 30 * @param componentData The actual component data dictionary. | 27 * @param componentData The actual component data dictionary. |
| 31 */ | 28 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 /** | 71 /** |
| 75 * Attempts to remove a player from the UI. | 72 * Attempts to remove a player from the UI. |
| 76 * @param id The ID of the player to remove. | 73 * @param id The ID of the player to remove. |
| 77 */ | 74 */ |
| 78 removePlayer: function(id) { | 75 removePlayer: function(id) { |
| 79 var playerRemoved = this.players_[id]; | 76 var playerRemoved = this.players_[id]; |
| 80 delete this.players_[id]; | 77 delete this.players_[id]; |
| 81 this.clientRenderer_.playerRemoved(this.players_, playerRemoved); | 78 this.clientRenderer_.playerRemoved(this.players_, playerRemoved); |
| 82 }, | 79 }, |
| 83 | 80 |
| 84 hidePlayers_: function() { | |
| 85 util.object.forEach(this.players_, function(playerInfo, id) { | |
| 86 this.removePlayer(id); | |
| 87 }, this); | |
| 88 }, | |
| 89 | |
| 90 updatePlayerInfoNoRecord: function(id, timestamp, key, value) { | 81 updatePlayerInfoNoRecord: function(id, timestamp, key, value) { |
| 91 if (!this.players_[id]) { | 82 if (!this.players_[id]) { |
| 92 console.error('[updatePlayerInfo] Id ' + id + ' does not exist'); | 83 console.error('[updatePlayerInfo] Id ' + id + ' does not exist'); |
| 93 return; | 84 return; |
| 94 } | 85 } |
| 95 | 86 |
| 96 this.players_[id].addPropertyNoRecord(timestamp, key, value); | 87 this.players_[id].addPropertyNoRecord(timestamp, key, value); |
| 97 this.clientRenderer_.playerUpdated(this.players_, | 88 this.clientRenderer_.playerUpdated(this.players_, |
| 98 this.players_[id], | 89 this.players_[id], |
| 99 key, | 90 key, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // The keys of each device to be shown in order of appearance. | 160 // The keys of each device to be shown in order of appearance. |
| 170 var videoCaptureDeviceKeys = ['name','formats','captureApi','id']; | 161 var videoCaptureDeviceKeys = ['name','formats','captureApi','id']; |
| 171 | 162 |
| 172 this.clientRenderer_.redrawVideoCaptureCapabilities( | 163 this.clientRenderer_.redrawVideoCaptureCapabilities( |
| 173 videoCaptureCapabilities, videoCaptureDeviceKeys); | 164 videoCaptureCapabilities, videoCaptureDeviceKeys); |
| 174 } | 165 } |
| 175 }; | 166 }; |
| 176 | 167 |
| 177 return Manager; | 168 return Manager; |
| 178 }()); | 169 }()); |
| OLD | NEW |