Skip to content

Commit

Permalink
Do not create a std::vector in Consumer::GetRtpStreams() (#902)
Browse files Browse the repository at this point in the history
No need to allocate that memory every time the method is called, which
is done every time a RTCP Compound packet is sent out. Return a
reference to the original vector instead.
  • Loading branch information
jmillan authored Sep 9, 2022
1 parent 688327a commit bba2aa0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion worker/include/RTC/Consumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace RTC
virtual void ApplyLayers() = 0;
virtual uint32_t GetDesiredBitrate() const = 0;
virtual void SendRtpPacket(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) = 0;
virtual std::vector<RTC::RtpStreamSend*> GetRtpStreams() = 0;
virtual const std::vector<RTC::RtpStreamSend*>& GetRtpStreams() const = 0;
virtual void GetRtcp(
RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t nowMs) = 0;
virtual void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) = 0;
Expand Down
2 changes: 1 addition & 1 deletion worker/include/RTC/PipeConsumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace RTC
uint32_t GetDesiredBitrate() const override;
void SendRtpPacket(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t nowMs) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override
const std::vector<RTC::RtpStreamSend*>& GetRtpStreams() const override
{
return this->rtpStreams;
}
Expand Down
2 changes: 1 addition & 1 deletion worker/include/RTC/SimpleConsumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace RTC
void ApplyLayers() override;
uint32_t GetDesiredBitrate() const override;
void SendRtpPacket(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override
const std::vector<RTC::RtpStreamSend*>& GetRtpStreams() const override
{
return this->rtpStreams;
}
Expand Down
2 changes: 1 addition & 1 deletion worker/include/RTC/SimulcastConsumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace RTC
uint32_t GetDesiredBitrate() const override;
void SendRtpPacket(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t nowMs) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override
const std::vector<RTC::RtpStreamSend*>& GetRtpStreams() const override
{
return this->rtpStreams;
}
Expand Down
2 changes: 1 addition & 1 deletion worker/include/RTC/SvcConsumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace RTC
uint32_t GetDesiredBitrate() const override;
void SendRtpPacket(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, RTC::RtpStreamSend* rtpStream, uint64_t nowMs) override;
std::vector<RTC::RtpStreamSend*> GetRtpStreams() override
const std::vector<RTC::RtpStreamSend*>& GetRtpStreams() const override
{
return this->rtpStreams;
}
Expand Down

0 comments on commit bba2aa0

Please sign in to comment.