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

Side by Side Diff: chrome/common/extensions/docs/examples/api/desktopCapture/app.js

Issue 2547633002: Desktop Capture API: Pass Audio Selection Information To Javascript (Closed)
Patch Set: Browser Test Case Created 4 years 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
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 'use strict'; 5 'use strict';
6 6
7 const DESKTOP_MEDIA = ['screen', 'window', 'tab', 'audio']; 7 const DESKTOP_MEDIA = ['screen', 'window', 'tab', 'audio'];
8 8
9 var pending_request_id = null; 9 var pending_request_id = null;
10 var pc1 = null; 10 var pc1 = null;
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 }); 23 });
24 24
25 document.querySelector('#startFromBackgroundPage') 25 document.querySelector('#startFromBackgroundPage')
26 .addEventListener('click', function(event) { 26 .addEventListener('click', function(event) {
27 chrome.runtime.sendMessage( 27 chrome.runtime.sendMessage(
28 {}, function(response) { console.log(response.farewell); }); 28 {}, function(response) { console.log(response.farewell); });
29 }); 29 });
30 30
31 // Launch webkitGetUserMedia() based on selected media id. 31 // Launch webkitGetUserMedia() based on selected media id.
32 function onAccessApproved(id) { 32 function onAccessApproved(id, options) {
33 if (!id) { 33 if (!id) {
34 console.log('Access rejected.'); 34 console.log('Access rejected.');
35 return; 35 return;
36 } 36 }
37 37
38 navigator.webkitGetUserMedia({ 38 var audioConstraint = {
39 audio:{
40 mandatory: { 39 mandatory: {
41 chromeMediaSource: 'desktop', 40 chromeMediaSource: 'desktop',
42 chromeMediaSourceId: id} }, 41 chromeMediaSourceId: id
42 }
43 };
44
45 console.log(options.canRequestAudioTrack);
46 if (!options.canRequestAudioTrack)
47 audioConstraint = false;
48
49 navigator.webkitGetUserMedia({
50 audio: audioConstraint,
43 video: { 51 video: {
44 mandatory: { 52 mandatory: {
45 chromeMediaSource: 'desktop', 53 chromeMediaSource: 'desktop',
46 chromeMediaSourceId: id, 54 chromeMediaSourceId: id,
47 maxWidth:screen.width, 55 maxWidth:screen.width,
48 maxHeight:screen.height} } 56 maxHeight:screen.height} }
49 }, gotStream, getUserMediaError); 57 }, gotStream, getUserMediaError);
50 } 58 }
51 59
52 function getUserMediaError(error) { 60 function getUserMediaError(error) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 var remotePC = (pc === pc1) ? pc2 : pc1; 120 var remotePC = (pc === pc1) ? pc2 : pc1;
113 remotePC.addIceCandidate(new RTCIceCandidate(event.candidate)); 121 remotePC.addIceCandidate(new RTCIceCandidate(event.candidate));
114 } 122 }
115 } 123 }
116 124
117 function onIceStateChange(pc, event) { 125 function onIceStateChange(pc, event) {
118 if (pc) { 126 if (pc) {
119 console.log('ICE state change event: ', event); 127 console.log('ICE state change event: ', event);
120 } 128 }
121 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698