Chromium Code Reviews| Index: webrtc/logging/rtc_event_log/rtc_event_log.cc |
| diff --git a/webrtc/logging/rtc_event_log/rtc_event_log.cc b/webrtc/logging/rtc_event_log/rtc_event_log.cc |
| index 976ff2321c08106dcea319a19c63f50619ebb0af..5758dd34873932049a39de8b6f7ddfa5fe0c3bd7 100644 |
| --- a/webrtc/logging/rtc_event_log/rtc_event_log.cc |
| +++ b/webrtc/logging/rtc_event_log/rtc_event_log.cc |
| @@ -18,6 +18,7 @@ |
| #include "webrtc/base/event.h" |
| #include "webrtc/base/swap_queue.h" |
| #include "webrtc/base/thread_checker.h" |
| +#include "webrtc/base/timeutils.h" |
| #include "webrtc/call.h" |
| #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" |
| #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| @@ -32,7 +33,6 @@ |
| #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
| -#include "webrtc/system_wrappers/include/clock.h" |
| #include "webrtc/system_wrappers/include/file_wrapper.h" |
| #include "webrtc/system_wrappers/include/logging.h" |
| @@ -51,7 +51,7 @@ namespace webrtc { |
| class RtcEventLogImpl final : public RtcEventLog { |
| public: |
| - explicit RtcEventLogImpl(const Clock* clock); |
| + explicit RtcEventLogImpl(); |
|
the sun
2016/11/18 15:43:59
no need for explicit
|
| ~RtcEventLogImpl() override; |
| bool StartLogging(const std::string& file_name, |
| @@ -87,12 +87,8 @@ class RtcEventLogImpl final : public RtcEventLog { |
| // Message queue for passing events to the logging thread. |
| SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; |
| - const Clock* const clock_; |
| - |
| RtcEventLogHelperThread helper_thread_; |
| rtc::ThreadChecker thread_checker_; |
| - |
| - RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcEventLogImpl); |
|
the sun
2016/11/18 15:43:59
Why'd this go?
nisse-webrtc
2016/11/21 07:58:02
Because otherwise it failed to compile... As far a
the sun
2016/11/21 08:35:01
Oh, sorry for being inattentive. You should use RT
nisse-webrtc
2016/11/28 14:26:41
Done.
|
| }; |
| namespace { |
| @@ -136,12 +132,11 @@ static const int kControlMessagesPerSecond = 10; |
| } // namespace |
| // RtcEventLogImpl member functions. |
| -RtcEventLogImpl::RtcEventLogImpl(const Clock* clock) |
| +RtcEventLogImpl::RtcEventLogImpl() |
| // Allocate buffers for roughly one second of history. |
| : message_queue_(kControlMessagesPerSecond), |
| event_queue_(kEventsPerSecond), |
| - clock_(clock), |
| - helper_thread_(&message_queue_, &event_queue_, clock), |
| + helper_thread_(&message_queue_, &event_queue_), |
| thread_checker_() { |
| thread_checker_.DetachFromThread(); |
| } |
| @@ -159,7 +154,7 @@ bool RtcEventLogImpl::StartLogging(const std::string& file_name, |
| message.max_size_bytes = max_size_bytes <= 0 |
| ? std::numeric_limits<int64_t>::max() |
| : max_size_bytes; |
| - message.start_time = clock_->TimeInMicroseconds(); |
| + message.start_time = rtc::TimeMicros(); |
| message.stop_time = std::numeric_limits<int64_t>::max(); |
| message.file.reset(FileWrapper::Create()); |
| if (!message.file->OpenFile(file_name.c_str(), false)) { |
| @@ -183,7 +178,7 @@ bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, |
| message.max_size_bytes = max_size_bytes <= 0 |
| ? std::numeric_limits<int64_t>::max() |
| : max_size_bytes; |
| - message.start_time = clock_->TimeInMicroseconds(); |
| + message.start_time = rtc::TimeMicros(); |
| message.stop_time = std::numeric_limits<int64_t>::max(); |
| message.file.reset(FileWrapper::Create()); |
| FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); |
| @@ -213,7 +208,7 @@ void RtcEventLogImpl::StopLogging() { |
| RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| RtcEventLogHelperThread::ControlMessage message; |
| message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; |
| - message.stop_time = clock_->TimeInMicroseconds(); |
| + message.stop_time = rtc::TimeMicros(); |
| while (!message_queue_.Insert(&message)) { |
| // TODO(terelius): We would like to have a blocking Insert function in the |
| // SwapQueue, but for the time being we will just clear any previous |
| @@ -232,7 +227,7 @@ void RtcEventLogImpl::StopLogging() { |
| void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
| const VideoReceiveStream::Config& config) { |
| std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| - event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); |
| rtclog::VideoReceiveConfig* receiver_config = |
| @@ -268,7 +263,7 @@ void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
| void RtcEventLogImpl::LogVideoSendStreamConfig( |
| const VideoSendStream::Config& config) { |
| std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| - event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); |
| rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); |
| @@ -298,7 +293,7 @@ void RtcEventLogImpl::LogVideoSendStreamConfig( |
| void RtcEventLogImpl::LogAudioReceiveStreamConfig( |
| const AudioReceiveStream::Config& config) { |
| std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| - event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| event->set_type(rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT); |
| rtclog::AudioReceiveConfig* receiver_config = |
| @@ -318,7 +313,7 @@ void RtcEventLogImpl::LogAudioReceiveStreamConfig( |
| void RtcEventLogImpl::LogAudioSendStreamConfig( |
| const AudioSendStream::Config& config) { |
| std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| - event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| event->set_type(rtclog::Event::AUDIO_SENDER_CONFIG_EVENT); |
| rtclog::AudioSendConfig* sender_config = event->mutable_audio_sender_config(); |
| @@ -356,7 +351,7 @@ void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
| } |
| std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); |
| - rtp_event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + rtp_event->set_timestamp_us(rtc::TimeMicros()); |
| rtp_event->set_type(rtclog::Event::RTP_EVENT); |
| rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); |
| rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
| @@ -370,7 +365,7 @@ void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
| const uint8_t* packet, |
| size_t length) { |
| std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); |
| - rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + rtcp_event->set_timestamp_us(rtc::TimeMicros()); |
| rtcp_event->set_type(rtclog::Event::RTCP_EVENT); |
| rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); |
| rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
| @@ -417,7 +412,7 @@ void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
| void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
| std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| - event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
| auto playout_event = event->mutable_audio_playout_event(); |
| playout_event->set_local_ssrc(ssrc); |
| @@ -428,7 +423,7 @@ void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
| uint8_t fraction_loss, |
| int32_t total_packets) { |
| std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| - event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| + event->set_timestamp_us(rtc::TimeMicros()); |
| event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); |
| auto bwe_event = event->mutable_bwe_packet_loss_event(); |
| bwe_event->set_bitrate(bitrate); |
| @@ -472,9 +467,9 @@ bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file, |
| } |
| // RtcEventLog member functions. |
| -std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { |
| +std::unique_ptr<RtcEventLog> RtcEventLog::Create() { |
| #ifdef ENABLE_RTC_EVENT_LOG |
| - return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); |
| + return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); |
| #else |
| return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
| #endif // ENABLE_RTC_EVENT_LOG |