Chromium Code Reviews| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 void LogRtcpPacket(PacketDirection direction, | 96 void LogRtcpPacket(PacketDirection direction, |
| 97 MediaType media_type, | 97 MediaType media_type, |
| 98 const uint8_t* packet, | 98 const uint8_t* packet, |
| 99 size_t length) override; | 99 size_t length) override; |
| 100 void LogAudioPlayout(uint32_t ssrc) override; | 100 void LogAudioPlayout(uint32_t ssrc) override; |
| 101 void LogBwePacketLossEvent(int32_t bitrate, | 101 void LogBwePacketLossEvent(int32_t bitrate, |
| 102 uint8_t fraction_loss, | 102 uint8_t fraction_loss, |
| 103 int32_t total_packets) override; | 103 int32_t total_packets) override; |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 void StoreEvent(std::unique_ptr<rtclog::Event>* event); | |
| 107 | |
| 106 // Message queue for passing control messages to the logging thread. | 108 // Message queue for passing control messages to the logging thread. |
| 107 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; | 109 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
| 108 | 110 |
| 109 // Message queue for passing events to the logging thread. | 111 // Message queue for passing events to the logging thread. |
| 110 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; | 112 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; |
| 111 | 113 |
| 112 rtc::Event wake_up_; | |
| 113 rtc::Event stopped_; | |
| 114 | |
| 115 const Clock* const clock_; | 114 const Clock* const clock_; |
| 116 | 115 |
| 117 RtcEventLogHelperThread helper_thread_; | 116 RtcEventLogHelperThread helper_thread_; |
| 118 rtc::ThreadChecker thread_checker_; | 117 rtc::ThreadChecker thread_checker_; |
| 119 | 118 |
| 120 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcEventLogImpl); | 119 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcEventLogImpl); |
| 121 }; | 120 }; |
| 122 | 121 |
| 123 namespace { | 122 namespace { |
| 124 // The functions in this namespace convert enums from the runtime format | 123 // The functions in this namespace convert enums from the runtime format |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 // sent packets because they also contain received packets. | 157 // sent packets because they also contain received packets. |
| 159 static const int kEventsPerSecond = 1000; | 158 static const int kEventsPerSecond = 1000; |
| 160 static const int kControlMessagesPerSecond = 10; | 159 static const int kControlMessagesPerSecond = 10; |
| 161 } // namespace | 160 } // namespace |
| 162 | 161 |
| 163 // RtcEventLogImpl member functions. | 162 // RtcEventLogImpl member functions. |
| 164 RtcEventLogImpl::RtcEventLogImpl(const Clock* clock) | 163 RtcEventLogImpl::RtcEventLogImpl(const Clock* clock) |
| 165 // Allocate buffers for roughly one second of history. | 164 // Allocate buffers for roughly one second of history. |
| 166 : message_queue_(kControlMessagesPerSecond), | 165 : message_queue_(kControlMessagesPerSecond), |
| 167 event_queue_(kEventsPerSecond), | 166 event_queue_(kEventsPerSecond), |
| 168 wake_up_(false, false), | |
| 169 stopped_(false, false), | |
| 170 clock_(clock), | 167 clock_(clock), |
| 171 helper_thread_(&message_queue_, | 168 helper_thread_(&message_queue_, |
| 172 &event_queue_, | 169 &event_queue_, |
| 173 &wake_up_, | |
| 174 &stopped_, | |
| 175 clock), | 170 clock), |
| 176 thread_checker_() { | 171 thread_checker_() { |
| 177 thread_checker_.DetachFromThread(); | 172 thread_checker_.DetachFromThread(); |
| 178 } | 173 } |
| 179 | 174 |
| 180 RtcEventLogImpl::~RtcEventLogImpl() { | 175 RtcEventLogImpl::~RtcEventLogImpl() { |
| 181 // The RtcEventLogHelperThread destructor closes the file | 176 // The RtcEventLogHelperThread destructor closes the file |
| 182 // and waits for the thread to terminate. | 177 // and waits for the thread to terminate. |
| 183 } | 178 } |
| 184 | 179 |
| 185 bool RtcEventLogImpl::StartLogging(const std::string& file_name, | 180 bool RtcEventLogImpl::StartLogging(const std::string& file_name, |
| 186 int64_t max_size_bytes) { | 181 int64_t max_size_bytes) { |
| 187 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 182 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 188 RtcEventLogHelperThread::ControlMessage message; | 183 RtcEventLogHelperThread::ControlMessage message; |
| 189 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 184 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
| 190 message.max_size_bytes = max_size_bytes <= 0 | 185 message.max_size_bytes = max_size_bytes <= 0 |
| 191 ? std::numeric_limits<int64_t>::max() | 186 ? std::numeric_limits<int64_t>::max() |
| 192 : max_size_bytes; | 187 : max_size_bytes; |
| 193 message.start_time = clock_->TimeInMicroseconds(); | 188 message.start_time = clock_->TimeInMicroseconds(); |
| 194 message.stop_time = std::numeric_limits<int64_t>::max(); | 189 message.stop_time = std::numeric_limits<int64_t>::max(); |
| 195 message.file.reset(FileWrapper::Create()); | 190 message.file.reset(FileWrapper::Create()); |
| 196 if (message.file->OpenFile(file_name.c_str(), false) != 0) { | 191 if (message.file->OpenFile(file_name.c_str(), false) != 0) { |
| 197 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 192 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
| 198 return false; | 193 return false; |
| 199 } | 194 } |
| 200 if (!message_queue_.Insert(&message)) { | 195 if (!message_queue_.Insert(&message)) { |
| 201 LOG(LS_ERROR) << "Message queue full. Can't start logging."; | 196 LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
| 202 return false; | 197 return false; |
| 203 } | 198 } |
| 199 helper_thread_.SignalNewEvent(); | |
| 204 LOG(LS_INFO) << "Starting WebRTC event log."; | 200 LOG(LS_INFO) << "Starting WebRTC event log."; |
| 205 return true; | 201 return true; |
| 206 } | 202 } |
| 207 | 203 |
| 208 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, | 204 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, |
| 209 int64_t max_size_bytes) { | 205 int64_t max_size_bytes) { |
| 210 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 206 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 211 RtcEventLogHelperThread::ControlMessage message; | 207 RtcEventLogHelperThread::ControlMessage message; |
| 212 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 208 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
| 213 message.max_size_bytes = max_size_bytes <= 0 | 209 message.max_size_bytes = max_size_bytes <= 0 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 227 return false; | 223 return false; |
| 228 } | 224 } |
| 229 if (message.file->OpenFromFileHandle(file_handle, true, false) != 0) { | 225 if (message.file->OpenFromFileHandle(file_handle, true, false) != 0) { |
| 230 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 226 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
| 231 return false; | 227 return false; |
| 232 } | 228 } |
| 233 if (!message_queue_.Insert(&message)) { | 229 if (!message_queue_.Insert(&message)) { |
| 234 LOG(LS_ERROR) << "Message queue full. Can't start logging."; | 230 LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
| 235 return false; | 231 return false; |
| 236 } | 232 } |
| 233 helper_thread_.SignalNewEvent(); | |
| 237 LOG(LS_INFO) << "Starting WebRTC event log."; | 234 LOG(LS_INFO) << "Starting WebRTC event log."; |
| 238 return true; | 235 return true; |
| 239 } | 236 } |
| 240 | 237 |
| 241 void RtcEventLogImpl::StopLogging() { | 238 void RtcEventLogImpl::StopLogging() { |
| 242 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 239 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 243 RtcEventLogHelperThread::ControlMessage message; | 240 RtcEventLogHelperThread::ControlMessage message; |
| 244 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; | 241 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; |
| 245 message.stop_time = clock_->TimeInMicroseconds(); | 242 message.stop_time = clock_->TimeInMicroseconds(); |
| 246 while (!message_queue_.Insert(&message)) { | 243 while (!message_queue_.Insert(&message)) { |
| 247 // TODO(terelius): We would like to have a blocking Insert function in the | 244 // TODO(terelius): We would like to have a blocking Insert function in the |
| 248 // SwapQueue, but for the time being we will just clear any previous | 245 // SwapQueue, but for the time being we will just clear any previous |
| 249 // messages. | 246 // messages. |
| 250 // Since StopLogging waits for the thread, it is essential that we don't | 247 // Since StopLogging waits for the thread, it is essential that we don't |
| 251 // clear any STOP_FILE messages. To ensure that there is only one call at a | 248 // clear any STOP_FILE messages. To ensure that there is only one call at a |
| 252 // time, we require that all calls to StopLogging are made on the same | 249 // time, we require that all calls to StopLogging are made on the same |
| 253 // thread. | 250 // thread. |
| 254 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging."; | 251 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging."; |
| 255 message_queue_.Clear(); | 252 message_queue_.Clear(); |
| 256 } | 253 } |
| 257 LOG(LS_INFO) << "Stopping WebRTC event log."; | 254 LOG(LS_INFO) << "Stopping WebRTC event log."; |
| 258 wake_up_.Set(); // Request the output thread to wake up. | 255 helper_thread_.WaitForFileFinished(); |
| 259 stopped_.Wait(rtc::Event::kForever); // Wait for the log to stop. | |
| 260 } | 256 } |
| 261 | 257 |
| 262 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 258 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
| 263 const VideoReceiveStream::Config& config) { | 259 const VideoReceiveStream::Config& config) { |
| 264 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 260 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| 265 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 261 event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| 266 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); | 262 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); |
| 267 | 263 |
| 268 rtclog::VideoReceiveConfig* receiver_config = | 264 rtclog::VideoReceiveConfig* receiver_config = |
| 269 event->mutable_video_receiver_config(); | 265 event->mutable_video_receiver_config(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 285 receiver_config->add_header_extensions(); | 281 receiver_config->add_header_extensions(); |
| 286 extension->set_name(e.uri); | 282 extension->set_name(e.uri); |
| 287 extension->set_id(e.id); | 283 extension->set_id(e.id); |
| 288 } | 284 } |
| 289 | 285 |
| 290 for (const auto& d : config.decoders) { | 286 for (const auto& d : config.decoders) { |
| 291 rtclog::DecoderConfig* decoder = receiver_config->add_decoders(); | 287 rtclog::DecoderConfig* decoder = receiver_config->add_decoders(); |
| 292 decoder->set_name(d.payload_name); | 288 decoder->set_name(d.payload_name); |
| 293 decoder->set_payload_type(d.payload_type); | 289 decoder->set_payload_type(d.payload_type); |
| 294 } | 290 } |
| 295 if (!event_queue_.Insert(&event)) { | 291 StoreEvent(&event); |
|
tommi
2016/06/08 15:26:40
This pattern looked strange to me (passing a |std:
terelius
2016/06/08 17:52:17
You're right. I thought about the argument type to
| |
| 296 LOG(LS_ERROR) << "Config queue full. Not logging config event."; | |
| 297 } | |
| 298 } | 292 } |
| 299 | 293 |
| 300 void RtcEventLogImpl::LogVideoSendStreamConfig( | 294 void RtcEventLogImpl::LogVideoSendStreamConfig( |
| 301 const VideoSendStream::Config& config) { | 295 const VideoSendStream::Config& config) { |
| 302 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 296 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| 303 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 297 event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| 304 event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); | 298 event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); |
| 305 | 299 |
| 306 rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); | 300 rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); |
| 307 | 301 |
| 308 for (const auto& ssrc : config.rtp.ssrcs) { | 302 for (const auto& ssrc : config.rtp.ssrcs) { |
| 309 sender_config->add_ssrcs(ssrc); | 303 sender_config->add_ssrcs(ssrc); |
| 310 } | 304 } |
| 311 | 305 |
| 312 for (const auto& e : config.rtp.extensions) { | 306 for (const auto& e : config.rtp.extensions) { |
| 313 rtclog::RtpHeaderExtension* extension = | 307 rtclog::RtpHeaderExtension* extension = |
| 314 sender_config->add_header_extensions(); | 308 sender_config->add_header_extensions(); |
| 315 extension->set_name(e.uri); | 309 extension->set_name(e.uri); |
| 316 extension->set_id(e.id); | 310 extension->set_id(e.id); |
| 317 } | 311 } |
| 318 | 312 |
| 319 for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) { | 313 for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) { |
| 320 sender_config->add_rtx_ssrcs(rtx_ssrc); | 314 sender_config->add_rtx_ssrcs(rtx_ssrc); |
| 321 } | 315 } |
| 322 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); | 316 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); |
| 323 | 317 |
| 324 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); | 318 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); |
| 325 encoder->set_name(config.encoder_settings.payload_name); | 319 encoder->set_name(config.encoder_settings.payload_name); |
| 326 encoder->set_payload_type(config.encoder_settings.payload_type); | 320 encoder->set_payload_type(config.encoder_settings.payload_type); |
| 327 if (!event_queue_.Insert(&event)) { | 321 StoreEvent(&event); |
| 328 LOG(LS_ERROR) << "Config queue full. Not logging config event."; | |
| 329 } | |
| 330 } | 322 } |
| 331 | 323 |
| 332 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, | 324 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
| 333 MediaType media_type, | 325 MediaType media_type, |
| 334 const uint8_t* header, | 326 const uint8_t* header, |
| 335 size_t packet_length) { | 327 size_t packet_length) { |
| 336 // Read header length (in bytes) from packet data. | 328 // Read header length (in bytes) from packet data. |
| 337 if (packet_length < 12u) { | 329 if (packet_length < 12u) { |
| 338 return; // Don't read outside the packet. | 330 return; // Don't read outside the packet. |
| 339 } | 331 } |
| 340 const bool x = (header[0] & 0x10) != 0; | 332 const bool x = (header[0] & 0x10) != 0; |
| 341 const uint8_t cc = header[0] & 0x0f; | 333 const uint8_t cc = header[0] & 0x0f; |
| 342 size_t header_length = 12u + cc * 4u; | 334 size_t header_length = 12u + cc * 4u; |
| 343 | 335 |
| 344 if (x) { | 336 if (x) { |
| 345 if (packet_length < 12u + cc * 4u + 4u) { | 337 if (packet_length < 12u + cc * 4u + 4u) { |
| 346 return; // Don't read outside the packet. | 338 return; // Don't read outside the packet. |
| 347 } | 339 } |
| 348 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); | 340 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); |
| 349 header_length += (x_len + 1) * 4; | 341 header_length += (x_len + 1) * 4; |
| 350 } | 342 } |
| 351 | 343 |
| 352 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); | 344 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); |
| 353 rtp_event->set_timestamp_us(clock_->TimeInMicroseconds()); | 345 rtp_event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| 354 rtp_event->set_type(rtclog::Event::RTP_EVENT); | 346 rtp_event->set_type(rtclog::Event::RTP_EVENT); |
| 355 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); | 347 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); |
| 356 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); | 348 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
| 357 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); | 349 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); |
| 358 rtp_event->mutable_rtp_packet()->set_header(header, header_length); | 350 rtp_event->mutable_rtp_packet()->set_header(header, header_length); |
| 359 if (!event_queue_.Insert(&rtp_event)) { | 351 StoreEvent(&rtp_event); |
| 360 LOG(LS_ERROR) << "RTP queue full. Not logging RTP packet."; | |
| 361 } | |
| 362 } | 352 } |
| 363 | 353 |
| 364 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, | 354 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
| 365 MediaType media_type, | 355 MediaType media_type, |
| 366 const uint8_t* packet, | 356 const uint8_t* packet, |
| 367 size_t length) { | 357 size_t length) { |
| 368 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); | 358 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); |
| 369 rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds()); | 359 rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| 370 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); | 360 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); |
| 371 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); | 361 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 FALLTHROUGH(); | 399 FALLTHROUGH(); |
| 410 default: | 400 default: |
| 411 // We don't log sender descriptions, application defined messages | 401 // We don't log sender descriptions, application defined messages |
| 412 // or message blocks of unknown type. | 402 // or message blocks of unknown type. |
| 413 break; | 403 break; |
| 414 } | 404 } |
| 415 | 405 |
| 416 block_begin += block_size; | 406 block_begin += block_size; |
| 417 } | 407 } |
| 418 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); | 408 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); |
| 419 if (!event_queue_.Insert(&rtcp_event)) { | 409 StoreEvent(&rtcp_event); |
| 420 LOG(LS_ERROR) << "RTCP queue full. Not logging RTCP packet."; | |
| 421 } | |
| 422 } | 410 } |
| 423 | 411 |
| 424 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 412 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
| 425 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 413 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| 426 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 414 event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| 427 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); | 415 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
| 428 auto playout_event = event->mutable_audio_playout_event(); | 416 auto playout_event = event->mutable_audio_playout_event(); |
| 429 playout_event->set_local_ssrc(ssrc); | 417 playout_event->set_local_ssrc(ssrc); |
| 430 if (!event_queue_.Insert(&event)) { | 418 StoreEvent(&event); |
| 431 LOG(LS_ERROR) << "Playout queue full. Not logging ACM playout."; | |
| 432 } | |
| 433 } | 419 } |
| 434 | 420 |
| 435 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, | 421 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
| 436 uint8_t fraction_loss, | 422 uint8_t fraction_loss, |
| 437 int32_t total_packets) { | 423 int32_t total_packets) { |
| 438 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 424 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
| 439 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 425 event->set_timestamp_us(clock_->TimeInMicroseconds()); |
| 440 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); | 426 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); |
| 441 auto bwe_event = event->mutable_bwe_packet_loss_event(); | 427 auto bwe_event = event->mutable_bwe_packet_loss_event(); |
| 442 bwe_event->set_bitrate(bitrate); | 428 bwe_event->set_bitrate(bitrate); |
| 443 bwe_event->set_fraction_loss(fraction_loss); | 429 bwe_event->set_fraction_loss(fraction_loss); |
| 444 bwe_event->set_total_packets(total_packets); | 430 bwe_event->set_total_packets(total_packets); |
| 445 if (!event_queue_.Insert(&event)) { | 431 StoreEvent(&event); |
| 446 LOG(LS_ERROR) << "BWE loss queue full. Not logging BWE update."; | 432 } |
| 433 | |
| 434 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { | |
| 435 if (!event_queue_.Insert(event)) { | |
| 436 LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event."; | |
| 447 } | 437 } |
| 438 helper_thread_.SignalNewEvent(); | |
| 448 } | 439 } |
| 449 | 440 |
| 450 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, | 441 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, |
| 451 rtclog::EventStream* result) { | 442 rtclog::EventStream* result) { |
| 452 char tmp_buffer[1024]; | 443 char tmp_buffer[1024]; |
| 453 int bytes_read = 0; | 444 int bytes_read = 0; |
| 454 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create()); | 445 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create()); |
| 455 if (dump_file->OpenFile(file_name.c_str(), true) != 0) { | 446 if (dump_file->OpenFile(file_name.c_str(), true) != 0) { |
| 456 return false; | 447 return false; |
| 457 } | 448 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 468 // RtcEventLog member functions. | 459 // RtcEventLog member functions. |
| 469 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { | 460 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { |
| 470 #ifdef ENABLE_RTC_EVENT_LOG | 461 #ifdef ENABLE_RTC_EVENT_LOG |
| 471 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); | 462 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); |
| 472 #else | 463 #else |
| 473 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 464 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
| 474 #endif // ENABLE_RTC_EVENT_LOG | 465 #endif // ENABLE_RTC_EVENT_LOG |
| 475 } | 466 } |
| 476 | 467 |
| 477 } // namespace webrtc | 468 } // namespace webrtc |
| OLD | NEW |