Index: webrtc/video/rtc_event_log.cc |
diff --git a/webrtc/video/rtc_event_log.cc b/webrtc/video/rtc_event_log.cc |
index 476ee2afd79c82b9be6b41feb7424939842d942b..28d7d70191d9c31716916b4a8410e9860dfbdcbd 100644 |
--- a/webrtc/video/rtc_event_log.cc |
+++ b/webrtc/video/rtc_event_log.cc |
@@ -35,6 +35,7 @@ namespace webrtc { |
// No-op implementation if flag is not set. |
class RtcEventLogImpl final : public RtcEventLog { |
public: |
+ void SetBufferDuration(int64_t recent_log_duration_us) override {} |
void StartLogging(const std::string& file_name, int duration_ms) override {} |
void StopLogging(void) override {} |
void LogVideoReceiveStreamConfig( |
@@ -59,6 +60,7 @@ class RtcEventLogImpl final : public RtcEventLog { |
public: |
RtcEventLogImpl(); |
+ void SetBufferDuration(int64_t recent_log_duration_us) override; |
void StartLogging(const std::string& file_name, int duration_ms) override; |
void StopLogging() override; |
void LogVideoReceiveStreamConfig( |
@@ -89,14 +91,14 @@ class RtcEventLogImpl final : public RtcEventLog { |
void AddRecentEvent(const rtclog::Event& event) |
EXCLUSIVE_LOCKS_REQUIRED(crit_); |
- // Amount of time in microseconds to record log events, before starting the |
- // actual log. |
- const int recent_log_duration_us = 10000000; |
- |
rtc::CriticalSection crit_; |
rtc::scoped_ptr<FileWrapper> file_ GUARDED_BY(crit_); |
rtclog::EventStream stream_ GUARDED_BY(crit_); |
std::deque<rtclog::Event> recent_log_events_ GUARDED_BY(crit_); |
+ std::vector<rtclog::Event> config_events_ GUARDED_BY(crit_); |
+ |
+ // Microseconds to record log events, before starting the actual log. |
+ int64_t recent_log_duration_us_ GUARDED_BY(crit_); |
bool currently_logging_ GUARDED_BY(crit_); |
int64_t start_time_us_ GUARDED_BY(crit_); |
int64_t duration_us_ GUARDED_BY(crit_); |
@@ -159,12 +161,18 @@ rtclog::MediaType ConvertMediaType(MediaType media_type) { |
RtcEventLogImpl::RtcEventLogImpl() |
: file_(FileWrapper::Create()), |
stream_(), |
+ recent_log_duration_us_(10000000), |
currently_logging_(false), |
start_time_us_(0), |
duration_us_(0), |
clock_(Clock::GetRealTimeClock()) { |
} |
+void RtcEventLogImpl::SetBufferDuration(int64_t recent_log_duration_us) { |
hlundin-webrtc
2015/08/28 11:16:29
I think the function name should match the member
terelius
2015/09/17 12:44:08
Changed the variable name to buffer_duration_us_.
|
+ rtc::CritScope lock(&crit_); |
+ recent_log_duration_us_ = recent_log_duration_us; |
+} |
+ |
void RtcEventLogImpl::StartLogging(const std::string& file_name, |
int duration_ms) { |
rtc::CritScope lock(&crit_); |
@@ -177,9 +185,21 @@ void RtcEventLogImpl::StartLogging(const std::string& file_name, |
currently_logging_ = true; |
start_time_us_ = clock_->TimeInMicroseconds(); |
duration_us_ = static_cast<int64_t>(duration_ms) * 1000; |
- // Write all the recent events to the log file, ignoring any old events. |
+ // Write all old configuration events to the log file. |
+ for (auto& event : config_events_) { |
+ StoreToFile(&event); |
+ } |
+ // Write all recent configuration events to the log file, and |
+ // write all other 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) { |
+ if (event.type() == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT || |
hlundin-webrtc
2015/08/28 11:16:29
Make a helper function for checking if an event is
stefan-webrtc
2015/09/03 11:13:21
+1
terelius
2015/09/17 12:44:08
Done.
|
+ event.type() == rtclog::Event::VIDEO_SENDER_CONFIG_EVENT || |
+ event.type() == rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT || |
+ event.type() == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT) { |
+ StoreToFile(&event); |
+ config_events_.push_back(event); |
+ } else if (event.timestamp_us() >= |
+ start_time_us_ - recent_log_duration_us_) { |
StoreToFile(&event); |
} |
} |
@@ -237,10 +257,6 @@ void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
decoder->set_name(d.payload_name); |
decoder->set_payload_type(d.payload_type); |
} |
- // TODO(terelius): We should use a separate event queue for config events. |
- // The current approach of storing the configuration together with the |
- // RTP events causes the configuration information to be removed 10s |
- // after the ReceiveStream is created. |
HandleEvent(&event); |
} |
@@ -276,11 +292,6 @@ void RtcEventLogImpl::LogVideoSendStreamConfig( |
rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); |
encoder->set_name(config.encoder_settings.payload_name); |
encoder->set_payload_type(config.encoder_settings.payload_type); |
- |
- // TODO(terelius): We should use a separate event queue for config events. |
- // The current approach of storing the configuration together with the |
- // RTP events causes the configuration information to be removed 10s |
- // after the ReceiveStream is created. |
HandleEvent(&event); |
} |
@@ -376,7 +387,14 @@ void RtcEventLogImpl::StoreToFile(rtclog::Event* event) { |
void RtcEventLogImpl::AddRecentEvent(const rtclog::Event& event) { |
recent_log_events_.push_back(event); |
while (recent_log_events_.front().timestamp_us() < |
- event.timestamp_us() - recent_log_duration_us) { |
+ event.timestamp_us() - recent_log_duration_us_) { |
+ rtclog::Event_EventType event_type = recent_log_events_.front().type(); |
+ if (event_type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT || |
+ event_type == rtclog::Event::VIDEO_SENDER_CONFIG_EVENT || |
+ event_type == rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT || |
+ event_type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT) { |
+ config_events_.push_back(recent_log_events_.front()); |
+ } |
recent_log_events_.pop_front(); |
} |
} |
@@ -403,4 +421,5 @@ bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, |
rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { |
return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); |
} |
+ |
} // namespace webrtc |