diff --git a/src/Common/MediaSink.cpp b/src/Common/MediaSink.cpp index ca0cf734..c3c862b2 100644 --- a/src/Common/MediaSink.cpp +++ b/src/Common/MediaSink.cpp @@ -32,7 +32,6 @@ bool MediaSink::addTrack(const Track::Ptr &track_in) { return false; } } - lock_guard lck(_mtx); if (_all_track_ready) { WarnL << "all track is ready, add this track too late!"; return false; @@ -64,7 +63,6 @@ bool MediaSink::addTrack(const Track::Ptr &track_in) { } void MediaSink::resetTracks() { - lock_guard lck(_mtx); _all_track_ready = false; _track_map.clear(); _track_ready_callback.clear(); @@ -74,7 +72,6 @@ void MediaSink::resetTracks() { } bool MediaSink::inputFrame(const Frame::Ptr &frame) { - lock_guard lck(_mtx); auto it = _track_map.find(frame->getTrackType()); if (it == _track_map.end()) { return false; @@ -135,7 +132,6 @@ void MediaSink::checkTrackIfReady(const Track::Ptr &track){ } void MediaSink::addTrackCompleted(){ - lock_guard lck(_mtx); _max_track_size = _track_map.size(); checkTrackIfReady(nullptr); } @@ -190,7 +186,6 @@ void MediaSink::onAllTrackReady_l() { vector MediaSink::getTracks(bool trackReady) const{ vector ret; - lock_guard lck(_mtx); for (auto &pr : _track_map){ if(trackReady && !pr.second->ready()){ continue; diff --git a/src/Common/MediaSink.h b/src/Common/MediaSink.h index fbe9c2b1..b4154bbc 100644 --- a/src/Common/MediaSink.h +++ b/src/Common/MediaSink.h @@ -148,7 +148,6 @@ private: private: bool _all_track_ready = false; size_t _max_track_size = 2; - mutable recursive_mutex _mtx; unordered_map _track_map; unordered_map > _frame_unread; unordered_map > _track_ready_callback; diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 3fed286c..9281f5b4 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -40,9 +40,7 @@ void RtmpPlayer::teardown() { CLEAR_ARR(_fist_stamp); CLEAR_ARR(_now_stamp); - lock_guard lck(_mtx_on_result); _map_on_result.clear(); - lock_guard lck2(_mtx_on_status); _deque_on_status.clear(); } @@ -271,7 +269,6 @@ inline void RtmpPlayer::send_pause(bool pause) { void RtmpPlayer::onCmd_result(AMFDecoder &dec){ auto req_id = dec.load(); - lock_guard lck(_mtx_on_result); auto it = _map_on_result.find(req_id); if (it != _map_on_result.end()) { it->second(dec); @@ -293,7 +290,6 @@ void RtmpPlayer::onCmd_onStatus(AMFDecoder &dec) { throw std::runtime_error("onStatus:the result object was not found"); } - lock_guard lck(_mtx_on_status); if (_deque_on_status.size()) { _deque_on_status.front()(val); _deque_on_status.pop_front(); diff --git a/src/Rtmp/RtmpPlayer.h b/src/Rtmp/RtmpPlayer.h index cb7fdb15..decd56ae 100644 --- a/src/Rtmp/RtmpPlayer.h +++ b/src/Rtmp/RtmpPlayer.h @@ -65,12 +65,10 @@ protected: template void addOnResultCB(const FUNC &func) { - lock_guard lck(_mtx_on_result); _map_on_result.emplace(_send_req_id, func); } template void addOnStatusCB(const FUNC &func) { - lock_guard lck(_mtx_on_status); _deque_on_status.emplace_back(func); } @@ -98,9 +96,6 @@ private: uint32_t _fist_stamp[2] = {0, 0}; uint32_t _now_stamp[2] = {0, 0}; Ticker _now_stamp_ticker[2]; - - recursive_mutex _mtx_on_result; - recursive_mutex _mtx_on_status; deque > _deque_on_status; unordered_map > _map_on_result; diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index 7a03c830..a5d05590 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -32,14 +32,8 @@ void RtmpPusher::teardown() { _app.clear(); _stream_id.clear(); _tc_url.clear(); - { - lock_guard lck(_mtx_on_result); - _map_on_result.clear(); - } - { - lock_guard lck(_mtx_on_status); - _deque_on_status.clear(); - } + _map_on_result.clear(); + _deque_on_status.clear(); _publish_timer.reset(); reset(); shutdown(SockException(Err_shutdown, "teardown")); @@ -241,7 +235,6 @@ void RtmpPusher::setSocketFlags(){ void RtmpPusher::onCmd_result(AMFDecoder &dec){ auto req_id = dec.load(); - lock_guard lck(_mtx_on_result); auto it = _map_on_result.find(req_id); if (it != _map_on_result.end()) { it->second(dec); @@ -263,7 +256,6 @@ void RtmpPusher::onCmd_onStatus(AMFDecoder &dec) { throw std::runtime_error("onStatus:the result object was not found"); } - lock_guard lck(_mtx_on_status); if (_deque_on_status.size()) { _deque_on_status.front()(val); _deque_on_status.pop_front(); diff --git a/src/Rtmp/RtmpPusher.h b/src/Rtmp/RtmpPusher.h index 3f119ec1..9b8c3604 100644 --- a/src/Rtmp/RtmpPusher.h +++ b/src/Rtmp/RtmpPusher.h @@ -44,12 +44,10 @@ private: template inline void addOnResultCB(const FUN &fun) { - lock_guard lck(_mtx_on_result); _map_on_result.emplace(_send_req_id, fun); } template inline void addOnStatusCB(const FUN &fun) { - lock_guard lck(_mtx_on_status); _deque_on_status.emplace_back(fun); } @@ -67,9 +65,6 @@ private: string _app; string _stream_id; string _tc_url; - - recursive_mutex _mtx_on_result; - recursive_mutex _mtx_on_status; deque > _deque_on_status; unordered_map > _map_on_result;