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 rtpStreamStart() { | 12 function rtpStreamStart() { |
13 console.log("[TEST] rtpStreamStart"); | 13 console.log("[TEST] rtpStreamStart"); |
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 chrome.test.assertEq(audioParams.payload.codecName, "OPUS"); | 27 chrome.test.assertTrue(!!audioParams.payload.codecName); |
28 var expectError = function(id, message) { | 28 var expectError = function(id, message) { |
29 chrome.test.assertEq("Destination not set.", message); | 29 chrome.test.assertEq("Destination not set.", message); |
30 chrome.test.succeed(); | 30 chrome.test.succeed(); |
31 } | 31 } |
32 console.log("Starting RTP stream before setting destination."); | 32 console.log("Starting RTP stream before setting destination."); |
33 rtpStream.onError.addListener(expectError); | 33 rtpStream.onError.addListener(expectError); |
34 rtpStream.start(audioId, audioParams); | 34 rtpStream.start(audioId, audioParams); |
35 }.bind(null, stream))); | 35 }.bind(null, stream))); |
36 })); | 36 })); |
37 }, | 37 }, |
38 ]); | 38 ]); |
OLD | NEW |