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

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

Issue 2773083002: Reland of WebRTC: Use the MediaStream Recording API for the audio_quality_browsertest.
Patch Set: Fix issues with MOS score. Created 3 years, 8 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 doneCapturing = false;
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 doneCapturing = true;
51 }
52
53 mediaRecorder.start();
54 setTimeout(function() { mediaRecorder.stop(); },
55 capture_duration_in_seconds * 1000);
56
57 returnToTest('ok-capturing');
58 }
59
60 function testIsDoneCapturing() {
61 returnToTest(doneCapturing.toString());
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698