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 stopNoStart() { |
13 console.log("[TEST] rtpStreamStart"); | 13 console.log("[TEST] stopNoStart"); |
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 chrome.test.assertTrue(audioId > 0); |
22 var stateMachine = new TestStateMachine(stream, | 22 chrome.test.assertTrue(videoId > 0); |
23 audioId, | 23 chrome.test.assertTrue(udpId > 0); |
24 videoId, | 24 rtpStream.stop(audioId); |
25 udpId); | 25 rtpStream.stop(videoId); |
26 var audioParams = rtpStream.getSupportedParams(audioId)[0]; | 26 rtpStream.destroy(audioId); |
27 chrome.test.assertEq(audioParams.payload.codecName, "OPUS"); | 27 rtpStream.destroy(videoId); |
28 var expectError = function(id, message) { | 28 udpTransport.destroy(udpId); |
29 chrome.test.assertEq("Destination not set.", message); | 29 chrome.test.succeed(); |
30 chrome.test.succeed(); | |
31 } | |
32 console.log("Starting RTP stream before setting destination."); | |
33 rtpStream.onError.addListener(expectError); | |
34 rtpStream.start(audioId, audioParams); | |
35 }.bind(null, stream))); | 30 }.bind(null, stream))); |
36 })); | 31 })); |
37 }, | 32 }, |
38 ]); | 33 ]); |
OLD | NEW |