Skip to content

Commit

Permalink
Merge pull request webrtc#1534 from fippo/restart-fix
Browse files Browse the repository at this point in the history
ice-restart: fix functionality
  • Loading branch information
fippo authored Apr 6, 2022
2 parents 61fa9fa + b83125d commit d7114f1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
test:
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
browser: [chrome]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"start": "http-server . -c-1",
"test": "npm run eslint && npm run stylelint",
"eslint": "eslint 'src/content/**/*.js'",
"mocha": "mocha 'src/content/**/test.js'",
"mocha": "mocha --timeout 5000 'src/content/**/test.js'",
"stylelint": "stylelint 'src/**/*.css'"
},
"eslintIgnore": [
"'**/third_party/*.js'"
],
"devDependencies": {
"chai": "^4.3.6",
"chromedriver": "^98.0.1",
"chromedriver": ">98.0.1",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"geckodriver": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/content/datachannel/filetransfer/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let driver;
const path = '/src/content/datachannel/filetransfer/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe('datachannel basic', () => {
describe('datachannel filetransfer', () => {
before(() => {
driver = seleniumHelpers.buildDriver();
});
Expand Down
23 changes: 19 additions & 4 deletions src/content/peerconnection/restart-ice/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ remoteVideo.addEventListener('loadedmetadata', function() {
console.log(`Remote video videoWidth: ${this.videoWidth}px, videoHeight: ${this.videoHeight}px`);
});

const useSelectedCandidatePairChange = window.RTCIceTransport && 'onselectedcandidatepairchange' in RTCIceTransport.prototype;

remoteVideo.onresize = () => {
console.log(`Remote video size changed to ${remoteVideo.videoWidth}x${remoteVideo.videoHeight}`);
// We'll use the first onsize callback as an indication that video has started
Expand Down Expand Up @@ -170,6 +172,18 @@ function onCreateAnswerSuccess(desc) {
pc2.setLocalDescription(desc).then(() => onSetLocalSuccess(pc2), onSetSessionDescriptionError);
console.log('pc1 setRemoteDescription start');
pc1.setRemoteDescription(desc).then(() => onSetRemoteSuccess(pc1), onSetSessionDescriptionError);

if (useSelectedCandidatePairChange) {
pc1.getSenders()[0].transport.iceTransport.onselectedcandidatepairchange = () => {
checkStats(pc1);
if (pc1.iceConnectionState === 'connected') {
restartButton.disabled = false;
}
};
pc2.getSenders()[0].transport.iceTransport.onselectedcandidatepairchange = () => {
checkStats(pc2);
};
}
}

function onIceCandidate(pc, event) {
Expand All @@ -191,10 +205,11 @@ function onIceStateChange(pc, event) {
if (pc) {
console.log(`${getName(pc)} ICE state: ${pc.iceConnectionState}`);
console.log('ICE state change event: ', event);
// TODO: get rid of this in favor of http://w3c.github.io/webrtc-pc/#widl-RTCIceTransport-onselectedcandidatepairchange
if (pc.iceConnectionState === 'connected' ||
pc.iceConnectionState === 'completed') {
checkStats(pc);
if (!useSelectedCandidatePairChange) {
if (pc.iceConnectionState === 'connected' ||
pc.iceConnectionState === 'completed') {
checkStats(pc);
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/content/peerconnection/restart-ice/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let driver;
const path = '/src/content/peerconnection/restart-ice/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;

describe.skip('peerconnection ice restart', () => {
describe('peerconnection ice restart', () => {
before(() => {
driver = seleniumHelpers.buildDriver();
});
Expand Down Expand Up @@ -58,7 +58,6 @@ describe.skip('peerconnection ice restart', () => {
await driver.wait(() => driver.findElement(webdriver.By.id('restartButton')).isEnabled());
await driver.findElement(webdriver.By.id('restartButton')).click();

await driver.wait(() => !driver.findElement(webdriver.By.id('restartButton')).isEnabled());
await driver.wait(() => driver.findElement(webdriver.By.id('restartButton')).isEnabled());

const secondCandidateIds = await Promise.all([
Expand Down

0 comments on commit d7114f1

Please sign in to comment.