1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

RTC: Support server hijacker

This commit is contained in:
winlin 2020-08-07 17:04:34 +08:00
parent 73eb60a9d5
commit a1da95c906
2 changed files with 39 additions and 0 deletions

View file

@ -204,9 +204,18 @@ ISrsRtcServerHandler::~ISrsRtcServerHandler()
{
}
ISrsRtcServerHijacker::ISrsRtcServerHijacker()
{
}
ISrsRtcServerHijacker::~ISrsRtcServerHijacker()
{
}
SrsRtcServer::SrsRtcServer()
{
handler = NULL;
hijacker = NULL;
timer = new SrsHourGlass(this, 1 * SRS_UTIME_SECONDS);
}
@ -257,6 +266,11 @@ void SrsRtcServer::set_handler(ISrsRtcServerHandler* h)
handler = h;
}
void SrsRtcServer::set_hijacker(ISrsRtcServerHijacker* h)
{
hijacker = h;
}
srs_error_t SrsRtcServer::listen_udp()
{
srs_error_t err = srs_success;
@ -309,6 +323,18 @@ srs_error_t SrsRtcServer::on_udp_packet(SrsUdpMuxSocket* skt)
}
}
// Notify hijack to handle the UDP packet.
if (hijacker) {
bool consumed = false;
if ((err = hijacker->on_udp_packet(&consumed)) != srs_success) {
return srs_error_wrap(err, "hijack consumed=%u", consumed);
}
if (consumed) {
return err;
}
}
// For STUN, the peer address may change.
if (srs_is_stun((uint8_t*)data, size)) {
SrsStunPacket ping;