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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void LogVideoSendStreamConfig( | 43 void LogVideoSendStreamConfig( |
44 const VideoSendStream::Config& config) override {} | 44 const VideoSendStream::Config& config) override {} |
45 void LogRtpHeader(bool incoming, | 45 void LogRtpHeader(bool incoming, |
46 MediaType media_type, | 46 MediaType media_type, |
47 const uint8_t* header, | 47 const uint8_t* header, |
48 size_t packet_length) override {} | 48 size_t packet_length) override {} |
49 void LogRtcpPacket(bool incoming, | 49 void LogRtcpPacket(bool incoming, |
50 MediaType media_type, | 50 MediaType media_type, |
51 const uint8_t* packet, | 51 const uint8_t* packet, |
52 size_t length) override {} | 52 size_t length) override {} |
53 void LogDebugEvent(DebugEvent event_type) override {} | 53 void LogAudioPlayout(uint32_t ssrc) override {} |
54 }; | 54 }; |
55 | 55 |
56 #else // ENABLE_RTC_EVENT_LOG is defined | 56 #else // ENABLE_RTC_EVENT_LOG is defined |
57 | 57 |
58 class RtcEventLogImpl final : public RtcEventLog { | 58 class RtcEventLogImpl final : public RtcEventLog { |
59 public: | 59 public: |
60 RtcEventLogImpl(); | 60 RtcEventLogImpl(); |
61 | 61 |
62 void StartLogging(const std::string& file_name, int duration_ms) override; | 62 void StartLogging(const std::string& file_name, int duration_ms) override; |
63 void StopLogging() override; | 63 void StopLogging() override; |
64 void LogVideoReceiveStreamConfig( | 64 void LogVideoReceiveStreamConfig( |
65 const VideoReceiveStream::Config& config) override; | 65 const VideoReceiveStream::Config& config) override; |
66 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; | 66 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; |
67 void LogRtpHeader(bool incoming, | 67 void LogRtpHeader(bool incoming, |
68 MediaType media_type, | 68 MediaType media_type, |
69 const uint8_t* header, | 69 const uint8_t* header, |
70 size_t packet_length) override; | 70 size_t packet_length) override; |
71 void LogRtcpPacket(bool incoming, | 71 void LogRtcpPacket(bool incoming, |
72 MediaType media_type, | 72 MediaType media_type, |
73 const uint8_t* packet, | 73 const uint8_t* packet, |
74 size_t length) override; | 74 size_t length) override; |
75 void LogDebugEvent(DebugEvent event_type) override; | 75 void LogAudioPlayout(uint32_t ssrc) override; |
76 | 76 |
77 private: | 77 private: |
78 // Stops logging and clears the stored data and buffers. | 78 // Stops logging and clears the stored data and buffers. |
79 void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 79 void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
80 // Adds a new event to the logfile if logging is active, or adds it to the | 80 // Adds a new event to the logfile if logging is active, or adds it to the |
81 // list of recent log events otherwise. | 81 // list of recent log events otherwise. |
82 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 82 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
83 // Writes the event to the file. Note that this will destroy the state of the | 83 // Writes the event to the file. Note that this will destroy the state of the |
84 // input argument. | 84 // input argument. |
85 void StoreToFile(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 85 void StoreToFile(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
(...skipping 18 matching lines...) Expand all Loading... |
104 | 104 |
105 namespace { | 105 namespace { |
106 // The functions in this namespace convert enums from the runtime format | 106 // The functions in this namespace convert enums from the runtime format |
107 // that the rest of the WebRtc project can use, to the corresponding | 107 // that the rest of the WebRtc project can use, to the corresponding |
108 // serialized enum which is defined by the protobuf. | 108 // serialized enum which is defined by the protobuf. |
109 | 109 |
110 // Do not add default return values to the conversion functions in this | 110 // Do not add default return values to the conversion functions in this |
111 // unnamed namespace. The intention is to make the compiler warn if anyone | 111 // unnamed namespace. The intention is to make the compiler warn if anyone |
112 // adds unhandled new events/modes/etc. | 112 // adds unhandled new events/modes/etc. |
113 | 113 |
114 rtclog::DebugEvent_EventType ConvertDebugEvent( | |
115 RtcEventLog::DebugEvent event_type) { | |
116 switch (event_type) { | |
117 case RtcEventLog::DebugEvent::kLogStart: | |
118 return rtclog::DebugEvent::LOG_START; | |
119 case RtcEventLog::DebugEvent::kLogEnd: | |
120 return rtclog::DebugEvent::LOG_END; | |
121 case RtcEventLog::DebugEvent::kAudioPlayout: | |
122 return rtclog::DebugEvent::AUDIO_PLAYOUT; | |
123 } | |
124 RTC_NOTREACHED(); | |
125 return rtclog::DebugEvent::UNKNOWN_EVENT; | |
126 } | |
127 | |
128 rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode( | 114 rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode( |
129 newapi::RtcpMode rtcp_mode) { | 115 newapi::RtcpMode rtcp_mode) { |
130 switch (rtcp_mode) { | 116 switch (rtcp_mode) { |
131 case newapi::kRtcpCompound: | 117 case newapi::kRtcpCompound: |
132 return rtclog::VideoReceiveConfig::RTCP_COMPOUND; | 118 return rtclog::VideoReceiveConfig::RTCP_COMPOUND; |
133 case newapi::kRtcpReducedSize: | 119 case newapi::kRtcpReducedSize: |
134 return rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE; | 120 return rtclog::VideoReceiveConfig::RTCP_REDUCEDSIZE; |
135 } | 121 } |
136 RTC_NOTREACHED(); | 122 RTC_NOTREACHED(); |
137 return rtclog::VideoReceiveConfig::RTCP_COMPOUND; | 123 return rtclog::VideoReceiveConfig::RTCP_COMPOUND; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { | 167 if (event.timestamp_us() >= start_time_us_ - recent_log_duration_us) { |
182 StoreToFile(&event); | 168 StoreToFile(&event); |
183 } | 169 } |
184 } | 170 } |
185 recent_log_events_.clear(); | 171 recent_log_events_.clear(); |
186 // Write a LOG_START event to the file. | 172 // Write a LOG_START event to the file. |
187 rtclog::Event start_event; | 173 rtclog::Event start_event; |
188 start_event.set_timestamp_us(start_time_us_); | 174 start_event.set_timestamp_us(start_time_us_); |
189 start_event.set_type(rtclog::Event::DEBUG_EVENT); | 175 start_event.set_type(rtclog::Event::DEBUG_EVENT); |
190 auto debug_event = start_event.mutable_debug_event(); | 176 auto debug_event = start_event.mutable_debug_event(); |
191 debug_event->set_type(ConvertDebugEvent(DebugEvent::kLogStart)); | 177 debug_event->set_type(rtclog::DebugEvent_EventType_LOG_START); |
192 StoreToFile(&start_event); | 178 StoreToFile(&start_event); |
193 } | 179 } |
194 | 180 |
195 void RtcEventLogImpl::StopLogging() { | 181 void RtcEventLogImpl::StopLogging() { |
196 rtc::CritScope lock(&crit_); | 182 rtc::CritScope lock(&crit_); |
197 StopLoggingLocked(); | 183 StopLoggingLocked(); |
198 } | 184 } |
199 | 185 |
200 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 186 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
201 const VideoReceiveStream::Config& config) { | 187 const VideoReceiveStream::Config& config) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 rtclog::Event rtcp_event; | 309 rtclog::Event rtcp_event; |
324 const int64_t timestamp = clock_->TimeInMicroseconds(); | 310 const int64_t timestamp = clock_->TimeInMicroseconds(); |
325 rtcp_event.set_timestamp_us(timestamp); | 311 rtcp_event.set_timestamp_us(timestamp); |
326 rtcp_event.set_type(rtclog::Event::RTCP_EVENT); | 312 rtcp_event.set_type(rtclog::Event::RTCP_EVENT); |
327 rtcp_event.mutable_rtcp_packet()->set_incoming(incoming); | 313 rtcp_event.mutable_rtcp_packet()->set_incoming(incoming); |
328 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 314 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
329 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); | 315 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); |
330 HandleEvent(&rtcp_event); | 316 HandleEvent(&rtcp_event); |
331 } | 317 } |
332 | 318 |
333 void RtcEventLogImpl::LogDebugEvent(DebugEvent event_type) { | 319 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
334 rtc::CritScope lock(&crit_); | 320 rtc::CritScope lock(&crit_); |
335 rtclog::Event event; | 321 rtclog::Event event; |
336 const int64_t timestamp = clock_->TimeInMicroseconds(); | 322 const int64_t timestamp = clock_->TimeInMicroseconds(); |
337 event.set_timestamp_us(timestamp); | 323 event.set_timestamp_us(timestamp); |
338 event.set_type(rtclog::Event::DEBUG_EVENT); | 324 event.set_type(rtclog::Event::DEBUG_EVENT); |
339 auto debug_event = event.mutable_debug_event(); | 325 auto debug_event = event.mutable_debug_event(); |
340 debug_event->set_type(ConvertDebugEvent(event_type)); | 326 debug_event->set_type(rtclog::DebugEvent_EventType_AUDIO_PLAYOUT); |
| 327 debug_event->set_local_ssrc(ssrc); |
341 HandleEvent(&event); | 328 HandleEvent(&event); |
342 } | 329 } |
343 | 330 |
344 void RtcEventLogImpl::StopLoggingLocked() { | 331 void RtcEventLogImpl::StopLoggingLocked() { |
345 if (currently_logging_) { | 332 if (currently_logging_) { |
346 currently_logging_ = false; | 333 currently_logging_ = false; |
347 // Create a LogEnd debug event | 334 // Create a LogEnd debug event |
348 rtclog::Event event; | 335 rtclog::Event event; |
349 int64_t timestamp = clock_->TimeInMicroseconds(); | 336 int64_t timestamp = clock_->TimeInMicroseconds(); |
350 event.set_timestamp_us(timestamp); | 337 event.set_timestamp_us(timestamp); |
351 event.set_type(rtclog::Event::DEBUG_EVENT); | 338 event.set_type(rtclog::Event::DEBUG_EVENT); |
352 auto debug_event = event.mutable_debug_event(); | 339 auto debug_event = event.mutable_debug_event(); |
353 debug_event->set_type(ConvertDebugEvent(DebugEvent::kLogEnd)); | 340 debug_event->set_type(rtclog::DebugEvent_EventType_LOG_END); |
354 // Store the event and close the file | 341 // Store the event and close the file |
355 RTC_DCHECK(file_->Open()); | 342 RTC_DCHECK(file_->Open()); |
356 StoreToFile(&event); | 343 StoreToFile(&event); |
357 file_->CloseFile(); | 344 file_->CloseFile(); |
358 } | 345 } |
359 RTC_DCHECK(!file_->Open()); | 346 RTC_DCHECK(!file_->Open()); |
360 stream_.Clear(); | 347 stream_.Clear(); |
361 } | 348 } |
362 | 349 |
363 void RtcEventLogImpl::HandleEvent(rtclog::Event* event) { | 350 void RtcEventLogImpl::HandleEvent(rtclog::Event* event) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 return result->ParseFromString(dump_buffer); | 396 return result->ParseFromString(dump_buffer); |
410 } | 397 } |
411 | 398 |
412 #endif // ENABLE_RTC_EVENT_LOG | 399 #endif // ENABLE_RTC_EVENT_LOG |
413 | 400 |
414 // RtcEventLog member functions. | 401 // RtcEventLog member functions. |
415 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { | 402 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { |
416 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); | 403 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); |
417 } | 404 } |
418 } // namespace webrtc | 405 } // namespace webrtc |
OLD | NEW |