Overriding media acquisition is too hard
See original GitHub issueIs your feature request related to a problem? Please describe.
Maintainers of SIP.js have made clear in several instances (#588, #602, #696) that using a custom MediaStream
as a source instead of getUserMedia()
should be done through the implementation of a custom SessionDescriptionHandler. I’m fine with that.
In 0.14 however, the library has been rewritten in typescript, and most of the methods of Web.SessionDescriptionHandler
are now private. This means that, to implement the rather small change from #588, one is required to reimplement the whole getDescription()
method, while previously overwriting acquire()
was enough.
Duplicating everything adds to the maintenance burden, as it forces to track every change to the upstream class. Bugs can easily slip through. It also means duplicating the whole class including modifier handling, ICE, etc., which are already solved problems.
Describe the solution you’d like
Because of that, would it be possible to devise a way to only override the acquisition part of Web.SessionDescriptionHandler
(ideally, only the actual stream creation part)?
I can imagine two ways this could be implemented, depending on what fits the library style best, while not adding much maintenance burden to SIP.js itself:
- through inheritance, using a protected
getMediaStreams(constraints: any): Promise<MediaStream[]>
method, - through inheritance, by splitting
getDescription()
into individually overridable parts, - though some sort of callback in the
SessionDescriptionHandlerOptions
interface or in events.
Also, due to the way the library uses different options in different contexts (in this case, UA sessionDescriptionHandlerFactoryOptions
at creation time but constructor options at INVITE
time) it might be useful to pass the options along to whatever solution is chosen.
Describe alternatives you’ve considered
I tried implementing a modifier that would add mediastream tracks and call createOffer()
again, but this fails due to Firefox complaining that you cannot call createOffer()
twice.
I could not find any other hook or overridable methods that could make this feature available easily.
Additional context I need to create a session without requesting user device access.
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (10 by maintainers)
Closing this as the proposal was released in 0.17.0.
I pushed 7caeb88f4071902ad4a5c357d5f286bc602921a2 as a first pass at this. Let me know if it covers what you were looking for. We plan to do a bit more work here after the next release is settled.