From ebc80b5f016dd28c39dc74467928018f5665d838 Mon Sep 17 00:00:00 2001 From: Shuhei Tanuma Date: Sat, 28 Oct 2023 20:41:08 +0900 Subject: [PATCH] Add Pli handler to C API --- include/rtc/rtc.h | 4 ++++ src/capi.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/include/rtc/rtc.h b/include/rtc/rtc.h index db0754848..6df2ce700 100644 --- a/include/rtc/rtc.h +++ b/include/rtc/rtc.h @@ -157,6 +157,7 @@ typedef void *(RTC_API *rtcInterceptorCallbackFunc)(int pc, const char *message, void *ptr); typedef void(RTC_API *rtcBufferedAmountLowCallbackFunc)(int id, void *ptr); typedef void(RTC_API *rtcAvailableCallbackFunc)(int id, void *ptr); +typedef void(RTC_API *rtcPliHandlerCallbackFunc)(); // Log @@ -369,6 +370,9 @@ RTC_C_EXPORT int rtcChainRtcpSrReporter(int tr); // Chain RtcpNackResponder to handler chain for given track RTC_C_EXPORT int rtcChainRtcpNackResponder(int tr, unsigned int maxStoredPacketsCount); +// Chain PliHandler to handler chain for given track +RTC_C_EXPORT int rtcChainPliHandler(int tr, rtcPliHandlerCallbackFunc onPli); + // Transform seconds to timestamp using track's clock rate, result is written to timestamp RTC_C_EXPORT int rtcTransformSecondsToTimestamp(int id, double seconds, uint32_t *timestamp); diff --git a/src/capi.cpp b/src/capi.cpp index ffea82c29..d840ff60d 100644 --- a/src/capi.cpp +++ b/src/capi.cpp @@ -1338,6 +1338,15 @@ int rtcChainRtcpNackResponder(int tr, unsigned int maxStoredPacketsCount) { }); } +int rtcChainPliHandler(int tr, rtcPliHandlerCallbackFunc onPli) { + return wrap([tr, onPli] { + auto responder = std::make_shared(onPli); + auto chainableHandler = getMediaChainableHandler(tr); + chainableHandler->addToChain(responder); + return RTC_ERR_SUCCESS; + }); +} + int rtcTransformSecondsToTimestamp(int id, double seconds, uint32_t *timestamp) { return wrap([&] { auto config = getRtpConfig(id);