[fix] use shared ptr to create real time clock

This commit is contained in:
dijunkun
2025-02-06 13:53:58 +08:00
parent dbb31f8298
commit 1d85247785
3 changed files with 7 additions and 2 deletions

View File

@@ -20,7 +20,7 @@ RtpVideoReceiver::RtpVideoReceiver()
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) { [this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
SendRemb(bitrate_bps, ssrcs); SendRemb(bitrate_bps, ssrcs);
}), }),
clock_(Clock::GetRealTimeClock()) {} clock_(Clock::GetRealTimeClockShared()) {}
RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics) RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
: io_statistics_(io_statistics), : io_statistics_(io_statistics),
@@ -33,7 +33,7 @@ RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) { [this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
SendRemb(bitrate_bps, ssrcs); SendRemb(bitrate_bps, ssrcs);
}), }),
clock_(Clock::GetRealTimeClock()) { clock_(Clock::GetRealTimeClockShared()) {
rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this); rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
#ifdef SAVE_RTP_RECV_STREAM #ifdef SAVE_RTP_RECV_STREAM

View File

@@ -60,4 +60,8 @@ Clock* Clock::GetRealTimeClock() {
static Clock* const clock = new RealTimeClock(); static Clock* const clock = new RealTimeClock();
return clock; return clock;
} }
std::shared_ptr<Clock> Clock::GetRealTimeClockShared() {
return std::make_shared<RealTimeClock>();
}
} // namespace webrtc } // namespace webrtc

View File

@@ -66,6 +66,7 @@ class Clock {
// Returns an instance of the real-time system clock implementation. // Returns an instance of the real-time system clock implementation.
static Clock* GetRealTimeClock(); static Clock* GetRealTimeClock();
static std::shared_ptr<Clock> GetRealTimeClockShared();
}; };
} // namespace webrtc } // namespace webrtc