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
3 // found in the LICENSE file.
7 * Provides the UI for dump creation.
9 var DumpCreator
= (function() {
11 * @param {Element} containerElement The parent element of the dump creation
15 function DumpCreator(containerElement
) {
17 * The root element of the dump creation UI.
21 this.root_
= document
.createElement('details');
23 this.root_
.className
= 'peer-connection-dump-root';
24 containerElement
.appendChild(this.root_
);
25 var summary
= document
.createElement('summary');
26 this.root_
.appendChild(summary
);
27 summary
.textContent
= 'Create Dump';
28 var content
= document
.createElement('div');
29 this.root_
.appendChild(content
);
31 content
.innerHTML
= '<div><a><button>' +
32 'Download the PeerConnection updates and stats data' +
33 '</button></a></div>' +
34 '<p><label><input type=checkbox>' +
35 'Enable diagnostic audio recordings</label></p>' +
36 '<p>A diagnostic audio recording is used for analyzing audio' +
37 ' problems. It contains the audio played out from the speaker and' +
38 ' recorded from the microphone and is saved to the local disk.' +
39 ' Checking this box will enable the recording for ongoing WebRTC' +
40 ' calls and for future WebRTC calls. When the box is unchecked or' +
41 ' this page is closed, all ongoing recordings will be stopped and' +
42 ' this recording functionality will be disabled for future WebRTC' +
43 ' calls. Recordings in multiple tabs are supported as well as' +
44 ' multiple recordings in the same tab. When enabling, you select a' +
45 ' base filename to save the dump(s) to. The base filename will have a' +
46 ' suffix appended to it as <base filename>.<render process' +
47 ' ID>.<recording ID>. If recordings are' +
48 ' disabled and then enabled using the same base filename, the' +
49 ' file(s) will be appended to and may become invalid. It is' +
50 ' recommended to choose a new base filename each time or move' +
51 ' the resulting files before enabling again. If track processing is' +
52 ' disabled (--disable-audio-track-processing): (1) Only one recording' +
53 ' per render process is supported. (2) When the box is unchecked or' +
54 ' this page is closed, ongoing recordings will continue until the' +
55 ' call ends or the page with the recording is closed</p>';
57 content
.getElementsByTagName('a')[0].addEventListener(
58 'click', this.onDownloadData_
.bind(this));
59 content
.getElementsByTagName('input')[0].addEventListener(
60 'click', this.onAudioDebugRecordingsChanged_
.bind(this));
63 DumpCreator
.prototype = {
64 // Mark the diagnostic audio recording checkbox checked.
65 enableAudioDebugRecordings: function() {
66 this.root_
.getElementsByTagName('input')[0].checked
= true;
69 // Mark the diagnostic audio recording checkbox unchecked.
70 disableAudioDebugRecordings: function() {
71 this.root_
.getElementsByTagName('input')[0].checked
= false;
75 * Downloads the PeerConnection updates and stats data as a file.
79 onDownloadData_: function() {
82 'getUserMedia': userMediaRequests
,
83 'PeerConnections': peerConnectionDataStore
,
85 var textBlob
= new Blob([JSON
.stringify(dump_object
, null, ' ')],
86 {type
: 'octet/stream'});
87 var URL
= window
.URL
.createObjectURL(textBlob
);
89 var anchor
= this.root_
.getElementsByTagName('a')[0];
91 anchor
.download
= 'webrtc_internals_dump.txt';
92 // The default action of the anchor will download the URL.
96 * Handles the event of toggling the audio debug recordings state.
100 onAudioDebugRecordingsChanged_: function() {
101 var enabled
= this.root_
.getElementsByTagName('input')[0].checked
;
103 chrome
.send('enableAudioDebugRecordings');
105 chrome
.send('disableAudioDebugRecordings');