Reputation: 8053
Using libdatachannel, I establish a PeerConnection
between two partners using some out-of-band signaling. I can create DataChannel
s and send data between them successfully (with peer_connection->createDataChannel()
).
But I am struggling to do the same with a video track. Here is what I do:
rtc::Description::Video media("myvideo", rtc::Description::Direction::RecvOnly);
media.addH264Codec(96);
media.setBitrate(3000);
auto track = peer_connection->addTrack(media);
peer_connection->setLocalDescription();
Note how I call setLocalDescription()
after addTrack
, so that libdatachannel will negotiate the track and I don't need to send an SDP out of band (at least that's my understanding).
onTrack()
callback:peer_connection->onTrack([this](const std::shared_ptr<rtc::Track>& track) {
track->onClosed([]() {
std::cout << "onClosed" << std::endl;
});
track->onOpen([]() {
std::cout << "onOpen" << std::endl;
if (track->isOpen()) {
std::cout << "track is open" << std::endl;
} else {
std::cout << "track is not open" << std::endl;
}
});
}
What I observe is that onTrack
is called, and the track
has the mid
I set from the sending side ("myvideo"). But right in the onOpen()
callback, the call to track->isOpen()
says that "track is not open".
If I try to use the track later (with e.g. track->send()
), if fails with a SIGABRT:
terminate called after throwing an instance of 'std::runtime_error'
what(): Track is closed
Signal: SIGABRT (Aborted)
So somehow it feels like my track was never properly open in the first place. Though I would expect track->onOpen()
to be called... when the track is open.
Am I missing something?
Upvotes: 0
Views: 366