Hi all,
This is my class MySendTransportListener
class MySendTransportListener:public mediasoupclient::SendTransport::Listener
{
public:
MySendTransportListener(EchoClient *sigClient);
std::future<void> OnConnect(mediasoupclient::Transport* transport, const nlohmann::json& dtlsParameters) override;
std::future<std::string> OnProduce(
mediasoupclient::SendTransport* transport,
const std::string& kind,
nlohmann::json rtpParameters,
const nlohmann::json& appData) override;
void OnConnectionStateChange(mediasoupclient::Transport* transport, const std::string& connectionState) override;
private:
EchoClient *mySignaling;
};
MySendTransportListener::MySendTransportListener(EchoClient * sigClient)
:mySignaling(sigClient)
{
}
std::future<void> MySendTransportListener::OnConnect(mediasoupclient::Transport * transport, const nlohmann::json & dtlsParameters)
{
qDebug() << "enter MySendTransportListener::OnConnect()";
std::promise<void> promise;
Json body =
{
{ "transportId", transport->GetId() },
{ "dtlsParameters", dtlsParameters }
};
// Signal local DTLS parameters to the server side transport.
mySignaling->requestBy("connectWebRtcTransport", 4, body);
// [...] Let's assume code execution continues once we get a success response
// from the server.
// Fullfill the promise and return its future.
promise.set_value();
return promise.get_future();
}
std::future<std::string> MySendTransportListener::OnProduce(
mediasoupclient::SendTransport* transport,
const std::string& kind,
nlohmann::json rtpParameters,
const nlohmann::json& appData)
{
qDebug() << "enter MySendTransportListener::OnProduce()";
std::promise<std::string> promise;
Json body =
{
{ "transportId", transport->GetId() },
{ "kind", kind },
{ "rtpParameters", rtpParameters },
{ "appData", appData }
};
mySignaling->requestBy("produce", 5, body);
while (mySignaling->req_produce_res == NULL) {}
Json response = mySignaling->req_produce_res;
// [...] Let's assume code execution continues once we get a success response
// from the server.
// Read the id in the response.
auto idIt = response.find("id");
if (idIt == response.end() || !idIt->is_string())
{
promise.set_exception(
std::make_exception_ptr("'id' missing/invalid in response"));
}
// Fullfill the promise with the id in the response and return its future.
promise.set_value(idIt->get<std::string>());
return promise.get_future();
}
and I create the _sendTransport
void ChatWindow::doReq1()
{
qDebug() << "doReq1()";
auto* sendTransportListener = new MySendTransportListener(sigClient);
// This will block the current thread until completion.
_sendTransport = _mediasoupDevice->CreateSendTransport(
sendTransportListener,
sigClient->transportInfo["id"],
sigClient->transportInfo["iceParameters"],
sigClient->transportInfo["iceCandidates"],
sigClient->transportInfo["dtlsParameters"]);
qDebug() << "doReq1() ok";
}
is Ok until now
then i produce
class MyProducerListener : public mediasoupclient::Producer::Listener
{
public:
void OnTransportClose(mediasoupclient::Producer * producer);
};
void MyProducerListener::OnTransportClose(mediasoupclient::Producer* producer)
{
qDebug() << "[MyProducerListener::OnTransportClose] transport closed";
}
void ChatWindow::prepareProduceAndConsume()
{
Json codecOptions =
{
{ "opusStereo", true },
{ "opusDtx", true }
};
auto* audioProducerListener = new MyProducerListener();
mediasoupclient::Producer *_micProducer = _sendTransport->Produce(
audioProducerListener,
sigClient->audio_track,
nullptr,
&codecOptions);
qDebug() << "_micProducer Ready";
std::vector<webrtc::RtpEncodingParameters> encodings;
encodings.emplace_back(webrtc::RtpEncodingParameters());
encodings.emplace_back(webrtc::RtpEncodingParameters());
encodings.emplace_back(webrtc::RtpEncodingParameters());
auto* videoProducerListener = new MyProducerListener();
// This will block the current thread until completion.
mediasoupclient::Producer *_webcamProducer = _sendTransport->Produce(
videoProducerListener,
sigClient->video_track_,
&encodings,
nullptr);
qDebug() << "_webcamProducer Ready";
}
And No errors, just block, no debug message print which means no firing Onconnect or OnProduce Events
local audio and video track is ok, can show in the window
Any help would be greatly appreciated.