OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2016 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 #ifndef WEBRTC_CALL_RTC_EVENT_LOG_PARSER_H_ | |
11 #define WEBRTC_CALL_RTC_EVENT_LOG_PARSER_H_ | |
12 | |
13 #include <string> | |
14 #include <vector> | |
15 | |
16 #include "webrtc/base/ignore_wundef.h" | |
17 #include "webrtc/call/rtc_event_log.h" | |
18 #include "webrtc/video_receive_stream.h" | |
19 #include "webrtc/video_send_stream.h" | |
20 | |
21 // Files generated at build-time by the protobuf compiler. | |
22 RTC_PUSH_IGNORING_WUNDEF() | |
23 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | |
24 #include "external/webrtc/webrtc/call/rtc_event_log.pb.h" | |
25 #else | |
26 #include "webrtc/call/rtc_event_log.pb.h" | |
27 #endif | |
28 RTC_POP_IGNORING_WUNDEF() | |
29 | |
30 namespace webrtc { | |
31 | |
32 enum class MediaType; | |
33 | |
34 class ParsedRtcEventLog { | |
35 friend class RtcEventLogTestHelper; | |
36 | |
37 public: | |
38 enum EventType { | |
39 UNKNOWN_EVENT = 0, | |
40 LOG_START = 1, | |
41 LOG_END = 2, | |
42 RTP_EVENT = 3, | |
43 RTCP_EVENT = 4, | |
44 AUDIO_PLAYOUT_EVENT = 5, | |
45 BWE_PACKET_LOSS_EVENT = 6, | |
46 BWE_PACKET_DELAY_EVENT = 7, | |
47 VIDEO_RECEIVER_CONFIG_EVENT = 8, | |
48 VIDEO_SENDER_CONFIG_EVENT = 9, | |
49 AUDIO_RECEIVER_CONFIG_EVENT = 10, | |
50 AUDIO_SENDER_CONFIG_EVENT = 11 | |
51 }; | |
52 | |
53 // Reads an RtcEventLog file and returns true if parsing was successful. | |
54 bool ParseFile(const std::string& file_name); | |
55 | |
56 // Reads an RtcEventLog from a string and returns true if successful. | |
57 bool ParseString(const std::string& s); | |
58 | |
59 // Reads an RtcEventLog from an istream and returns true if successful. | |
60 bool ParseStream(std::istream& stream); | |
61 | |
62 // Returns the number of events in an EventStream. | |
63 size_t GetNumberOfEvents() const; | |
64 | |
65 // Reads the arrival timestamp (in microseconds) from a rtclog::Event. | |
66 int64_t GetTimestamp(size_t index) const; | |
67 | |
68 // Reads the event type of the rtclog::Event at |index|. | |
69 EventType GetEventType(size_t index) const; | |
70 | |
71 // Reads the header, direction, media type, header length and packet length | |
72 // from the RTP event at |index|, and stores the values in the corresponding | |
73 // output parameters. The output parameters can be set to nullptr if those | |
74 // values aren't needed. | |
75 // NB: The header must have space for at least IP_PACKET_SIZE bytes. | |
76 void GetRtpHeader(size_t index, | |
77 PacketDirection* incoming, | |
78 MediaType* media_type, | |
79 uint8_t* header, | |
80 size_t* header_length, | |
81 size_t* total_length) const; | |
82 | |
83 // Reads packet, direction, media type and packet length from the RTCP event | |
84 // at |index|, and stores the values in the corresponding output parameters. | |
85 // The output parameters can be set to nullptr if those values aren't needed. | |
86 // NB: The packet must have space for at least IP_PACKET_SIZE bytes. | |
87 void GetRtcpPacket(size_t index, | |
88 PacketDirection* incoming, | |
89 MediaType* media_type, | |
90 uint8_t* packet, | |
91 size_t* length) const; | |
92 | |
93 // Reads a config event to a (non-NULL) VideoReceiveStream::Config struct. | |
94 // Only the fields that are stored in the protobuf will be written. | |
95 void GetVideoReceiveConfig(size_t index, | |
96 VideoReceiveStream::Config* config) const; | |
97 | |
98 // Reads a config event to a (non-NULL) VideoSendStream::Config struct. | |
99 // Only the fields that are stored in the protobuf will be written. | |
100 void GetVideoSendConfig(size_t index, VideoSendStream::Config* config) const; | |
101 | |
102 // Reads the SSRC from the audio playout event at |index|. The SSRC is stored | |
103 // in the output parameter ssrc. The output parameter can be set to nullptr | |
104 // and in that case the function only asserts that the event is well formed. | |
105 void GetAudioPlayout(size_t index, uint32_t* ssrc) const; | |
106 | |
107 // Reads bitrate, fraction loss (as defined in RFC 1889) and total number of | |
108 // expected packets from the BWE event at |index| and stores the values in | |
109 // the corresponding output parameters. The output parameters can be set to | |
110 // nullptr if those values aren't needed. | |
111 // NB: The packet must have space for at least IP_PACKET_SIZE bytes. | |
112 void GetBwePacketLossEvent(size_t index, | |
113 int32_t* bitrate, | |
114 uint8_t* fraction_loss, | |
115 int32_t* total_packets) const; | |
116 | |
117 private: | |
118 std::vector<rtclog::Event> events_; | |
119 }; | |
120 | |
121 } // namespace webrtc | |
122 | |
123 #endif // WEBRTC_CALL_RTC_EVENT_LOG_PARSER_H_ | |
OLD | NEW |