| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // The window (tab) opened and navigated to receiver.html. | 5 // The window (tab) opened and navigated to receiver.html. |
| 6 var receiver = null; | 6 var receiver = null; |
| 7 | 7 |
| 8 // Open a new window of receiver.html when browser action icon is clicked. | 8 // Open a new window of receiver.html when browser action icon is clicked. |
| 9 chrome.browserAction.onClicked.addListener(function(tab) { | 9 chrome.browserAction.onClicked.addListener(function(tab) { |
| 10 chrome.tabCapture.capture( | 10 chrome.tabCapture.capture( |
| 11 {video: true, audio: true, | 11 {video: true, audio: true, |
| 12 videoConstraints: { | 12 videoConstraints: { |
| 13 mandatory: { | 13 mandatory: { |
| 14 // If minWidth/Height have the same aspect ratio (e.g., 16:9) as | 14 // If minWidth/Height have the same aspect ratio (e.g., 16:9) as |
| 15 // maxWidth/Height, the implementation will letterbox/pillarbox as | 15 // maxWidth/Height, the implementation will letterbox/pillarbox as |
| 16 // needed. Otherwise, set minWidth/Height to 0 to allow output video | 16 // needed. Otherwise, set minWidth/Height to 0 to allow output video |
| 17 // to be of any arbitrary size. | 17 // to be of any arbitrary size. |
| 18 minWidth: 16, | 18 minWidth: 16, |
| 19 minHeight: 9, | 19 minHeight: 9, |
| 20 maxWidth: 854, | 20 maxWidth: 1280, |
| 21 maxHeight: 480, | 21 maxHeight: 720, |
| 22 maxFrameRate: 60, // Note: Frame rate is variable (0 <= x <= 60). | 22 maxFrameRate: 60, // Note: Frame rate is variable (0 <= x <= 60). |
| 23 }, | 23 }, |
| 24 }, | 24 }, |
| 25 }, | 25 }, |
| 26 function(stream) { | 26 function(stream) { |
| 27 if (!stream) { | 27 if (!stream) { |
| 28 console.error('Error starting tab capture: ' + | 28 console.error('Error starting tab capture: ' + |
| 29 (chrome.runtime.lastError.message || 'UNKNOWN')); | 29 (chrome.runtime.lastError.message || 'UNKNOWN')); |
| 30 return; | 30 return; |
| 31 } | 31 } |
| 32 if (receiver != null) { | 32 if (receiver != null) { |
| 33 receiver.close(); | 33 receiver.close(); |
| 34 } | 34 } |
| 35 receiver = window.open('receiver.html'); | 35 receiver = window.open('receiver.html'); |
| 36 receiver.currentStream = stream; | 36 receiver.currentStream = stream; |
| 37 } | 37 } |
| 38 ); | 38 ); |
| 39 }); | 39 }); |
| OLD | NEW |