Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ICE candidate event handlers #546

Merged
merged 1 commit into from
Mar 25, 2019
Merged

Add ICE candidate event handlers #546

merged 1 commit into from
Mar 25, 2019

Conversation

albrow
Copy link
Contributor

@albrow albrow commented Mar 22, 2019

Description

Add OnICECandidate and OnICEGatheringStateChange methods to PeerConnection. The main goal of this change is to improve API compatibility with the JavaScript/Wasm bindings. It does not actually add trickle ICE support or change the ICE candidate gathering process, which is still synchronous in the Go implementation. Rather, it fires the appropriate events similar to they way they would be fired in a true trickle ICE process.

@backkem backkem added the review label Mar 22, 2019
@albrow
Copy link
Contributor Author

albrow commented Mar 22, 2019

This PR doesn't add all methods related to ICE candidate gathering. Before we merge this PR, I plan to make another pass to see if there are any other easy changes to make the Go and JavaScript/Wasm APIs more similar.

@coveralls
Copy link

coveralls commented Mar 22, 2019

Pull Request Test Coverage Report for Build 2657

  • 25 of 40 (62.5%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.2%) to 81.233%

Changes Missing Coverage Covered Lines Changed/Added Lines %
peerconnection.go 25 40 62.5%
Files with Coverage Reduction New Missed Lines %
internal/ice/candidatepair.go 2 89.55%
internal/ice/candidate.go 2 91.11%
Totals Coverage Status
Change from base Build 2649: -0.2%
Covered Lines: 4112
Relevant Lines: 5062

💛 - Coveralls

@albrow
Copy link
Contributor Author

albrow commented Mar 22, 2019

There are still potentially more event handlers or methods to add in the future, but I've done all I want to do for this PR. The Go implementation and the JavaScript/Wasm bindings now have matching function signatures and similar enough behavior for OnICECandidate and OnICEGatheringStateChange.

if pc.onICEGatheringStateChangeHandler != nil {
// Note: Gathering is already done at this point, but some clients might
// still expect the state change handler to be triggered.
pc.onICEGatheringStateChangeHandler()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to call this in a goroutine (copying how onTrack does it) otherwise someone via the API could do something blocking (and then pc.mu.Lock() could be held for a long time)

Copy link
Member

@Sean-Der Sean-Der left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this!

Just small nits on holding locks when calling public API, beyond that LGTM!

@albrow
Copy link
Contributor Author

albrow commented Mar 25, 2019

@Sean-Der I applied changes based on your feedback. Ready for another look.

@Sean-Der Sean-Der self-requested a review March 25, 2019 19:11
Copy link
Member

@Sean-Der Sean-Der left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Do you feel good about it testing wise? It might be nice to assert we get candidates or we got a nil, also another useful test is the blocking in the callbacks doesn't break anything.

Also mind squashing down into single commit? Just nice in case we have to revert things, but if you think it makes history reading harder in this case feel free to disregard!

@albrow
Copy link
Contributor Author

albrow commented Mar 25, 2019

Do you feel good about it testing wise? It might be nice to assert we get candidates or we got a nil, also another useful test is the blocking in the callbacks doesn't break anything.

Testing could definitely be improved, but I think it's good enough for now. The updated signalPair function uses the OnICECandidate event handler, and signalPair is used in a lot of places. OnICEGatheringStateChange doesn't have any test coverage but it's also really simple.

@albrow
Copy link
Contributor Author

albrow commented Mar 25, 2019

And yes, I'll squash before merging.

Add OnICECandidate and OnICEGatheringStateChange methods to
PeerConnection. The main goal of this change is to improve API
compatibility with the JavaScript/Wasm bindings. It does not actually
add trickle ICE support or change the ICE candidate gathering process,
which is still synchronous in the Go implementation. Rather, it fires
the appropriate events similar to they way they would be fired in a true
trickle ICE process.

Remove unused OnNegotiationNeeded event handler. This handler is not
required for most applications and would be difficult to implement in
Go. This commit removes the handler from the JavaScript/Wasm bindings,
which leads to a more similar API for Go and JavaScript/Wasm.

Add OnICEGatheringStateChange to the JavaScript/Wasm bindings. Also
changes the Go implementation so that the function signatures match.
@albrow albrow force-pushed the ice-gathering-events branch 2 times, most recently from 53c0629 to b24bea3 Compare March 25, 2019 20:30
@albrow albrow merged commit 5ee8b1a into master Mar 25, 2019
@albrow albrow deleted the ice-gathering-events branch March 25, 2019 21:22
@backkem backkem removed the review label Mar 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants