Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: chrome/test/data/webrtc/audio_extraction.js

Issue 2753543010: WebRTC: Use the MediaStream Recording API for the audio_quality_browsertest. (Closed)
Patch Set: Download recording to file. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * Copyright 2017 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 /**
8 * Aggregate target bits per second for encoding of the Audio track.
9 * @private
10 */
11 const AUDIO_BITS_PER_SECOND = 3000000;
12
13 var CAPTURE_STATUS = 'not-started';
mcasas 2017/03/22 17:04:55 This is a true variable, so s/CAPTURE_STATUS/captu
14
15 /**
16 * Starts the audio capturing.
17 *
18 * @param {Number} The duration of the capture in seconds.
19 */
20 function startAudioCapture(capture_duration_in_seconds, output_file) {
21 console.log('Started capturing for ' + capture_duration_in_seconds + 's to '
22 + output_file);
23 var inputElement = document.getElementById('remote-view');
24
25 // |audioBitsPerSecond| must set to a large number to throw as little
26 // information away as possible.
27 var mediaRecorderOptions = {
28 audioBitsPerSecond: AUDIO_BITS_PER_SECOND,
29 mimeType: 'audio/webm',
30 };
31 var stream = inputElement.srcObject;
32 var mediaRecorder = new MediaRecorder(stream, mediaRecorderOptions);
33
34 var audio_chunks = [];
35
36 mediaRecorder.ondataavailable = function(recording) {
37 audio_chunks.push(recording.data);
38 }
39 mediaRecorder.onstop = function() {
40 var audioBlob = new Blob(audio_chunks, {type: 'audio/webm'});
41
42 var url = window.URL.createObjectURL(audioBlob);
43 var a = document.createElement('a');
44 document.body.appendChild(a);
45
46 a.href = url;
47 a.download = output_file;
48 a.click();
49
50 CAPTURE_STATUS = 'done-capturing';
51 }
52
53 mediaRecorder.start();
54 CAPTURE_STATUS = 'started';
55 setTimeout(function() { mediaRecorder.stop(); },
56 capture_duration_in_seconds * 1000);
57
58 returnToTest('ok-capturing');
59 }
60
61 function getCaptureStatus() {
62 returnToTest(CAPTURE_STATUS);
mcasas 2017/03/22 17:04:55 getCaptureStatus() uses only compare the returned
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698