VLprojects / mediasoup-client-swift

Swift wrapper for libmediasoupclient
MIT License
39 stars 16 forks source link

createproducer function returning nil #5

Open satishjkoladiya opened 1 year ago

satishjkoladiya commented 1 year ago

let producer = try? sendTransport.createProducer(for: audioTrack, encodings: nil, codecOptions: nil, appData: nil)

this is returning nil. please help me to resolve this

Mahmoud-Yousef commented 1 year ago

use

do {
    let producer = try sendTransport.createProducer(for: audioTrack, encodings: nil, codecOptions: nil, appData: nil)
} catch {
    print(error.localizedDescription)
}

to catch the error

fedulvtubudul commented 1 year ago

There are several possible reasons. As @Mahmoud-Yousef said, we need more logs to investigate this. At least print out the error thrown by createProducer(...).

What it can be:

  1. SendTransportDelegate not implemented correctly. Make sure you've set transport delegate and implemented onProduce method. This method must talk to your media server via signaling mechanism, your server creates producer on server-side and provides you an id for created producer. onProduce method must call it's callback closure with id provided by your media server.
  2. SendTransport is in incorrect state (yet not connected or already disconnected)
  3. Working with sendTransport from arbitrary thread (all calls to mediasoupclient should be done from the same dedicated thread/queue)
  4. Using codec unsupported by your media server