Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/test/data/extensions/api_test/webrtc_cast/basics.js

Issue 83043005: Cast Extensions API: Factory method for creating a cast session (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove castSendTransport.create Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 sendTransport = chrome.webrtc.castSendTransport; 5 var sendTransport = chrome.webrtc.castSendTransport;
6 var tabCapture = chrome.tabCapture; 6 var tabCapture = chrome.tabCapture;
7 var udpTransport = chrome.webrtc.castUdpTransport; 7 var udpTransport = chrome.webrtc.castUdpTransport;
8 var createSession = chrome.cast.streaming.createSession;
8 9
9 chrome.test.runTests([ 10 chrome.test.runTests([
10 function udpTransportCreate() { 11 function sendTransportStart() {
11 udpTransport.create(function(udpId) { 12 tabCapture.capture({audio: true, video: true}, function(stream) {
12 udpTransport.start(
13 udpId,
14 {address: "127.0.0.1", port: 60613});
15 udpTransport.destroy(udpId);
16 chrome.test.succeed();
17 });
18 },
19 function sendTransportCreate() {
20 tabCapture.capture({audio: true}, function(stream) {
21 chrome.test.assertTrue(!!stream); 13 chrome.test.assertTrue(!!stream);
22 udpTransport.create(function(stream, udpId) { 14 createSession(stream.getAudioTracks()[0],
23 sendTransport.create( 15 stream.getVideoTracks()[0],
24 udpId, 16 function(stream, audioId, videoId, udpId) {
25 stream.getAudioTracks()[0], 17 var audioParams = sendTransport.getCaps(audioId);
26 function(stream, udpId, sendTransportId) { 18 var videoParams = sendTransport.getCaps(videoId);
27 sendTransport.destroy(sendTransportId); 19 sendTransport.start(audioId, audioParams);
28 udpTransport.destroy(udpId); 20 sendTransport.start(videoId, videoParams);
29 stream.stop(); 21 sendTransport.stop(audioId);
30 chrome.test.succeed(); 22 sendTransport.stop(videoId);
31 }.bind(null, stream, udpId)); 23 sendTransport.destroy(audioId);
24 sendTransport.destroy(videoId);
25 udpTransport.destroy(udpId);
26 stream.stop();
27 chrome.test.assertEq(audioParams.payloads[0].codecName, "OPUS");
28 chrome.test.assertEq(videoParams.payloads[0].codecName, "VP8");
29 chrome.test.succeed();
32 }.bind(null, stream)); 30 }.bind(null, stream));
33 }); 31 });
34 }, 32 },
35 function sendTransportGetCapsAudio() {
36 tabCapture.capture({audio: true}, function(stream) {
37 chrome.test.assertTrue(!!stream);
38 udpTransport.create(function(stream, udpId) {
39 sendTransport.create(
40 udpId,
41 stream.getAudioTracks()[0],
42 function(stream, udpId, sendTransportId) {
43 var caps = sendTransport.getCaps(sendTransportId);
44 sendTransport.destroy(sendTransportId);
45 udpTransport.destroy(udpId);
46 stream.stop();
47 chrome.test.assertEq(caps.payloads[0].codecName, "OPUS");
48 chrome.test.succeed();
49 }.bind(null, stream, udpId));
50 }.bind(null, stream));
51 });
52 },
53 function sendTransportStart() {
54 function startId(id) {
55 // TODO(hclam): Give something meaningful for params.
56 var params = {
57 payloads: [],
58 rtcpFeatures: [],
59 };
60 sendTransport.start(id, params);
61 }
62 function cleanupId(id) {
63 sendTransport.stop(id);
64 sendTransport.destroy(id);
65 }
66 tabCapture.capture({audio: true, video: true}, function(stream) {
67 chrome.test.assertTrue(!!stream);
68 udpTransport.create(function(stream, udpId) {
69 // Create a transport for audio.
70 sendTransport.create(
71 udpId,
72 stream.getAudioTracks()[0],
73 function(stream, udpId, audioId) {
74 // Create a transport for video.
75 sendTransport.create(
76 udpId,
77 stream.getVideoTracks()[0],
78 function(stream, udpId, audioId, videoId) {
79 startId(audioId);
80 cleanupId(audioId);
81 startId(videoId);
82 cleanupId(videoId);
83 udpTransport.destroy(udpId);
84 stream.stop();
85 chrome.test.succeed();
86 }.bind(null, stream, udpId, audioId));
87 }.bind(null, stream, udpId));
88 }.bind(null, stream));
89 });
90 },
91 ]); 33 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698