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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Write all the recent events to the log file, ignoring any old events. | 167 // Write all the recent events to the log file, ignoring any old events. |
168 for (auto& event : recent_log_events_) { | 168 for (auto& event : recent_log_events_) { |
169 if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { | 169 if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { |
170 StoreToFile(&event); | 170 StoreToFile(&event); |
171 } | 171 } |
172 } | 172 } |
173 recent_log_events_.clear(); | 173 recent_log_events_.clear(); |
174 // Write a LOG_START event to the file. | 174 // Write a LOG_START event to the file. |
175 rtclog::Event start_event; | 175 rtclog::Event start_event; |
176 start_event.set_timestamp_us(start_time_us_); | 176 start_event.set_timestamp_us(start_time_us_); |
177 start_event.set_type(rtclog::Event::DEBUG_EVENT); | 177 start_event.set_type(rtclog::Event::LOG_START); |
178 auto debug_event = start_event.mutable_debug_event(); | |
179 debug_event->set_type(rtclog::DebugEvent_EventType_LOG_START); | |
180 StoreToFile(&start_event); | 178 StoreToFile(&start_event); |
181 } | 179 } |
182 | 180 |
183 void RtcEventLogImpl::StopLogging() { | 181 void RtcEventLogImpl::StopLogging() { |
184 rtc::CritScope lock(&crit_); | 182 rtc::CritScope lock(&crit_); |
185 StopLoggingLocked(); | 183 StopLoggingLocked(); |
186 } | 184 } |
187 | 185 |
188 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 186 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
189 const VideoReceiveStream::Config& config) { | 187 const VideoReceiveStream::Config& config) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 314 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
317 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); | 315 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); |
318 HandleEvent(&rtcp_event); | 316 HandleEvent(&rtcp_event); |
319 } | 317 } |
320 | 318 |
321 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 319 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
322 rtc::CritScope lock(&crit_); | 320 rtc::CritScope lock(&crit_); |
323 rtclog::Event event; | 321 rtclog::Event event; |
324 const int64_t timestamp = clock_->TimeInMicroseconds(); | 322 const int64_t timestamp = clock_->TimeInMicroseconds(); |
325 event.set_timestamp_us(timestamp); | 323 event.set_timestamp_us(timestamp); |
326 event.set_type(rtclog::Event::DEBUG_EVENT); | 324 event.set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
327 auto debug_event = event.mutable_debug_event(); | 325 auto playout_event = event.mutable_audio_playout_event(); |
328 debug_event->set_type(rtclog::DebugEvent_EventType_AUDIO_PLAYOUT); | 326 playout_event->set_local_ssrc(ssrc); |
329 debug_event->set_local_ssrc(ssrc); | |
330 HandleEvent(&event); | 327 HandleEvent(&event); |
331 } | 328 } |
332 | 329 |
333 void RtcEventLogImpl::StopLoggingLocked() { | 330 void RtcEventLogImpl::StopLoggingLocked() { |
334 if (currently_logging_) { | 331 if (currently_logging_) { |
335 currently_logging_ = false; | 332 currently_logging_ = false; |
336 // Create a LogEnd debug event | 333 // Create a LogEnd event |
337 rtclog::Event event; | 334 rtclog::Event event; |
338 int64_t timestamp = clock_->TimeInMicroseconds(); | 335 int64_t timestamp = clock_->TimeInMicroseconds(); |
339 event.set_timestamp_us(timestamp); | 336 event.set_timestamp_us(timestamp); |
340 event.set_type(rtclog::Event::DEBUG_EVENT); | 337 event.set_type(rtclog::Event::LOG_END); |
341 auto debug_event = event.mutable_debug_event(); | |
342 debug_event->set_type(rtclog::DebugEvent_EventType_LOG_END); | |
343 // Store the event and close the file | 338 // Store the event and close the file |
344 RTC_DCHECK(file_->Open()); | 339 RTC_DCHECK(file_->Open()); |
345 StoreToFile(&event); | 340 StoreToFile(&event); |
346 file_->CloseFile(); | 341 file_->CloseFile(); |
347 } | 342 } |
348 RTC_DCHECK(!file_->Open()); | 343 RTC_DCHECK(!file_->Open()); |
349 stream_.Clear(); | 344 stream_.Clear(); |
350 } | 345 } |
351 | 346 |
352 void RtcEventLogImpl::HandleEvent(rtclog::Event* event) { | 347 void RtcEventLogImpl::HandleEvent(rtclog::Event* event) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 return result->ParseFromString(dump_buffer); | 393 return result->ParseFromString(dump_buffer); |
399 } | 394 } |
400 | 395 |
401 #endif // ENABLE_RTC_EVENT_LOG | 396 #endif // ENABLE_RTC_EVENT_LOG |
402 | 397 |
403 // RtcEventLog member functions. | 398 // RtcEventLog member functions. |
404 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { | 399 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { |
405 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); | 400 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); |
406 } | 401 } |
407 } // namespace webrtc | 402 } // namespace webrtc |
OLD | NEW |