获取track统计信息不再上锁,修复可能死锁的bug

This commit is contained in:
ziyuexiachu 2025-02-28 12:51:15 +08:00
parent 0b1f9fb194
commit 550870ea74

View File

@ -733,9 +733,9 @@ public:
* [AUTO-TRANSLATED:a3e7e6db] * [AUTO-TRANSLATED:a3e7e6db]
*/ */
bool inputFrame(const Frame::Ptr &frame) override { bool inputFrame(const Frame::Ptr &frame) override {
std::lock_guard<std::recursive_mutex> lck(_mtx);
doStatistics(frame); doStatistics(frame);
bool ret = false; bool ret = false;
std::lock_guard<std::recursive_mutex> lck(_mtx);
for (auto &pr : _delegates) { for (auto &pr : _delegates) {
if (pr.second->inputFrame(frame)) { if (pr.second->inputFrame(frame)) {
ret = true; ret = true;
@ -767,7 +767,6 @@ public:
* [AUTO-TRANSLATED:73cb2ab0] * [AUTO-TRANSLATED:73cb2ab0]
*/ */
uint64_t getVideoKeyFrames() const { uint64_t getVideoKeyFrames() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
return _video_key_frames; return _video_key_frames;
} }
@ -778,22 +777,18 @@ public:
* [AUTO-TRANSLATED:118b395e] * [AUTO-TRANSLATED:118b395e]
*/ */
uint64_t getFrames() const { uint64_t getFrames() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
return _frames; return _frames;
} }
size_t getVideoGopSize() const { size_t getVideoGopSize() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
return _gop_size; return _gop_size;
} }
size_t getVideoGopInterval() const { size_t getVideoGopInterval() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
return _gop_interval_ms; return _gop_interval_ms;
} }
int64_t getDuration() const { int64_t getDuration() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
return _stamp.getRelativeStamp(); return _stamp.getRelativeStamp();
} }