| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 */ | 34 */ |
| 35 var gDefaultAudioCodec = null; | 35 var gDefaultAudioCodec = null; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * The default video codec that should be used when creating an offer. | 38 * The default video codec that should be used when creating an offer. |
| 39 * @private | 39 * @private |
| 40 */ | 40 */ |
| 41 var gDefaultVideoCodec = null; | 41 var gDefaultVideoCodec = null; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Flag to indicate if HW or SW video codec is preferred. |
| 45 * @private |
| 46 */ |
| 47 var gDefaultPreferHwVideoCodec = null; |
| 48 |
| 49 /** |
| 44 * Flag to indicate if Opus Dtx should be enabled. | 50 * Flag to indicate if Opus Dtx should be enabled. |
| 45 * @private | 51 * @private |
| 46 */ | 52 */ |
| 47 var gOpusDtx = false; | 53 var gOpusDtx = false; |
| 48 | 54 |
| 49 /** @private */ | 55 /** @private */ |
| 50 var gNegotiationNeededCount = 0; | 56 var gNegotiationNeededCount = 0; |
| 51 | 57 |
| 52 // Public interface to tests. These are expected to be called with | 58 // Public interface to tests. These are expected to be called with |
| 53 // ExecuteJavascript invocations from the browser tests and will return answers | 59 // ExecuteJavascript invocations from the browser tests and will return answers |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 returnToTest('ok'); | 121 returnToTest('ok'); |
| 116 } | 122 } |
| 117 | 123 |
| 118 /** | 124 /** |
| 119 * Sets the default video codec to be used when creating an offer and returns | 125 * Sets the default video codec to be used when creating an offer and returns |
| 120 * "ok" to test. | 126 * "ok" to test. |
| 121 * @param {string} videoCodec promotes the specified codec to be the default | 127 * @param {string} videoCodec promotes the specified codec to be the default |
| 122 * video codec, e.g. the first one in the list on the 'm=video' SDP offer | 128 * video codec, e.g. the first one in the list on the 'm=video' SDP offer |
| 123 * line. |videoCodec| is the case-sensitive codec name, e.g. 'VP8' or | 129 * line. |videoCodec| is the case-sensitive codec name, e.g. 'VP8' or |
| 124 * 'H264'. | 130 * 'H264'. |
| 131 * @param {bool} preferHwVideoCodec specifies what codec to use from the |
| 132 * 'm=video' line when there are multiple codecs with the name |videoCodec|. |
| 133 * If true, it will return the last codec with that name, and if false, it |
| 134 * will return the first codec with that name. |
| 125 */ | 135 */ |
| 126 function setDefaultVideoCodec(videoCodec) { | 136 function setDefaultVideoCodec(videoCodec, preferHwVideoCodec) { |
| 127 gDefaultVideoCodec = videoCodec; | 137 gDefaultVideoCodec = videoCodec; |
| 138 gDefaultPreferHwVideoCodec = preferHwVideoCodec; |
| 128 returnToTest('ok'); | 139 returnToTest('ok'); |
| 129 } | 140 } |
| 130 | 141 |
| 131 /** | 142 /** |
| 132 * Creates a data channel with the specified label. | 143 * Creates a data channel with the specified label. |
| 133 * Returns 'ok-created' to test. | 144 * Returns 'ok-created' to test. |
| 134 */ | 145 */ |
| 135 function createDataChannel(label) { | 146 function createDataChannel(label) { |
| 136 peerConnection_().createDataChannel(label); | 147 peerConnection_().createDataChannel(label); |
| 137 returnToTest('ok-created'); | 148 returnToTest('ok-created'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 149 function(localOffer) { | 160 function(localOffer) { |
| 150 success('createOffer'); | 161 success('createOffer'); |
| 151 | 162 |
| 152 setLocalDescription(peerConnection, localOffer); | 163 setLocalDescription(peerConnection, localOffer); |
| 153 if (gDefaultAudioCodec !== null) { | 164 if (gDefaultAudioCodec !== null) { |
| 154 localOffer.sdp = setSdpDefaultAudioCodec(localOffer.sdp, | 165 localOffer.sdp = setSdpDefaultAudioCodec(localOffer.sdp, |
| 155 gDefaultAudioCodec); | 166 gDefaultAudioCodec); |
| 156 } | 167 } |
| 157 if (gDefaultVideoCodec !== null) { | 168 if (gDefaultVideoCodec !== null) { |
| 158 localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, | 169 localOffer.sdp = setSdpDefaultVideoCodec(localOffer.sdp, |
| 159 gDefaultVideoCodec); | 170 gDefaultVideoCodec, |
| 171 gDefaultPreferHwVideoCodec); |
| 160 } | 172 } |
| 161 if (gOpusDtx) { | 173 if (gOpusDtx) { |
| 162 localOffer.sdp = setOpusDtxEnabled(localOffer.sdp); | 174 localOffer.sdp = setOpusDtxEnabled(localOffer.sdp); |
| 163 } | 175 } |
| 164 returnToTest('ok-' + JSON.stringify(localOffer)); | 176 returnToTest('ok-' + JSON.stringify(localOffer)); |
| 165 }, | 177 }, |
| 166 function(error) { failure('createOffer', error); }, | 178 function(error) { failure('createOffer', error); }, |
| 167 constraints); | 179 constraints); |
| 168 } | 180 } |
| 169 | 181 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 function parseJson_(json) { | 552 function parseJson_(json) { |
| 541 // Escape since the \r\n in the SDP tend to get unescaped. | 553 // Escape since the \r\n in the SDP tend to get unescaped. |
| 542 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); | 554 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); |
| 543 try { | 555 try { |
| 544 return JSON.parse(jsonWithEscapedLineBreaks); | 556 return JSON.parse(jsonWithEscapedLineBreaks); |
| 545 } catch (exception) { | 557 } catch (exception) { |
| 546 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + | 558 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + |
| 547 exception); | 559 exception); |
| 548 } | 560 } |
| 549 } | 561 } |
| OLD | NEW |