Skip to content

Commit

Permalink
Upgrade streamer example to remove deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Oct 27, 2023
1 parent 0e4d6a4 commit d9d61ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
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 d9d61ff

Please sign in to comment.