Added a requestKeyframe()

This commit is contained in:
Staz M
2020-10-20 01:52:11 -04:00
parent 0fad9c0a16
commit 1cb53362d1
5 changed files with 27 additions and 2 deletions

View File

@ -58,6 +58,8 @@ public:
*/
void onOutgoing(const std::function<void(rtc::message_ptr)>& cb);
virtual bool requestKeyframe() {return false;}
};
class Track;
@ -72,10 +74,14 @@ public:
void requestBitrate(unsigned int newBitrate);
bool requestKeyframe() override;
protected:
void pushREMB(unsigned int bitrate);
void pushRR(unsigned int lastSR_delay);
void pushPLI();
unsigned int mRequestedBitrate = 0;
SSRC mSsrc = 0;
uint32_t mGreatestSeqNo = 0;

View File

@ -55,6 +55,8 @@ public:
size_t availableAmount() const override;
std::optional<message_variant> receive() override;
bool requestKeyframe();
// RTCP handler
void setRtcpHandler(std::shared_ptr<RtcpHandler> handler);

View File

@ -573,8 +573,7 @@ void PeerConnection::forwardMedia(message_ptr message) {
mMidFromSssrc.emplace(ssrc, *found);
mid = *found;
break;
}else
PLOG_WARNING << "Unknown SSRC " << ssrc;
}
}
}

View File

@ -123,6 +123,18 @@ bool RtcpReceivingSession::send(message_ptr msg) {
return false;
}
bool RtcpReceivingSession::requestKeyframe() {
pushPLI();
return true; // TODO Make this false when it is impossible (i.e. Opus).
}
void RtcpReceivingSession::pushPLI() {
auto msg = rtc::make_message(rtc::RTCP_PLI::size(), rtc::Message::Type::Control);
auto *pli = (rtc::RTCP_PLI *) msg->data();
pli->preparePacket(mSsrc);
send(msg);
}
void RtcpHandler::onOutgoing(const std::function<void(rtc::message_ptr)>& cb) {
this->outgoingCallback = synchronized_callback<rtc::message_ptr>(cb);
}

View File

@ -152,5 +152,11 @@ void Track::setRtcpHandler(std::shared_ptr<RtcpHandler> handler) {
});
}
bool Track::requestKeyframe() {
if (mRtcpHandler)
return mRtcpHandler->requestKeyframe();
return false;
}
} // namespace rtc