Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: webrtc/logging/rtc_event_log/rtc_event_log.cc

Issue 2787263003: Delete all log messages depending on system_wrappers. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h"
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h"
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h"
35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
36 #include "webrtc/system_wrappers/include/file_wrapper.h" 36 #include "webrtc/system_wrappers/include/file_wrapper.h"
37 #include "webrtc/system_wrappers/include/logging.h"
38 37
39 #ifdef ENABLE_RTC_EVENT_LOG 38 #ifdef ENABLE_RTC_EVENT_LOG
40 // Files generated at build-time by the protobuf compiler. 39 // Files generated at build-time by the protobuf compiler.
41 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 40 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
42 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" 41 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
43 #else 42 #else
44 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" 43 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
45 #endif 44 #endif
46 #endif 45 #endif
47 46
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 199 RTC_DCHECK(thread_checker_.CalledOnValidThread());
201 RtcEventLogHelperThread::ControlMessage message; 200 RtcEventLogHelperThread::ControlMessage message;
202 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; 201 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE;
203 message.max_size_bytes = max_size_bytes <= 0 202 message.max_size_bytes = max_size_bytes <= 0
204 ? std::numeric_limits<int64_t>::max() 203 ? std::numeric_limits<int64_t>::max()
205 : max_size_bytes; 204 : max_size_bytes;
206 message.start_time = rtc::TimeMicros(); 205 message.start_time = rtc::TimeMicros();
207 message.stop_time = std::numeric_limits<int64_t>::max(); 206 message.stop_time = std::numeric_limits<int64_t>::max();
208 message.file.reset(FileWrapper::Create()); 207 message.file.reset(FileWrapper::Create());
209 if (!message.file->OpenFile(file_name.c_str(), false)) { 208 if (!message.file->OpenFile(file_name.c_str(), false)) {
210 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started.";
211 return false; 209 return false;
212 } 210 }
213 if (!message_queue_.Insert(&message)) { 211 if (!message_queue_.Insert(&message)) {
214 LOG(LS_ERROR) << "Message queue full. Can't start logging.";
215 return false; 212 return false;
216 } 213 }
217 helper_thread_.SignalNewEvent(); 214 helper_thread_.SignalNewEvent();
218 LOG(LS_INFO) << "Starting WebRTC event log.";
219 return true; 215 return true;
220 } 216 }
221 217
222 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, 218 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file,
223 int64_t max_size_bytes) { 219 int64_t max_size_bytes) {
224 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 220 RTC_DCHECK(thread_checker_.CalledOnValidThread());
225 RtcEventLogHelperThread::ControlMessage message; 221 RtcEventLogHelperThread::ControlMessage message;
226 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; 222 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE;
227 message.max_size_bytes = max_size_bytes <= 0 223 message.max_size_bytes = max_size_bytes <= 0
228 ? std::numeric_limits<int64_t>::max() 224 ? std::numeric_limits<int64_t>::max()
229 : max_size_bytes; 225 : max_size_bytes;
230 message.start_time = rtc::TimeMicros(); 226 message.start_time = rtc::TimeMicros();
231 message.stop_time = std::numeric_limits<int64_t>::max(); 227 message.stop_time = std::numeric_limits<int64_t>::max();
232 message.file.reset(FileWrapper::Create()); 228 message.file.reset(FileWrapper::Create());
233 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); 229 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file);
234 if (!file_handle) { 230 if (!file_handle) {
235 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started.";
236 // Even though we failed to open a FILE*, the platform_file is still open 231 // Even though we failed to open a FILE*, the platform_file is still open
237 // and needs to be closed. 232 // and needs to be closed.
238 if (!rtc::ClosePlatformFile(platform_file)) { 233 if (!rtc::ClosePlatformFile(platform_file)) {
239 LOG(LS_ERROR) << "Can't close file.";
240 } 234 }
241 return false; 235 return false;
242 } 236 }
243 if (!message.file->OpenFromFileHandle(file_handle)) { 237 if (!message.file->OpenFromFileHandle(file_handle)) {
244 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started.";
245 return false; 238 return false;
246 } 239 }
247 if (!message_queue_.Insert(&message)) { 240 if (!message_queue_.Insert(&message)) {
248 LOG(LS_ERROR) << "Message queue full. Can't start logging.";
249 return false; 241 return false;
250 } 242 }
251 helper_thread_.SignalNewEvent(); 243 helper_thread_.SignalNewEvent();
252 LOG(LS_INFO) << "Starting WebRTC event log.";
253 return true; 244 return true;
254 } 245 }
255 246
256 void RtcEventLogImpl::StopLogging() { 247 void RtcEventLogImpl::StopLogging() {
257 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 248 RTC_DCHECK(thread_checker_.CalledOnValidThread());
258 RtcEventLogHelperThread::ControlMessage message; 249 RtcEventLogHelperThread::ControlMessage message;
259 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; 250 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE;
260 message.stop_time = rtc::TimeMicros(); 251 message.stop_time = rtc::TimeMicros();
261 while (!message_queue_.Insert(&message)) { 252 while (!message_queue_.Insert(&message)) {
262 // TODO(terelius): We would like to have a blocking Insert function in the 253 // TODO(terelius): We would like to have a blocking Insert function in the
263 // SwapQueue, but for the time being we will just clear any previous 254 // SwapQueue, but for the time being we will just clear any previous
264 // messages. 255 // messages.
265 // Since StopLogging waits for the thread, it is essential that we don't 256 // Since StopLogging waits for the thread, it is essential that we don't
266 // clear any STOP_FILE messages. To ensure that there is only one call at a 257 // clear any STOP_FILE messages. To ensure that there is only one call at a
267 // time, we require that all calls to StopLogging are made on the same 258 // time, we require that all calls to StopLogging are made on the same
268 // thread. 259 // thread.
269 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging.";
270 message_queue_.Clear(); 260 message_queue_.Clear();
271 } 261 }
272 LOG(LS_INFO) << "Stopping WebRTC event log.";
273 helper_thread_.WaitForFileFinished(); 262 helper_thread_.WaitForFileFinished();
274 } 263 }
275 264
276 void RtcEventLogImpl::LogVideoReceiveStreamConfig( 265 void RtcEventLogImpl::LogVideoReceiveStreamConfig(
277 const VideoReceiveStream::Config& config) { 266 const VideoReceiveStream::Config& config) {
278 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); 267 std::unique_ptr<rtclog::Event> event(new rtclog::Event());
279 event->set_timestamp_us(rtc::TimeMicros()); 268 event->set_timestamp_us(rtc::TimeMicros());
280 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); 269 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT);
281 270
282 rtclog::VideoReceiveConfig* receiver_config = 271 rtclog::VideoReceiveConfig* receiver_config =
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 auto probe_result = event->mutable_probe_result(); 552 auto probe_result = event->mutable_probe_result();
564 probe_result->set_id(id); 553 probe_result->set_id(id);
565 probe_result->set_result(result); 554 probe_result->set_result(result);
566 if (result == rtclog::BweProbeResult::SUCCESS) 555 if (result == rtclog::BweProbeResult::SUCCESS)
567 probe_result->set_bitrate_bps(bitrate_bps); 556 probe_result->set_bitrate_bps(bitrate_bps);
568 StoreEvent(&event); 557 StoreEvent(&event);
569 } 558 }
570 559
571 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { 560 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) {
572 if (!event_queue_.Insert(event)) { 561 if (!event_queue_.Insert(event)) {
573 LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event.";
574 } 562 }
575 helper_thread_.SignalNewEvent(); 563 helper_thread_.SignalNewEvent();
576 } 564 }
577 565
578 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, 566 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name,
579 rtclog::EventStream* result) { 567 rtclog::EventStream* result) {
580 char tmp_buffer[1024]; 568 char tmp_buffer[1024];
581 int bytes_read = 0; 569 int bytes_read = 0;
582 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create()); 570 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create());
583 if (!dump_file->OpenFile(file_name.c_str(), true)) { 571 if (!dump_file->OpenFile(file_name.c_str(), true)) {
584 return false; 572 return false;
585 } 573 }
586 std::string dump_buffer; 574 std::string dump_buffer;
587 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) { 575 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) {
588 dump_buffer.append(tmp_buffer, bytes_read); 576 dump_buffer.append(tmp_buffer, bytes_read);
589 } 577 }
590 dump_file->CloseFile(); 578 dump_file->CloseFile();
591 return result->ParseFromString(dump_buffer); 579 return result->ParseFromString(dump_buffer);
592 } 580 }
593 581
594 #endif // ENABLE_RTC_EVENT_LOG 582 #endif // ENABLE_RTC_EVENT_LOG
595 583
596 bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file, 584 bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file,
597 int64_t max_size_bytes) { 585 int64_t max_size_bytes) {
598 // The platform_file is open and needs to be closed. 586 // The platform_file is open and needs to be closed.
599 if (!rtc::ClosePlatformFile(platform_file)) { 587 if (!rtc::ClosePlatformFile(platform_file)) {
600 LOG(LS_ERROR) << "Can't close file.";
601 } 588 }
602 return false; 589 return false;
603 } 590 }
604 591
605 // RtcEventLog member functions. 592 // RtcEventLog member functions.
606 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { 593 std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
607 #ifdef ENABLE_RTC_EVENT_LOG 594 #ifdef ENABLE_RTC_EVENT_LOG
608 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); 595 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl());
609 #else 596 #else
610 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 597 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
611 #endif // ENABLE_RTC_EVENT_LOG 598 #endif // ENABLE_RTC_EVENT_LOG
612 } 599 }
613 600
614 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { 601 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
615 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 602 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
616 } 603 }
617 604
618 } // namespace webrtc 605 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698