OLD | NEW |
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 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 getStats() { |
13 console.log("[TEST] rtpStreamStart"); | 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, |
(...skipping 13 matching lines...) Expand all Loading... |
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."); |
40 rtpStream.stop(audioId); | 40 rtpStream.stop(audioId); |
41 rtpStream.stop(videoId); | 41 rtpStream.stop(videoId); |
42 }.bind(null, audioId, videoId)); | 42 }.bind(null, audioId, videoId)); |
43 rtpStream.onStopped.addListener( | 43 rtpStream.onStopped.addListener( |
44 stateMachine.onStopped.bind(stateMachine)); | 44 stateMachine.onStopped.bind(stateMachine)); |
45 stateMachine.onAllStopped = | 45 stateMachine.onAllStopped = |
46 pass(function(audioId, videoId) { | 46 pass(function(audioId, videoId) { |
47 rtpStream.getRawEvents(audioId, | 47 rtpStream.getStats(audioId, |
48 stateMachine.onGotRawEvents.bind(stateMachine, audioId)); | 48 stateMachine.onGotLogs.bind(stateMachine, audioId)); |
49 rtpStream.getRawEvents(videoId, | 49 rtpStream.getStats(videoId, |
50 stateMachine.onGotRawEvents.bind(stateMachine, videoId)); | 50 stateMachine.onGotLogs.bind(stateMachine, videoId)); |
51 }.bind(null, audioId, videoId)); | 51 }.bind(null, audioId, videoId)); |
52 stateMachine.onGotAllRawEvents = | 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.assertEq(audioParams.payload.codecName, "OPUS"); |
62 chrome.test.assertEq(videoParams.payload.codecName, "VP8"); | 62 chrome.test.assertEq(videoParams.payload.codecName, "VP8"); |
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 |