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

Side by Side Diff: chrome/test/data/webrtc/peerconnection.js

Issue 1645043004: WebRtcBrowserTest with VP8 and VP9. WebRtcTestBase::NegotiateCall specifying video codec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (Updated comments, js include order of munge_sdp.js: after peerconnection.js) Created 4 years, 10 months 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
OLDNEW
1 /** 1 /**
2 * Copyright 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * The one and only peer connection in this page. 8 * The one and only peer connection in this page.
9 * @private 9 * @private
10 */ 10 */
(...skipping 26 matching lines...) Expand all
37 gPeerConnection = createPeerConnection_(); 37 gPeerConnection = createPeerConnection_();
38 returnToTest('ok-peerconnection-created'); 38 returnToTest('ok-peerconnection-created');
39 } 39 }
40 40
41 /** 41 /**
42 * Asks this page to create a local offer. 42 * Asks this page to create a local offer.
43 * 43 *
44 * Returns a string on the format ok-(JSON encoded session description). 44 * Returns a string on the format ok-(JSON encoded session description).
45 * 45 *
46 * @param {!Object} constraints Any createOffer constraints. 46 * @param {!Object} constraints Any createOffer constraints.
47 * @param {!String} videoCodec If not null, promotes the specified codec to be
phoglund_chromium 2016/02/01 14:20:44 Remove the !, which means that the parameter is ma
hbos_chromium 2016/02/02 14:07:19 Oh so that's what it means... :) done.
48 * the default video codec, e.g. the first one in the list on the 'm=video' SDP
49 * offer line. |videoCodec| is the case-sensitive codec name, e.g. 'VP8'.
47 */ 50 */
48 function createLocalOffer(constraints) { 51 function createLocalOffer(constraints, videoCodec = null) {
49 peerConnection_().createOffer( 52 peerConnection_().createOffer(
50 function(localOffer) { 53 function(localOffer) {
51 success_('createOffer'); 54 success_('createOffer');
55
52 setLocalDescription(peerConnection, localOffer); 56 setLocalDescription(peerConnection, localOffer);
57 if (videoCodec !== null)
58 localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, videoCodec);
53 59
54 returnToTest('ok-' + JSON.stringify(localOffer)); 60 returnToTest('ok-' + JSON.stringify(localOffer));
55 }, 61 },
56 function(error) { failure_('createOffer', error); }, 62 function(error) { failure_('createOffer', error); },
57 constraints); 63 constraints);
58 } 64 }
59 65
60 /** 66 /**
61 * Asks this page to accept an offer and generate an answer. 67 * Asks this page to accept an offer and generate an answer.
62 * 68 *
63 * Returns a string on the format ok-(JSON encoded session description). 69 * Returns a string on the format ok-(JSON encoded session description).
64 * 70 *
65 * @param {!string} sessionDescJson A JSON-encoded session description of type 71 * @param {!string} sessionDescJson A JSON-encoded session description of type
66 * 'offer'. 72 * 'offer'.
67 * @param {!Object} constraints Any createAnswer constraints. 73 * @param {!Object} constraints Any createAnswer constraints.
74 * @param {!string} videoCodec If not null, verifies that the specified codec
phoglund_chromium 2016/02/01 14:20:44 Call this expectedVideoCodec
phoglund_chromium 2016/02/01 14:20:44 Same here
hbos_chromium 2016/02/02 14:07:19 Done.
75 * is the default video codec, e.g. the first one in the list on the 'm=video'
76 * SDP answer line. If this is not the case, |failure_| occurs. |videoCodec| is
77 * the case-sensitive codec name, e.g. 'VP8', or null not to perform any
78 * verification.
68 */ 79 */
69 function receiveOfferFromPeer(sessionDescJson, constraints) { 80 function receiveOfferFromPeer(sessionDescJson, constraints, videoCodec = null) {
70 offer = parseJson_(sessionDescJson); 81 offer = parseJson_(sessionDescJson);
71 if (!offer.type) 82 if (!offer.type)
72 failTest('Got invalid session description from peer: ' + sessionDescJson); 83 failTest('Got invalid session description from peer: ' + sessionDescJson);
73 if (offer.type != 'offer') 84 if (offer.type != 'offer')
74 failTest('Expected to receive offer from peer, got ' + offer.type); 85 failTest('Expected to receive offer from peer, got ' + offer.type);
75 86
76 var sessionDescription = new RTCSessionDescription(offer); 87 var sessionDescription = new RTCSessionDescription(offer);
77 peerConnection_().setRemoteDescription( 88 peerConnection_().setRemoteDescription(
78 sessionDescription, 89 sessionDescription,
79 function() { success_('setRemoteDescription'); }, 90 function() { success_('setRemoteDescription'); },
80 function(error) { failure_('setRemoteDescription', error); }); 91 function(error) { failure_('setRemoteDescription', error); });
81 92
82 peerConnection_().createAnswer( 93 peerConnection_().createAnswer(
83 function(answer) { 94 function(answer) {
84 success_('createAnswer'); 95 success_('createAnswer');
96
85 setLocalDescription(peerConnection, answer); 97 setLocalDescription(peerConnection, answer);
98 if (videoCodec !== null) {
phoglund_chromium 2016/02/01 14:20:44 Break this out into a new function verifyDefaultVi
hbos_chromium 2016/02/02 14:07:19 Done.
99 var defaultVideoCodec = getSdpDefaultVideoCodec(answer.sdp);
100 if (defaultVideoCodec === null) {
101 failure_('createAnswer',
phoglund_chromium 2016/02/01 14:20:44 Should be failTest. Also note failTest takes one a
hbos_chromium 2016/02/02 14:07:19 failure_ is defined in this file.
102 'Could not determine default video codec.');
103 }
104 if (videoCodec !== defaultVideoCodec) {
105 failure_('createAnswer',
phoglund_chromium 2016/02/01 14:20:44 Same here
106 'Expected default video codec ' + videoCodec +
107 ', got ' + defaultVideoCodec + '.');
108 }
109 }
110
86 returnToTest('ok-' + JSON.stringify(answer)); 111 returnToTest('ok-' + JSON.stringify(answer));
87 }, 112 },
88 function(error) { failure_('createAnswer', error); }, 113 function(error) { failure_('createAnswer', error); },
89 constraints); 114 constraints);
90 } 115 }
91 116
92 /** 117 /**
93 * Asks this page to accept an answer generated by the peer in response to a 118 * Asks this page to accept an answer generated by the peer in response to a
94 * previous offer by this page 119 * previous offer by this page
95 * 120 *
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 function parseJson_(json) { 320 function parseJson_(json) {
296 // Escape since the \r\n in the SDP tend to get unescaped. 321 // Escape since the \r\n in the SDP tend to get unescaped.
297 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 322 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
298 try { 323 try {
299 return JSON.parse(jsonWithEscapedLineBreaks); 324 return JSON.parse(jsonWithEscapedLineBreaks);
300 } catch (exception) { 325 } catch (exception) {
301 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 326 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
302 exception); 327 exception);
303 } 328 }
304 } 329 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698