-
Notifications
You must be signed in to change notification settings - Fork 62
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 SessionID to interceptors #38
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
==========================================
+ Coverage 79.02% 80.65% +1.62%
==========================================
Files 20 22 +2
Lines 577 641 +64
==========================================
+ Hits 456 517 +61
- Misses 81 82 +1
- Partials 40 42 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
0841fab
to
b7a7179
Compare
b7a7179
to
b882b10
Compare
Closes #37. This commit addresses the changes discussed [here][1]. I added `SessionID` to all interceptor methods and ensured that the existing interceptors can be shared by different `PeerConnection`s. I defined an `interceptor.Factory` following AtWat's suggestion. It took a while for this to click for me: I didn't realize that the `interceptor.Registry` contained already prebuilt interceptors. I like the idea of a `Factory` better than implementing `Copy`. I added the `interceptor.Registry.AddFactory` method and modified the internals a little. The new `interceptor.NewChainFromFactories` will now be called from the `Registry`. The `interceptor.SharedFactory` allows us to easily keep the current behavior with existing interceptors. I left a number of TODOs, main bullet points being: 1. I think binding anything before calling `BindRTCPWriter` should be an error, because otherwise it becomes difficult to track state (e.g. if we've started a write loop). But I did not want to add an error return value to all methods before discussing it. If we do decide that calling `BindRTCPWriter` is the first step, then I think it would make sense to pass `RTCPWriter` as an argument to `interceptor.Registry.Build`? 2. We could modify the interceptors to only have a single `loop` goroutine which would go through all SSRCs for all bound sessions at once, but I'm not sure what's the best way to concurrently handle RTCP writes - I'm sure we wouldn't want a hanging RTCPWrite to slow down any other processing or writes. I also think that spinning up an unbounded number of goroutines just to do these writes is not a good idea, so I'm not sure how to processed. I'm open to suggestions. Maybe this shouldn't be a part of this change, but it's something to think about. [1]: pion/webrtc#1749
b882b10
to
22fe480
Compare
Fixed with fd0ded9 We instead went with a factory pattern. State can now be re-used inside of them. |
Closes #37. This commit addresses the changes discussed here.
I added
SessionID
to all interceptor methods and ensured that the existing interceptors can be shared by differentPeerConnection
s.I defined an
interceptor.Factory
following AtWat's suggestion. It took a while for this to click for me: I didn't realize that theinterceptor.Registry
contained already prebuilt interceptors. I like the idea of aFactory
better than implementingCopy
. I added theinterceptor.Registry.AddFactory
method and modified the internals a little. The newinterceptor.NewChainFromFactories
will now be called from theRegistry
.The
interceptor.SharedFactory
allows us to easily keep the current behavior with existing interceptors.I left a number of TODOs which are the main reason the build is currently failing. The main points are:
I think binding anything before calling
BindRTCPWriter
should be an error, because otherwise it becomes difficult to track state (e.g. if we've started a write loop). But I did not want to add an error return value to all methods before discussing it.If we do decide that calling
BindRTCPWriter
is the first step, then I think it would make sense to passRTCPWriter
as an argument tointerceptor.Registry.Build
?We could modify the interceptors to only have a single
loop
goroutine which would go through all SSRCs for all bound sessions at once, but I'm not sure what's the best way to concurrently handle RTCP writes - I'm sure we wouldn't want a hanging RTCPWrite to slow down any other processing or writes.I also don't think that spinning up an unbounded number of goroutines just to do these writes is a good idea, so I'm not sure how to processed. I'm open to suggestions.
Maybe this shouldn't be a part of this change, but it's something to think about.