| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 var rtpStream = chrome.cast.streaming.rtpStream; | 5 var rtpStream = chrome.cast.streaming.rtpStream; |
| 6 var tabCapture = chrome.tabCapture; | 6 var tabCapture = chrome.tabCapture; |
| 7 var udpTransport = chrome.cast.streaming.udpTransport; | 7 var udpTransport = chrome.cast.streaming.udpTransport; |
| 8 var createSession = chrome.cast.streaming.session.create; | 8 var createSession = chrome.cast.streaming.session.create; |
| 9 var pass = chrome.test.callbackPass; | 9 var pass = chrome.test.callbackPass; |
| 10 | 10 |
| 11 chrome.test.runTests([ | 11 chrome.test.runTests([ |
| 12 function getStats() { | 12 function getStats() { |
| 13 console.log("[TEST] getStats"); | 13 console.log("[TEST] getStats"); |
| 14 tabCapture.capture({audio: true, video: true}, | 14 tabCapture.capture({audio: true, video: true}, |
| 15 pass(function(stream) { | 15 pass(function(stream) { |
| 16 console.log("Got MediaStream."); | 16 console.log("Got MediaStream."); |
| 17 chrome.test.assertTrue(!!stream); | 17 chrome.test.assertTrue(!!stream); |
| 18 createSession(stream.getAudioTracks()[0], | 18 createSession(stream.getAudioTracks()[0], |
| 19 stream.getVideoTracks()[0], | 19 stream.getVideoTracks()[0], |
| 20 pass(function(stream, audioId, videoId, udpId) { | 20 pass(function(stream, audioId, videoId, udpId) { |
| 21 console.log("Starting."); | 21 console.log("Starting."); |
| 22 var stateMachine = new TestStateMachine(stream, | 22 var stateMachine = new TestStateMachine(stream, |
| 23 audioId, | 23 audioId, |
| 24 videoId, | 24 videoId, |
| 25 udpId); | 25 udpId); |
| 26 var audioParams = rtpStream.getSupportedParams(audioId)[0]; | 26 var audioParams = rtpStream.getSupportedParams(audioId)[0]; |
| 27 var videoParams = rtpStream.getSupportedParams(videoId)[0]; | 27 var videoParams = rtpStream.getSupportedParams(videoId)[0]; |
| 28 chrome.test.assertEq(audioParams.payload.codecName, "OPUS"); | 28 chrome.test.assertTrue(!!audioParams.payload.codecName); |
| 29 chrome.test.assertEq(videoParams.payload.codecName, "VP8"); | 29 chrome.test.assertTrue(!!videoParams.payload.codecName); |
| 30 udpTransport.setDestination(udpId, | 30 udpTransport.setDestination(udpId, |
| 31 {address: "127.0.0.1", port: 2344}); | 31 {address: "127.0.0.1", port: 2344}); |
| 32 rtpStream.onStarted.addListener( | 32 rtpStream.onStarted.addListener( |
| 33 stateMachine.onStarted.bind(stateMachine)); | 33 stateMachine.onStarted.bind(stateMachine)); |
| 34 stateMachine.onAllStarted = | 34 stateMachine.onAllStarted = |
| 35 pass(function(audioId, videoId) { | 35 pass(function(audioId, videoId) { |
| 36 console.log("Enabling logging."); | 36 console.log("Enabling logging."); |
| 37 rtpStream.toggleLogging(audioId, true); | 37 rtpStream.toggleLogging(audioId, true); |
| 38 rtpStream.toggleLogging(videoId, true); | 38 rtpStream.toggleLogging(videoId, true); |
| 39 console.log("Stopping."); | 39 console.log("Stopping."); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 }.bind(null, audioId, videoId)); | 51 }.bind(null, audioId, videoId)); |
| 52 stateMachine.onGotAllLogs = | 52 stateMachine.onGotAllLogs = |
| 53 pass(function(stream, audioId, videoId, udpId) { | 53 pass(function(stream, audioId, videoId, udpId) { |
| 54 console.log("Disabling logging."); | 54 console.log("Disabling logging."); |
| 55 rtpStream.toggleLogging(audioId, false); | 55 rtpStream.toggleLogging(audioId, false); |
| 56 rtpStream.toggleLogging(videoId, false); | 56 rtpStream.toggleLogging(videoId, false); |
| 57 console.log("Destroying."); | 57 console.log("Destroying."); |
| 58 rtpStream.destroy(audioId); | 58 rtpStream.destroy(audioId); |
| 59 rtpStream.destroy(videoId); | 59 rtpStream.destroy(videoId); |
| 60 udpTransport.destroy(udpId); | 60 udpTransport.destroy(udpId); |
| 61 chrome.test.assertEq(audioParams.payload.codecName, "OPUS"); | 61 chrome.test.assertTrue(!!audioParams.payload.codecName); |
| 62 chrome.test.assertEq(videoParams.payload.codecName, "VP8"); | 62 chrome.test.assertTrue(!!videoParams.payload.codecName); |
| 63 chrome.test.succeed(); | 63 chrome.test.succeed(); |
| 64 }.bind(null, stream, audioId, videoId, udpId)); | 64 }.bind(null, stream, audioId, videoId, udpId)); |
| 65 rtpStream.start(audioId, audioParams); | 65 rtpStream.start(audioId, audioParams); |
| 66 rtpStream.start(videoId, videoParams); | 66 rtpStream.start(videoId, videoParams); |
| 67 }.bind(null, stream))); | 67 }.bind(null, stream))); |
| 68 })); | 68 })); |
| 69 }, | 69 }, |
| 70 ]); | 70 ]); |
| OLD | NEW |