mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 15:15:28 +00:00
Added Description::addSSRC
This commit is contained in:
@ -65,11 +65,13 @@ int main() {
|
||||
auto session = std::make_shared<rtc::RtcpSession>();
|
||||
track->setRtcpHandler(session);
|
||||
|
||||
const rtc::SSRC targetSSRC = 15;
|
||||
|
||||
track->onMessage(
|
||||
[&receivers](rtc::binary message) {
|
||||
// This is an RTP packet
|
||||
auto rtp = (rtc::RTP*) message.data();
|
||||
rtp->ssrc = htonl(15);
|
||||
rtp->ssrc = htonl(targetSSRC);
|
||||
for (auto pc : receivers) {
|
||||
if (pc->track != nullptr && pc->track->isOpen()) {
|
||||
pc->track->send(message);
|
||||
@ -109,6 +111,8 @@ int main() {
|
||||
media.setBitrate(
|
||||
3000); // Request 3Mbps (Browsers do not encode more than 2.5MBps from a webcam)
|
||||
|
||||
media.addSSRC(targetSSRC, "video-send");
|
||||
|
||||
pc->track = pc->conn->addTrack(media);
|
||||
pc->conn->setLocalDescription();
|
||||
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
Direction direction() const { return mDirection; }
|
||||
void setDirection(Direction dir);
|
||||
|
||||
void addSSRC(uint32_t ssrc, std::string name);
|
||||
|
||||
operator string() const;
|
||||
string generateSdp(string_view eol) const;
|
||||
|
||||
|
@ -374,9 +374,7 @@ Description::Entry::Entry(const string &mline, string mid, Direction dir)
|
||||
ss >> mType;
|
||||
ss >> port; // ignored
|
||||
ss >> mDescription;
|
||||
if (direction() == Direction::SendOnly) {
|
||||
mAttributes.emplace_back("ssrc:15 cname:test");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Description::Entry::setDirection(Direction dir) { mDirection = dir; }
|
||||
@ -444,6 +442,10 @@ void Description::Entry::parseSdpLine(string_view line) {
|
||||
}
|
||||
}
|
||||
|
||||
void Description::Entry::addSSRC(uint32_t ssrc, std::string name) {
|
||||
mAttributes.emplace_back("ssrc:" + std::to_string(ssrc) + " cname:" + name);
|
||||
}
|
||||
|
||||
Description::Application::Application(string mid)
|
||||
: Entry("application 9 UDP/DTLS/SCTP", std::move(mid), Direction::SendRecv) {}
|
||||
|
||||
|
Reference in New Issue
Block a user