OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Write all the recent events to the log file, ignoring any old events. | 165 // Write all the recent events to the log file, ignoring any old events. |
166 for (auto& event : recent_log_events_) { | 166 for (auto& event : recent_log_events_) { |
167 if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { | 167 if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { |
168 StoreToFile(&event); | 168 StoreToFile(&event); |
169 } | 169 } |
170 } | 170 } |
171 recent_log_events_.clear(); | 171 recent_log_events_.clear(); |
172 // Write a LOG_START event to the file. | 172 // Write a LOG_START event to the file. |
173 rtclog::Event start_event; | 173 rtclog::Event start_event; |
174 start_event.set_timestamp_us(start_time_us_); | 174 start_event.set_timestamp_us(start_time_us_); |
175 start_event.set_type(rtclog::Event::DEBUG_EVENT); | 175 start_event.set_type(rtclog::Event::LOG_START); |
176 auto debug_event = start_event.mutable_debug_event(); | |
177 debug_event->set_type(rtclog::DebugEvent_EventType_LOG_START); | |
178 StoreToFile(&start_event); | 176 StoreToFile(&start_event); |
179 } | 177 } |
180 | 178 |
181 void RtcEventLogImpl::StopLogging() { | 179 void RtcEventLogImpl::StopLogging() { |
182 rtc::CritScope lock(&crit_); | 180 rtc::CritScope lock(&crit_); |
183 StopLoggingLocked(); | 181 StopLoggingLocked(); |
184 } | 182 } |
185 | 183 |
186 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 184 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
187 const VideoReceiveStream::Config& config) { | 185 const VideoReceiveStream::Config& config) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 312 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
315 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); | 313 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); |
316 HandleEvent(&rtcp_event); | 314 HandleEvent(&rtcp_event); |
317 } | 315 } |
318 | 316 |
319 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 317 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
320 rtc::CritScope lock(&crit_); | 318 rtc::CritScope lock(&crit_); |
321 rtclog::Event event; | 319 rtclog::Event event; |
322 const int64_t timestamp = clock_->TimeInMicroseconds(); | 320 const int64_t timestamp = clock_->TimeInMicroseconds(); |
323 event.set_timestamp_us(timestamp); | 321 event.set_timestamp_us(timestamp); |
324 event.set_type(rtclog::Event::DEBUG_EVENT); | 322 event.set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
325 auto debug_event = event.mutable_debug_event(); | 323 auto playout_event = event.mutable_audio_playout_event(); |
326 debug_event->set_type(rtclog::DebugEvent_EventType_AUDIO_PLAYOUT); | 324 playout_event->set_local_ssrc(ssrc); |
327 debug_event->set_local_ssrc(ssrc); | |
328 HandleEvent(&event); | 325 HandleEvent(&event); |
329 } | 326 } |
330 | 327 |
331 void RtcEventLogImpl::StopLoggingLocked() { | 328 void RtcEventLogImpl::StopLoggingLocked() { |
332 if (currently_logging_) { | 329 if (currently_logging_) { |
333 currently_logging_ = false; | 330 currently_logging_ = false; |
334 // Create a LogEnd debug event | 331 // Create a LogEnd event |
335 rtclog::Event event; | 332 rtclog::Event event; |
336 int64_t timestamp = clock_->TimeInMicroseconds(); | 333 int64_t timestamp = clock_->TimeInMicroseconds(); |
337 event.set_timestamp_us(timestamp); | 334 event.set_timestamp_us(timestamp); |
338 event.set_type(rtclog::Event::DEBUG_EVENT); | 335 event.set_type(rtclog::Event::LOG_END); |
339 auto debug_event = event.mutable_debug_event(); | |
340 debug_event->set_type(rtclog::DebugEvent_EventType_LOG_END); | |
341 // Store the event and close the file | 336 // Store the event and close the file |
342 RTC_DCHECK(file_->Open()); | 337 RTC_DCHECK(file_->Open()); |
343 StoreToFile(&event); | 338 StoreToFile(&event); |
344 file_->CloseFile(); | 339 file_->CloseFile(); |
345 } | 340 } |
346 RTC_DCHECK(!file_->Open()); | 341 RTC_DCHECK(!file_->Open()); |
347 stream_.Clear(); | 342 stream_.Clear(); |
348 } | 343 } |
349 | 344 |
350 void RtcEventLogImpl::HandleEvent(rtclog::Event* event) { | 345 void RtcEventLogImpl::HandleEvent(rtclog::Event* event) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 return result->ParseFromString(dump_buffer); | 391 return result->ParseFromString(dump_buffer); |
397 } | 392 } |
398 | 393 |
399 #endif // ENABLE_RTC_EVENT_LOG | 394 #endif // ENABLE_RTC_EVENT_LOG |
400 | 395 |
401 // RtcEventLog member functions. | 396 // RtcEventLog member functions. |
402 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { | 397 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { |
403 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); | 398 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); |
404 } | 399 } |
405 } // namespace webrtc | 400 } // namespace webrtc |
OLD | NEW |