From 08da5e10b2bc74e833de4e744565a06443c557c7 Mon Sep 17 00:00:00 2001 From: Staz M Date: Mon, 25 Jan 2021 09:35:23 -0500 Subject: [PATCH] refactored to use getRtcpHandler() --- src/track.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/track.cpp b/src/track.cpp index 8dcb0fb..471145d 100644 --- a/src/track.cpp +++ b/src/track.cpp @@ -62,11 +62,8 @@ bool Track::send(message_variant data) { auto message = make_message(std::move(data)); - std::shared_lock lock(mRtcpHandlerMutex); - if (mRtcpHandler) { - auto copy = mRtcpHandler; - lock.unlock(); - message = copy->outgoing(message); + if (auto handler = getRtcpHandler()) { + message = handler->outgoing(message); if (!message) return false; } @@ -125,11 +122,8 @@ void Track::incoming(message_ptr message) { return; } - std::shared_lock lock(mRtcpHandlerMutex); - if (mRtcpHandler) { - auto copy = mRtcpHandler; - lock.unlock(); - message = copy->incoming(message); + if (auto handler = getRtcpHandler()) { + message = handler->incoming(message); if (!message) return; } @@ -175,11 +169,8 @@ void Track::setRtcpHandler(std::shared_ptr handler) { } bool Track::requestKeyframe() { - std::shared_lock lock(mRtcpHandlerMutex); - if (mRtcpHandler) { - auto copy = mRtcpHandler; - lock.unlock(); - return copy->requestKeyframe(); + if (auto handler = getRtcpHandler()) { + return handler->requestKeyframe(); } return false; }