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

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: Use Object 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 audio_constraint = {
Devlin 2016/12/13 16:05:44 js-style variable, so audioConstraint
qiangchen 2016/12/13 19:04:33 Done.
39 audio:{
40 mandatory: { 39 mandatory: {
41 chromeMediaSource: 'desktop', 40 chromeMediaSource: 'desktop',
42 chromeMediaSourceId: id} }, 41 chromeMediaSourceId: id} };
Devlin 2016/12/13 16:05:44 The wrapping here was already weird, but let's cle
qiangchen 2016/12/13 19:04:33 Done.
42
43 if (!options.can_request_audio_track) audio_constraint = false;
Devlin 2016/12/13 16:05:44 if bodies should go on separate lines, so this wou
qiangchen 2016/12/13 19:04:32 Done.
44
45 navigator.webkitGetUserMedia({
46 audio: audio_constraint,
43 video: { 47 video: {
44 mandatory: { 48 mandatory: {
45 chromeMediaSource: 'desktop', 49 chromeMediaSource: 'desktop',
46 chromeMediaSourceId: id, 50 chromeMediaSourceId: id,
47 maxWidth:screen.width, 51 maxWidth:screen.width,
48 maxHeight:screen.height} } 52 maxHeight:screen.height} }
49 }, gotStream, getUserMediaError); 53 }, gotStream, getUserMediaError);
50 } 54 }
51 55
52 function getUserMediaError(error) { 56 function getUserMediaError(error) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 var remotePC = (pc === pc1) ? pc2 : pc1; 116 var remotePC = (pc === pc1) ? pc2 : pc1;
113 remotePC.addIceCandidate(new RTCIceCandidate(event.candidate)); 117 remotePC.addIceCandidate(new RTCIceCandidate(event.candidate));
114 } 118 }
115 } 119 }
116 120
117 function onIceStateChange(pc, event) { 121 function onIceStateChange(pc, event) {
118 if (pc) { 122 if (pc) {
119 console.log('ICE state change event: ', event); 123 console.log('ICE state change event: ', event);
120 } 124 }
121 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698