Skip to content

Commit

Permalink
Upgrade examples to remove deprecated API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Oct 28, 2023
1 parent b67cf0f commit efab23b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
7 changes: 3 additions & 4 deletions examples/media-sfu/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ int main() {

auto track = pc->addTrack(media);

auto session = std::make_shared<rtc::RtcpReceivingSession>();
track->setMediaHandler(session);
track->setMediaHandler(std::make_shared<rtc::RtcpReceivingSession>());

const rtc::SSRC targetSSRC = 42;
track->onMessage(
Expand Down Expand Up @@ -101,8 +100,8 @@ int main() {

r->track = r->conn->addTrack(media);

r->track->onOpen([session]() {
session->requestKeyframe(); // So the receiver can start playing immediately
r->track->onOpen([r]() {
r->track->requestKeyframe(); // So the receiver can start playing immediately
});
r->track->onMessage([](rtc::binary var) {}, nullptr);

Expand Down
18 changes: 7 additions & 11 deletions examples/streamer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,14 @@ shared_ptr<ClientTrackData> addVideo(const shared_ptr<PeerConnection> pc, const
auto rtpConfig = make_shared<RtpPacketizationConfig>(ssrc, cname, payloadType, H264RtpPacketizer::defaultClockRate);
// create packetizer
auto packetizer = make_shared<H264RtpPacketizer>(NalUnit::Separator::Length, rtpConfig);
// create H264 handler
auto h264Handler = make_shared<H264PacketizationHandler>(packetizer);
// add RTCP SR handler
auto srReporter = make_shared<RtcpSrReporter>(rtpConfig);
h264Handler->addToChain(srReporter);
packetizer->addToChain(srReporter);
// add RTCP NACK handler
auto nackResponder = make_shared<RtcpNackResponder>();
h264Handler->addToChain(nackResponder);
packetizer->addToChain(nackResponder);
// set handler
track->setMediaHandler(h264Handler);
track->setMediaHandler(packetizer);
track->onOpen(onOpen);
auto trackData = make_shared<ClientTrackData>(track, srReporter);
return trackData;
Expand All @@ -232,19 +230,17 @@ shared_ptr<ClientTrackData> addAudio(const shared_ptr<PeerConnection> pc, const
audio.addSSRC(ssrc, cname, msid, cname);
auto track = pc->addTrack(audio);
// create RTP configuration
auto rtpConfig = make_shared<RtpPacketizationConfig>(ssrc, cname, payloadType, OpusRtpPacketizer::defaultClockRate);
auto rtpConfig = make_shared<RtpPacketizationConfig>(ssrc, cname, payloadType, OpusRtpPacketizer::DefaultClockRate);
// create packetizer
auto packetizer = make_shared<OpusRtpPacketizer>(rtpConfig);
// create opus handler
auto opusHandler = make_shared<OpusPacketizationHandler>(packetizer);
// add RTCP SR handler
auto srReporter = make_shared<RtcpSrReporter>(rtpConfig);
opusHandler->addToChain(srReporter);
packetizer->addToChain(srReporter);
// add RTCP NACK handler
auto nackResponder = make_shared<RtcpNackResponder>();
opusHandler->addToChain(nackResponder);
packetizer->addToChain(nackResponder);
// set handler
track->setMediaHandler(opusHandler);
track->setMediaHandler(packetizer);
track->onOpen(onOpen);
auto trackData = make_shared<ClientTrackData>(track, srReporter);
return trackData;
Expand Down
2 changes: 1 addition & 1 deletion examples/streamer/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StreamSource {
virtual rtc::binary getSample() = 0;
};

class Stream: std::enable_shared_from_this<Stream> {
class Stream: public std::enable_shared_from_this<Stream> {
uint64_t startTime = 0;
std::mutex mutex;
DispatchQueue dispatchQueue = DispatchQueue("StreamQueue");
Expand Down

0 comments on commit efab23b

Please sign in to comment.