No video track visible on browser side in webrtc-internals when libdatachannel as answere with sending data and browser as offere with receive only data. #1477
Replies: 1 comment 2 replies
-
|
If you want to send a predefined media stream, you should offer from sender. If you really want to answer from sender, you have to look into the media description to find a suitable format among what's offered. In particular, you must send a media format matching offered payload types. Do not match tracks according to If you want to send raw frames instead of RTP packets, simply add a packetizer in std::shared_ptr<rtc::Track> videoTrack;
int payloadType = -1;
uint32_t ssrc = 42; // your sent SSRC
[...]
void WebrtcManager::OnTrack(std::shared_ptr<rtc::Track> track) {
auto desc = track->description();
std::cout << "Track description: " << std::string(desc) << endl;
if (desc.direction() == rtc::Description::Direction::RecvOnly) // recvonly appears as sendonly on this side
return;
// Find a format we can send
for(int pt : desc.payloadTypes()) {
auto rtpMap = desc.rtpMap(pt);
if (rtpMap.format == "H264") { // for instance
// If you want to send this format, you must use payload type pt
payloadType = pt;
desc.addSSRC(ssrc, "mycname"); // Add sent SSRC
track->setDescription(std::move(desc));
// You could also add a packetizer to the track here if you want to send raw frames instead of RTP packets
// track->chainMediaHandler(packetizer);
std::atomic_store(&videoTrack, track);
break;
}
}
});
[...]
// Once the track is open you must send with payloadType and ssrc
// Assume buffer contains an RTP packet of length len
auto track = std::atomic_load(videoTrack);
if (track && len >= sizeof(rtc::RtpHeader)) {
auto rtp = reinterpret_cast<rtc::RtpHeader *>(buffer);
rtp->setPayloadType(static_cast<uint8_t>(payloadType));
rtp->setSsrc(ssrc);
track->send(reinterpret_cast<const std::byte *>(buffer), len);
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created code in c++ with libdatachannel. On Browser Side used below client.js code block for track adding
On Server Side I am checking On Track Callback and used that videotrack pointer for sending the RTP packet. RTP packet generating manually with fix SSRC and payload type received from Offer.
after that I am sending packet using send function. data sending log visible. but no Video or tracks stats visible on browser side or in chrome:/wbertc-internal page.
Can you help me to identify any error in usage of libdatachannel. can I use RTPpacketizer on sender side with answerer. Can you please provide me code snippet that I can use of.
OFFER FROM BROWSER SIDE
(IP masked) Please reveiew and update
Beta Was this translation helpful? Give feedback.
All reactions