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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 }; | 25 }; |
26 tabCapture.capture(constraints, | 26 tabCapture.capture(constraints, |
27 pass(function(stream) { | 27 pass(function(stream) { |
28 chrome.test.assertTrue(!!stream); | 28 chrome.test.assertTrue(!!stream); |
29 createSession(stream.getAudioTracks()[0], | 29 createSession(stream.getAudioTracks()[0], |
30 stream.getVideoTracks()[0], | 30 stream.getVideoTracks()[0], |
31 pass(function(stream, audioId, videoId, udpId) { | 31 pass(function(stream, audioId, videoId, udpId) { |
32 var audioParams = rtpStream.getSupportedParams(audioId)[0]; | 32 var audioParams = rtpStream.getSupportedParams(audioId)[0]; |
33 var videoParams = rtpStream.getSupportedParams(videoId)[0]; | 33 var videoParams = rtpStream.getSupportedParams(videoId)[0]; |
34 rtpStream.onError.addListener( | |
35 pass(function(audioId, videoId, id, msg) { | |
36 chrome.test.assertEq(videoId, id); | |
37 rtpStream.destroy(audioId); | |
38 rtpStream.destroy(videoId); | |
39 udpTransport.destroy(udpId); | |
40 console.log(msg); | |
41 }.bind(null, audioId, videoId))); | |
42 // Specify invalid value to trigger error. | 34 // Specify invalid value to trigger error. |
43 videoParams.payload.codecName = "Animated WebP"; | 35 videoParams.payload.codecName = "Animated WebP"; |
44 udpTransport.setDestination(udpId, | 36 udpTransport.setDestination(udpId, |
45 {address: "127.0.0.1", port: 2344}); | 37 {address: "127.0.0.1", port: 2344}); |
46 rtpStream.start(videoId, videoParams); | 38 try { |
| 39 rtpStream.start(videoId, videoParams); |
| 40 chrome.test.fail(); |
| 41 } catch (e) { |
| 42 rtpStream.stop(audioId); |
| 43 rtpStream.stop(videoId); |
| 44 rtpStream.destroy(audioId); |
| 45 rtpStream.destroy(videoId); |
| 46 udpTransport.destroy(udpId); |
| 47 chrome.test.succeed(); |
| 48 } |
47 }.bind(null, stream))); | 49 }.bind(null, stream))); |
48 })); | 50 })); |
49 }, | 51 }, |
50 ]); | 52 ]); |
OLD | NEW |