Index: webrtc/call/rtc_event_log.cc |
diff --git a/webrtc/call/rtc_event_log.cc b/webrtc/call/rtc_event_log.cc |
index 3c602b772188dc80738e075104805cb8facfe471..7dc0dd2f6f1317126320a988c89572637c8f61fa 100644 |
--- a/webrtc/call/rtc_event_log.cc |
+++ b/webrtc/call/rtc_event_log.cc |
@@ -103,6 +103,8 @@ class RtcEventLogImpl final : public RtcEventLog { |
int32_t total_packets) override; |
private: |
+ void StoreEvent(std::unique_ptr<rtclog::Event>* event); |
+ |
// Message queue for passing control messages to the logging thread. |
SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
@@ -110,6 +112,7 @@ class RtcEventLogImpl final : public RtcEventLog { |
SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; |
rtc::Event wake_up_; |
+ rtc::Event end_hibernation_; |
rtc::Event stopped_; |
const Clock* const clock_; |
@@ -166,11 +169,13 @@ RtcEventLogImpl::RtcEventLogImpl(const Clock* clock) |
: message_queue_(kControlMessagesPerSecond), |
event_queue_(kEventsPerSecond), |
wake_up_(false, false), |
+ end_hibernation_(false, false), |
stopped_(false, false), |
clock_(clock), |
helper_thread_(&message_queue_, |
&event_queue_, |
&wake_up_, |
+ &end_hibernation_, |
&stopped_, |
clock), |
thread_checker_() { |
@@ -201,6 +206,7 @@ bool RtcEventLogImpl::StartLogging(const std::string& file_name, |
LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
return false; |
} |
+ end_hibernation_.Set(); |
LOG(LS_INFO) << "Starting WebRTC event log."; |
return true; |
} |
@@ -234,6 +240,7 @@ bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, |
LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
return false; |
} |
+ end_hibernation_.Set(); |
LOG(LS_INFO) << "Starting WebRTC event log."; |
return true; |
} |
@@ -255,6 +262,7 @@ void RtcEventLogImpl::StopLogging() { |
message_queue_.Clear(); |
} |
LOG(LS_INFO) << "Stopping WebRTC event log."; |
+ end_hibernation_.Set(); |
pbos-webrtc
2016/06/03 08:54:25
Should the last three lines here be replaced with
terelius
2016/06/08 11:47:29
Done. Note that this only reduces the number of sh
|
wake_up_.Set(); // Request the output thread to wake up. |
stopped_.Wait(rtc::Event::kForever); // Wait for the log to stop. |
} |
@@ -292,9 +300,7 @@ void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
decoder->set_name(d.payload_name); |
decoder->set_payload_type(d.payload_type); |
} |
- if (!event_queue_.Insert(&event)) { |
- LOG(LS_ERROR) << "Config queue full. Not logging config event."; |
- } |
+ StoreEvent(&event); |
} |
void RtcEventLogImpl::LogVideoSendStreamConfig( |
@@ -324,9 +330,7 @@ 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); |
- if (!event_queue_.Insert(&event)) { |
- LOG(LS_ERROR) << "Config queue full. Not logging config event."; |
- } |
+ StoreEvent(&event); |
} |
void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
@@ -356,9 +360,7 @@ void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); |
rtp_event->mutable_rtp_packet()->set_header(header, header_length); |
- if (!event_queue_.Insert(&rtp_event)) { |
- LOG(LS_ERROR) << "RTP queue full. Not logging RTP packet."; |
- } |
+ StoreEvent(&rtp_event); |
} |
void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
@@ -416,9 +418,7 @@ void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
block_begin += block_size; |
} |
rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); |
- if (!event_queue_.Insert(&rtcp_event)) { |
- LOG(LS_ERROR) << "RTCP queue full. Not logging RTCP packet."; |
- } |
+ StoreEvent(&rtcp_event); |
} |
void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
@@ -427,9 +427,7 @@ void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
auto playout_event = event->mutable_audio_playout_event(); |
playout_event->set_local_ssrc(ssrc); |
- if (!event_queue_.Insert(&event)) { |
- LOG(LS_ERROR) << "Playout queue full. Not logging ACM playout."; |
- } |
+ StoreEvent(&event); |
} |
void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
@@ -442,9 +440,14 @@ void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
bwe_event->set_bitrate(bitrate); |
bwe_event->set_fraction_loss(fraction_loss); |
bwe_event->set_total_packets(total_packets); |
- if (!event_queue_.Insert(&event)) { |
- LOG(LS_ERROR) << "BWE loss queue full. Not logging BWE update."; |
+ StoreEvent(&event); |
+} |
+ |
+void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { |
+ if (!event_queue_.Insert(event)) { |
+ LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event."; |
} |
+ end_hibernation_.Set(); |
} |
bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, |