OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 var USER_MEDIA_TAB_ID = 'user-media-tab-id'; | |
6 | |
5 var tabView = null; | 7 var tabView = null; |
6 var ssrcInfoManager = null; | 8 var ssrcInfoManager = null; |
7 var peerConnectionUpdateTable = null; | 9 var peerConnectionUpdateTable = null; |
8 var statsTable = null; | 10 var statsTable = null; |
9 var dumpCreator = null; | 11 var dumpCreator = null; |
10 /** A map from peer connection id to the PeerConnectionRecord. */ | 12 /** A map from peer connection id to the PeerConnectionRecord. */ |
11 var peerConnectionDataStore = {}; | 13 var peerConnectionDataStore = {}; |
12 /** A list of getUserMedia requests. */ | 14 /** A list of getUserMedia requests. */ |
13 var userMediaRequests = []; | 15 var userMediaRequests = []; |
14 | 16 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 */ | 133 */ |
132 function extractSsrcInfo(data) { | 134 function extractSsrcInfo(data) { |
133 if (data.type == 'setLocalDescription' || | 135 if (data.type == 'setLocalDescription' || |
134 data.type == 'setRemoteDescription') { | 136 data.type == 'setRemoteDescription') { |
135 ssrcInfoManager.addSsrcStreamInfo(data.value); | 137 ssrcInfoManager.addSsrcStreamInfo(data.value); |
136 } | 138 } |
137 } | 139 } |
138 | 140 |
139 | 141 |
140 /** | 142 /** |
143 * A helper function for appending a child element to |parent|. | |
144 * | |
145 * @param {!Element} parent The parent element. | |
146 * @param {string} tag The child element tag. | |
147 * @param {string} text The textContent of the new DIV. | |
148 * @return {!Element} the new DIV element. | |
149 */ | |
150 function appendChildWithText(parent, tag, text) { | |
151 var child = document.createElement(tag); | |
152 child.textContent = text; | |
153 parent.appendChild(child); | |
154 return child; | |
155 } | |
156 | |
157 /** | |
141 * Helper for adding a peer connection update. | 158 * Helper for adding a peer connection update. |
142 * | 159 * |
143 * @param {Element} peerConnectionElement | 160 * @param {Element} peerConnectionElement |
144 * @param {!PeerConnectionUpdateEntry} update The peer connection update data. | 161 * @param {!PeerConnectionUpdateEntry} update The peer connection update data. |
145 */ | 162 */ |
146 function addPeerConnectionUpdate(peerConnectionElement, update) { | 163 function addPeerConnectionUpdate(peerConnectionElement, update) { |
147 peerConnectionUpdateTable.addPeerConnectionUpdate(peerConnectionElement, | 164 peerConnectionUpdateTable.addPeerConnectionUpdate(peerConnectionElement, |
148 update); | 165 update); |
149 extractSsrcInfo(update); | 166 extractSsrcInfo(update); |
150 peerConnectionDataStore[peerConnectionElement.id].addUpdate(update); | 167 peerConnectionDataStore[peerConnectionElement.id].addUpdate(update); |
(...skipping 28 matching lines...) Expand all Loading... | |
179 var id = getPeerConnectionId(data); | 196 var id = getPeerConnectionId(data); |
180 | 197 |
181 if (!peerConnectionDataStore[id]) { | 198 if (!peerConnectionDataStore[id]) { |
182 peerConnectionDataStore[id] = new PeerConnectionRecord(); | 199 peerConnectionDataStore[id] = new PeerConnectionRecord(); |
183 } | 200 } |
184 peerConnectionDataStore[id].initialize( | 201 peerConnectionDataStore[id].initialize( |
185 data.url, data.servers, data.constraints); | 202 data.url, data.servers, data.constraints); |
186 | 203 |
187 var peerConnectionElement = $(id); | 204 var peerConnectionElement = $(id); |
188 if (!peerConnectionElement) { | 205 if (!peerConnectionElement) { |
189 peerConnectionElement = tabView.addTab(id, data.url); | 206 peerConnectionElement = tabView.addTab(id, data.url + ' [' + id + ']'); |
190 } | 207 } |
191 peerConnectionElement.innerHTML = | 208 peerConnectionElement.innerHTML = |
192 '<p>' + data.url + ' ' + data.servers + ' ' + data.constraints + | 209 '<p>' + data.url + ' ' + data.servers + ' ' + data.constraints + |
193 '</p>'; | 210 '</p>'; |
194 | 211 |
195 return peerConnectionElement; | 212 return peerConnectionElement; |
196 } | 213 } |
197 | 214 |
198 | 215 |
199 /** | 216 /** |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 } | 268 } |
252 | 269 |
253 | 270 |
254 /** | 271 /** |
255 * Adds a getUserMedia request. | 272 * Adds a getUserMedia request. |
256 * | 273 * |
257 * @param {!Object} data The object containing rid {number}, pid {number}, | 274 * @param {!Object} data The object containing rid {number}, pid {number}, |
258 * origin {string}, audio {string}, video {string}. | 275 * origin {string}, audio {string}, video {string}. |
259 */ | 276 */ |
260 function addGetUserMedia(data) { | 277 function addGetUserMedia(data) { |
261 // TODO(jiayl): add the getUserMedia info to the tabbed UI. | |
262 userMediaRequests.push(data); | 278 userMediaRequests.push(data); |
279 | |
280 if (!$(USER_MEDIA_TAB_ID)) { | |
281 tabView.addTab(USER_MEDIA_TAB_ID, 'GetUserMedia Requests'); | |
282 } | |
283 | |
284 var requestDiv = document.createElement('div'); | |
285 requestDiv.className = 'user-media-request-div-class'; | |
286 requestDiv.rid = data.rid; | |
287 $(USER_MEDIA_TAB_ID).appendChild(requestDiv); | |
288 | |
289 appendChildWithText(requestDiv, 'div', 'Caller origin: ' + data.origin); | |
290 appendChildWithText(requestDiv, 'div', 'Caller process id: ' + data.pid); | |
291 appendChildWithText(requestDiv, 'span', 'Audio Constraints').style.fontWeight | |
292 = 'bold'; | |
293 appendChildWithText(requestDiv, 'div', data.audio); | |
294 | |
295 appendChildWithText(requestDiv, 'span', 'Video Constraints').style.fontWeight | |
296 = 'bold'; | |
297 appendChildWithText(requestDiv, 'div', data.video); | |
263 } | 298 } |
264 | 299 |
265 | 300 |
266 /** | 301 /** |
267 * Removes the getUserMedia requests from the specified |rid|. | 302 * Removes the getUserMedia requests from the specified |rid|. |
268 * | 303 * |
269 * @param {!Object} data The object containing rid {number}, the render id. | 304 * @param {!Object} data The object containing rid {number}, the render id. |
270 */ | 305 */ |
271 function removeGetUserMediaForRenderer(data) { | 306 function removeGetUserMediaForRenderer(data) { |
272 // TODO(jiayl): remove the getUserMedia info from the tabbed UI. | |
273 for (var i = userMediaRequests.length - 1; i >= 0; --i) { | 307 for (var i = userMediaRequests.length - 1; i >= 0; --i) { |
274 if (userMediaRequests[i].rid == data.rid) | 308 if (userMediaRequests[i].rid == data.rid) |
275 userMediaRequests.splice(i, 1); | 309 userMediaRequests.splice(i, 1); |
276 } | 310 } |
311 | |
312 var requests = $(USER_MEDIA_TAB_ID).childNodes; | |
313 for (var i = 0; i < requests.length; ++i) { | |
314 if (requests[i].rid == data.rid) { | |
vrk (LEFT CHROMIUM)
2014/07/18 22:01:06
nit: no {}
jiayl
2014/07/18 22:06:24
Done.
| |
315 $(USER_MEDIA_TAB_ID).removeChild(requests[i]); | |
316 } | |
317 } | |
318 if ($(USER_MEDIA_TAB_ID).childNodes.length == 0) { | |
vrk (LEFT CHROMIUM)
2014/07/18 22:01:06
nit: no {}
jiayl
2014/07/18 22:06:24
Done.
| |
319 tabView.removeTab(USER_MEDIA_TAB_ID); | |
320 } | |
277 } | 321 } |
278 | 322 |
279 | 323 |
280 /** | 324 /** |
281 * Notification that the AEC recording file selection dialog was cancelled, | 325 * Notification that the AEC recording file selection dialog was cancelled, |
282 * i.e. AEC has not been enabled. | 326 * i.e. AEC has not been enabled. |
283 */ | 327 */ |
284 function aecRecordingFileSelectionCancelled() { | 328 function aecRecordingFileSelectionCancelled() { |
285 dumpCreator.disableAecRecording(); | 329 dumpCreator.disableAecRecording(); |
286 } | 330 } |
287 | 331 |
288 | 332 |
289 /** | 333 /** |
290 * Set | 334 * Set |
291 */ | 335 */ |
292 function enableAecRecording() { | 336 function enableAecRecording() { |
293 dumpCreator.enableAecRecording(); | 337 dumpCreator.enableAecRecording(); |
294 } | 338 } |
OLD | NEW |