Chromium Code Reviews| Index: webrtc/call/rtc_event_log.cc |
| diff --git a/webrtc/call/rtc_event_log.cc b/webrtc/call/rtc_event_log.cc |
| index 97885cc066a609d79cf13b69beabc4874d838b57..63d48824581ea487a9c6b0ea3dc3d8d311157c0b 100644 |
| --- a/webrtc/call/rtc_event_log.cc |
| +++ b/webrtc/call/rtc_event_log.cc |
| @@ -11,6 +11,7 @@ |
| #include "webrtc/call/rtc_event_log.h" |
| #include <deque> |
| +#include <limits> |
|
the sun
2015/10/13 11:00:40
where do you use something from limits (in the cha
ivoc
2015/10/13 13:50:50
Thanks, this looks like a leftover of some earlier
|
| #include "webrtc/base/checks.h" |
| #include "webrtc/base/criticalsection.h" |
| @@ -37,6 +38,7 @@ namespace webrtc { |
| class RtcEventLogImpl final : public RtcEventLog { |
| public: |
| void StartLogging(const std::string& file_name, int duration_ms) override {} |
| + int StartLogging(FILE* log_file) override { return -1; } |
| void StopLogging(void) override {} |
| void LogVideoReceiveStreamConfig( |
| const VideoReceiveStream::Config& config) override {} |
| @@ -60,6 +62,7 @@ class RtcEventLogImpl final : public RtcEventLog { |
| RtcEventLogImpl(); |
| void StartLogging(const std::string& file_name, int duration_ms) override; |
| + int StartLogging(FILE* log_file) override; |
| void StopLogging() override; |
| void LogVideoReceiveStreamConfig( |
| const VideoReceiveStream::Config& config) override; |
| @@ -75,6 +78,9 @@ class RtcEventLogImpl final : public RtcEventLog { |
| void LogAudioPlayout(uint32_t ssrc) override; |
| private: |
| + // Starts logging. This function assumes the file_ has been opened succesfully |
| + // and that the start_time_us_ and _duration_us_ have been set. |
| + void StartLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| // Stops logging and clears the stored data and buffers. |
| void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| // Adds a new event to the logfile if logging is active, or adds it to the |
| @@ -161,9 +167,29 @@ void RtcEventLogImpl::StartLogging(const std::string& file_name, |
| if (file_->OpenFile(file_name.c_str(), false) != 0) { |
| return; |
| } |
| - currently_logging_ = true; |
| start_time_us_ = clock_->TimeInMicroseconds(); |
| duration_us_ = static_cast<int64_t>(duration_ms) * 1000; |
| + StartLoggingLocked(); |
| +} |
| + |
| +int RtcEventLogImpl::StartLogging(FILE* log_file) { |
| + rtc::CritScope lock(&crit_); |
| + |
| + if (currently_logging_) |
| + StopLoggingLocked(); |
| + RTC_DCHECK(log_file); |
| + if (file_->OpenFromFileHandle(log_file, true, false) != 0) { |
| + return -1; |
| + } |
| + // Set the start time and duration to keep logging for 10 minutes. |
| + start_time_us_ = clock_->TimeInMicroseconds(); |
| + duration_us_ = 10 * 60 * 1000000; |
| + StartLoggingLocked(); |
| + return 0; |
| +} |
| + |
| +void RtcEventLogImpl::StartLoggingLocked() { |
| + currently_logging_ = true; |
| // Write all the recent events to the log file, ignoring any old events. |
| for (auto& event : recent_log_events_) { |
| if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { |