Closed richmonkey closed 3 years ago
Need more work to do, Handler.SetupTransport is another async method, Only if precreate local dtlsParameters is possible, the target is possible.
if device.createSendTransport() can get local dtlsParameters after createSendTransport, request server connectTransport with local dtlsParameters . last transport.produce
How to get local dtlsParameters in the step device.createSendTransport()? in handler create peerconnect, add transceiver, createoffer, get dtlsparamters from localsdp, close peerconnection. save the local dtlsParamters in last produce step, when after createoffer, modify the sdp's dtlsparamters field with saved local dtlsParamters, setlocaldescription with the changed sdp. Is it possible?
My opinion:library's listener is async, it's complex for caller, also not good smell.
Transport.produce must be called in thread.
Actually, calls to Transport.produce should be queued somehow, otherwise the handler may try to connect the transport more than once, not to mention that internal manipulations with sdp are not thread-safe.
“calls to Transport.produce should be queued somehow”, I know this. meidasoupclient is not threadsafe. I want to express: So for simple, call meidasoupclient always in one thread, mediasoupcliennt can't be called in ui thread, because Transport.produce is sync method and long time(access network).
This is not a bug. This is by design. Nobody said that libmediasoupclient can be used in UI thread. Please let's use the mediasoup forum for further discussions.
Because Transportlistener->onProducer must access network, so Transport.produce must be called in thread. It's not a issuse, but as a library, it's not very good. Can split transport.produce into two step.
If api like this, it's my free to call mediaclient api in main thread or other thread.