| 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); |
| 19 } | 22 } |
| 20 | 23 |
| 21 Manager.prototype = { | 24 Manager.prototype = { |
| 22 /** | 25 /** |
| 23 * Updates an audio-component. | 26 * Updates an audio-component. |
| 24 * @param componentType Integer AudioComponent enum value; must match values | 27 * @param componentType Integer AudioComponent enum value; must match values |
| 25 * from the AudioLogFactory::AudioComponent enum. | 28 * from the AudioLogFactory::AudioComponent enum. |
| 26 * @param componentId The unique-id of the audio-component. | 29 * @param componentId The unique-id of the audio-component. |
| 27 * @param componentData The actual component data dictionary. | 30 * @param componentData The actual component data dictionary. |
| 28 */ | 31 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 /** | 74 /** |
| 72 * Attempts to remove a player from the UI. | 75 * Attempts to remove a player from the UI. |
| 73 * @param id The ID of the player to remove. | 76 * @param id The ID of the player to remove. |
| 74 */ | 77 */ |
| 75 removePlayer: function(id) { | 78 removePlayer: function(id) { |
| 76 var playerRemoved = this.players_[id]; | 79 var playerRemoved = this.players_[id]; |
| 77 delete this.players_[id]; | 80 delete this.players_[id]; |
| 78 this.clientRenderer_.playerRemoved(this.players_, playerRemoved); | 81 this.clientRenderer_.playerRemoved(this.players_, playerRemoved); |
| 79 }, | 82 }, |
| 80 | 83 |
| 84 hidePlayers_: function() { |
| 85 util.object.forEach(this.players_, function(playerInfo, id) { |
| 86 this.removePlayer(id); |
| 87 }, this); |
| 88 }, |
| 89 |
| 81 updatePlayerInfoNoRecord: function(id, timestamp, key, value) { | 90 updatePlayerInfoNoRecord: function(id, timestamp, key, value) { |
| 82 if (!this.players_[id]) { | 91 if (!this.players_[id]) { |
| 83 console.error('[updatePlayerInfo] Id ' + id + ' does not exist'); | 92 console.error('[updatePlayerInfo] Id ' + id + ' does not exist'); |
| 84 return; | 93 return; |
| 85 } | 94 } |
| 86 | 95 |
| 87 this.players_[id].addPropertyNoRecord(timestamp, key, value); | 96 this.players_[id].addPropertyNoRecord(timestamp, key, value); |
| 88 this.clientRenderer_.playerUpdated(this.players_, | 97 this.clientRenderer_.playerUpdated(this.players_, |
| 89 this.players_[id], | 98 this.players_[id], |
| 90 key, | 99 key, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // The keys of each device to be shown in order of appearance. | 169 // The keys of each device to be shown in order of appearance. |
| 161 var videoCaptureDeviceKeys = ['name','formats','captureApi','id']; | 170 var videoCaptureDeviceKeys = ['name','formats','captureApi','id']; |
| 162 | 171 |
| 163 this.clientRenderer_.redrawVideoCaptureCapabilities( | 172 this.clientRenderer_.redrawVideoCaptureCapabilities( |
| 164 videoCaptureCapabilities, videoCaptureDeviceKeys); | 173 videoCaptureCapabilities, videoCaptureDeviceKeys); |
| 165 } | 174 } |
| 166 }; | 175 }; |
| 167 | 176 |
| 168 return Manager; | 177 return Manager; |
| 169 }()); | 178 }()); |
| OLD | NEW |