Browse Source

Rename PliHandler::onPli to mOnPli and convert it to a synchronized
callback

Arda Cinar 1 year ago
parent
commit
56cab34b22
2 changed files with 6 additions and 5 deletions
  1. 3 2
      include/rtc/plihandler.hpp
  2. 3 3
      src/plihandler.cpp

+ 3 - 2
include/rtc/plihandler.hpp

@@ -12,6 +12,7 @@
 #if RTC_ENABLE_MEDIA
 #if RTC_ENABLE_MEDIA
 
 
 #include "mediahandlerelement.hpp"
 #include "mediahandlerelement.hpp"
+#include "utils.hpp"
 #include <functional>
 #include <functional>
 
 
 namespace rtc {
 namespace rtc {
@@ -19,12 +20,12 @@ namespace rtc {
 /// Responds to PLI and FIR messages sent by the receiver. The sender should respond to these
 /// Responds to PLI and FIR messages sent by the receiver. The sender should respond to these
 /// messages by sending an intra. 
 /// messages by sending an intra. 
 class RTC_CPP_EXPORT PliHandler final : public MediaHandlerElement {
 class RTC_CPP_EXPORT PliHandler final : public MediaHandlerElement {
-    std::function<void(void)> onPli;
+    std::function<void(void)> mOnPli;
 
 
 public:
 public:
 	/// Constructs the PLIResponder object to notify whenever a new intra frame is requested
 	/// Constructs the PLIResponder object to notify whenever a new intra frame is requested
 	/// @param onPli The callback that gets called whenever an intra frame is requested by the receiver
 	/// @param onPli The callback that gets called whenever an intra frame is requested by the receiver
-    PliHandler(std::function<void(void)> onPli);
+    PliHandler(rtc::synchronized_callback<> onPli);
     ChainedIncomingControlProduct processIncomingControlMessage(message_ptr) override;
     ChainedIncomingControlProduct processIncomingControlMessage(message_ptr) override;
 };
 };
 
 

+ 3 - 3
src/plihandler.cpp

@@ -21,14 +21,14 @@ ChainedIncomingControlProduct PliHandler::processIncomingControlMessage(message_
 
 
 		if (payload_type == 196) { 
 		if (payload_type == 196) { 
 			// FIR message, call pli handler anyway
 			// FIR message, call pli handler anyway
-			onPli();
+			mOnPli();
 			break;
 			break;
 		} else if (payload_type == 206) {
 		} else if (payload_type == 206) {
 			// On a payload specific fb message, there is a "feedback message type" (FMT) in the
 			// On a payload specific fb message, there is a "feedback message type" (FMT) in the
 			// header instead of a report count. PT = 206, FMT = 1 means a PLI message
 			// header instead of a report count. PT = 206, FMT = 1 means a PLI message
 			uint8_t feedback_message_type = header->reportCount();
 			uint8_t feedback_message_type = header->reportCount();
 			if (feedback_message_type == 1) {
 			if (feedback_message_type == 1) {
-				onPli();
+				mOnPli();
 				break;
 				break;
 			}
 			}
 		}
 		}
@@ -37,7 +37,7 @@ ChainedIncomingControlProduct PliHandler::processIncomingControlMessage(message_
 	return { message, std::nullopt };
 	return { message, std::nullopt };
 }
 }
 
 
-PliHandler::PliHandler(std::function<void(void)> onPli) : onPli(onPli) { }
+PliHandler::PliHandler(rtc::synchronized_callback<> onPli) : mOnPli(onPli) { }
 
 
 }
 }