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

Side by Side Diff: webrtc/call/rtc_event_log.h

Issue 2380683005: Moved RtcEventLog files from call/ to logging/ (new top level dir) (Closed)
Patch Set: Rebase to master Created 4 years, 2 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 | « webrtc/call/ringbuffer_unittest.cc ('k') | webrtc/call/rtc_event_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_CALL_RTC_EVENT_LOG_H_
12 #define WEBRTC_CALL_RTC_EVENT_LOG_H_
13
14 #include <memory>
15 #include <string>
16
17 #include "webrtc/base/platform_file.h"
18 #include "webrtc/video_receive_stream.h"
19 #include "webrtc/video_send_stream.h"
20
21 namespace webrtc {
22
23 // Forward declaration of storage class that is automatically generated from
24 // the protobuf file.
25 namespace rtclog {
26 class EventStream;
27 } // namespace rtclog
28
29 class Clock;
30 class RtcEventLogImpl;
31
32 enum class MediaType;
33
34 enum PacketDirection { kIncomingPacket = 0, kOutgoingPacket };
35
36 class RtcEventLog {
37 public:
38 virtual ~RtcEventLog() {}
39
40 // Factory method to create an RtcEventLog object.
41 static std::unique_ptr<RtcEventLog> Create(const Clock* clock);
42
43 // Create an RtcEventLog object that does nothing.
44 static std::unique_ptr<RtcEventLog> CreateNull();
45
46 // Starts logging a maximum of max_size_bytes bytes to the specified file.
47 // If the file already exists it will be overwritten.
48 // If max_size_bytes <= 0, logging will be active until StopLogging is called.
49 // The function has no effect and returns false if we can't start a new log
50 // e.g. because we are already logging or the file cannot be opened.
51 virtual bool StartLogging(const std::string& file_name,
52 int64_t max_size_bytes) = 0;
53
54 // Same as above. The RtcEventLog takes ownership of the file if the call
55 // is successful, i.e. if it returns true.
56 virtual bool StartLogging(rtc::PlatformFile platform_file,
57 int64_t max_size_bytes) = 0;
58
59 // Deprecated. Pass an explicit file size limit.
60 bool StartLogging(const std::string& file_name) {
61 return StartLogging(file_name, 10000000);
62 }
63
64 // Deprecated. Pass an explicit file size limit.
65 bool StartLogging(rtc::PlatformFile platform_file) {
66 return StartLogging(platform_file, 10000000);
67 }
68
69 // Stops logging to file and waits until the thread has finished.
70 virtual void StopLogging() = 0;
71
72 // Logs configuration information for webrtc::VideoReceiveStream.
73 virtual void LogVideoReceiveStreamConfig(
74 const webrtc::VideoReceiveStream::Config& config) = 0;
75
76 // Logs configuration information for webrtc::VideoSendStream.
77 virtual void LogVideoSendStreamConfig(
78 const webrtc::VideoSendStream::Config& config) = 0;
79
80 // Logs the header of an incoming or outgoing RTP packet. packet_length
81 // is the total length of the packet, including both header and payload.
82 virtual void LogRtpHeader(PacketDirection direction,
83 MediaType media_type,
84 const uint8_t* header,
85 size_t packet_length) = 0;
86
87 // Logs an incoming or outgoing RTCP packet.
88 virtual void LogRtcpPacket(PacketDirection direction,
89 MediaType media_type,
90 const uint8_t* packet,
91 size_t length) = 0;
92
93 // Logs an audio playout event.
94 virtual void LogAudioPlayout(uint32_t ssrc) = 0;
95
96 // Logs a bitrate update from the bandwidth estimator based on packet loss.
97 virtual void LogBwePacketLossEvent(int32_t bitrate,
98 uint8_t fraction_loss,
99 int32_t total_packets) = 0;
100
101 // Reads an RtcEventLog file and returns true when reading was successful.
102 // The result is stored in the given EventStream object.
103 // The order of the events in the EventStream is implementation defined.
104 // The current implementation writes a LOG_START event, then the old
105 // configurations, then the remaining events in timestamp order and finally
106 // a LOG_END event. However, this might change without further notice.
107 // TODO(terelius): Change result type to a vector?
108 static bool ParseRtcEventLog(const std::string& file_name,
109 rtclog::EventStream* result);
110 };
111
112 // No-op implementation is used if flag is not set, or in tests.
113 class RtcEventLogNullImpl final : public RtcEventLog {
114 public:
115 bool StartLogging(const std::string& file_name,
116 int64_t max_size_bytes) override {
117 return false;
118 }
119 bool StartLogging(rtc::PlatformFile platform_file,
120 int64_t max_size_bytes) override;
121 void StopLogging() override {}
122 void LogVideoReceiveStreamConfig(
123 const VideoReceiveStream::Config& config) override {}
124 void LogVideoSendStreamConfig(
125 const VideoSendStream::Config& config) override {}
126 void LogRtpHeader(PacketDirection direction,
127 MediaType media_type,
128 const uint8_t* header,
129 size_t packet_length) override {}
130 void LogRtcpPacket(PacketDirection direction,
131 MediaType media_type,
132 const uint8_t* packet,
133 size_t length) override {}
134 void LogAudioPlayout(uint32_t ssrc) override {}
135 void LogBwePacketLossEvent(int32_t bitrate,
136 uint8_t fraction_loss,
137 int32_t total_packets) override {}
138 };
139
140 } // namespace webrtc
141
142 #endif // WEBRTC_CALL_RTC_EVENT_LOG_H_
OLDNEW
« no previous file with comments | « webrtc/call/ringbuffer_unittest.cc ('k') | webrtc/call/rtc_event_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698