-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Modernize #70
Comments
Eventually I get this error when running the tests (just a few times):
So it happens when calling UPDATE: More detailed crash:
Again: it happens randomly. It seems there is some race condition in some thread. |
We have a problem with the current API. This is createSendTransport(
{
id,
iceParameters,
iceCandidates,
dtlsParameters,
sctpParameters,
iceServers,
iceTransportPolicy,
additionalSettings,
proprietaryConstraints,
appData = {}
}: TransportOptions
): Transport However this is SendTransport* Device::CreateSendTransport(
SendTransport::Listener* listener,
const std::string& id,
const json& iceParameters,
const json& iceCandidates,
const json& dtlsParameters,
const PeerConnection::Options* peerConnectionOptions,
const json& appData) const We cannot extend the C++ method signature without breaking its API. Just wondering if we should have used an object from the very beginning instead of multiple arguments. /cc @jmillan |
As commented via phone lets create this new signature and also maintain the previous one: SendTransport* Device::CreateSendTransport(
SendTransport::Listener* listener,
const std::string& id,
const json& iceParameters,
const json& iceCandidates,
const json& dtlsParameters,
const json& sctpParameters,
const PeerConnection::Options* peerConnectionOptions,
const json& appData) const |
BTW added a bullet in the list above. cc/ @jmillan |
Picking up on the discussion above, just my 2 cents: If you want to go more in the direction of having a similar API with mediasoup-client, you will lose some of the opportunities that the (c++) language offers. Take for example the "produce" event vs. the OnProduce() callback. Since OnProduce() is pure virtual, the user has to implement it, otherwise the user's code won't compile. The mediasoup-client app will still "build" even if the "produce" event is not listened to. Of course, there is no "better way", it really depends on what is more important to you. |
What is the purpose of calling |
True, but it will throw only at runtime. C++ won't even build. Of course there's no logic in calling Produce without listening on the "produce" event. But since you can enforce it at compile time, it might make your library a bit more resilient (and possibly avoid some questions on the forums). |
I don't understand your point now. In fact you said:
now you say:
and that's exactly what we do now. Mandate the user to define |
I'm saying that there is a difference of behavior between mediasoup-client and libmediasoup. Anyway, not important. It's good that you mandate the implementation of OnProduce(). |
@jmillan can you please update checkboxes in the issue description above? |
It's up to date. |
Just to add to the OnProduce discussion. Maybe another way to look at it is with OnProduceData(). I don't use data producers or consumers and so it feels awkward that the compiler requires me to implement OnProduceData(). Especially because my implementation isn't just an empty method, it's a method that creates an exception that states that I haven't implemented data producers and returns a future that's already in an error state. I think it would make sense for the interface to provide a default implementation that does this for all methods. If you call Produce or ProduceData at runtime and you haven't implemented one of the methods, it will throw and you can implement it. Applications that are only using a limited set of APIs won't be required to implement callbacks for all APIs. Max |
True. But I would actually aim for an even more integrated API, if possible. The way I see it there should be only one callback to be implemented: "OnProduce()". Logically "data" is just another type besides video and audio that mediasoup (WebRTC) can transport, so to me it just feels more natural to have a generic callback to handle all of them. |
I disagree there. If mediasoup sent data via a Producer (as opposed to the separate DataProducer type), I'd agree with you, but they treat them as different paths, and I think that's the correct move given that libwebrtc treats audio/video and data channels separately almost in every layer. It maps nicely if you're working with clients/servers that aren't using mediasoup as well. |
I didn't say the Producer and DataProducer should be consolidated into a single class. I was talking only about the callback, which is mediasoup specific. |
Probably a corner case, but for someone who is ONLY using data producers/consumers might feel awkward that the compiler requires her to implement OnProduce(). |
If they're separate producer classes, but use the same listener type, but the listener is expected to branch based on what type of producer is making the callback you've defeated the purpose of using types in C++ imo. The solution I proposed would not require someone using "ONLY using data producers/consumers" to implement OnProduce() fwiw. If OnProduce and OnProduceData just had their own default implementation that threw an exception, anyone using only audio/video or only data would only have to implement a single listener. And anyone using both wouldn't have to have a runtime check to branch based on which producer type is making the callback. They'd just implement both. |
Yes, this was my initial point. It would also bring it close to the mediasoup-client API, which doesn't enforce implementation of the callbacks.
Unsure if I understand the point. A branching will be needed on the server side to choose between produce() and produceData(), not on the C++ client side. But thinking about it, it would complicate things in other ways like sctp parameters being mandatory for DataChannels but not for audio/video etc. At least now it's clear which parameters need to be sent to the other side. |
Working on
v3
branch.Tasks:
scripts/format.sh
work. I've changed the bashfor
which didn't work but not sure whetherclang-format
is really working as expected.gulpfile.js
that has "lint" and "format" tasks as in mediasoup.clang-tidy
.readability-identifier-naming.GlobalFunctionCase
tocamelBack
(instead ofCamelCase
) since that's how all the code is written, even public API.clang-tidy
ignore code indeps
. We should build deps first, then runtidy.sh
.MediaSections
(delete mediaSection
). See when I closed the Producer, I found that the memory was not freed #69.HandlerInterface
as in mediasoup-client.producer.replaceTrack(null)
(commit in mediasoup-client).transport.produce()
(commit in mediasoup-client).The text was updated successfully, but these errors were encountered: