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