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 |
11 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 11 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
12 | 12 |
13 #include <limits> | 13 #include <limits> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
18 #include "webrtc/base/event.h" | 18 #include "webrtc/base/event.h" |
19 #include "webrtc/base/swap_queue.h" | 19 #include "webrtc/base/swap_queue.h" |
20 #include "webrtc/base/thread_checker.h" | 20 #include "webrtc/base/thread_checker.h" |
21 #include "webrtc/base/timeutils.h" | |
21 #include "webrtc/call.h" | 22 #include "webrtc/call.h" |
22 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" | 23 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 25 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
28 #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" |
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" |
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
35 #include "webrtc/system_wrappers/include/clock.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" | 37 #include "webrtc/system_wrappers/include/logging.h" |
38 | 38 |
39 #ifdef ENABLE_RTC_EVENT_LOG | 39 #ifdef ENABLE_RTC_EVENT_LOG |
40 // Files generated at build-time by the protobuf compiler. | 40 // Files generated at build-time by the protobuf compiler. |
41 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 41 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
42 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" | 42 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" |
43 #else | 43 #else |
44 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" | 44 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" |
45 #endif | 45 #endif |
46 #endif | 46 #endif |
47 | 47 |
48 namespace webrtc { | 48 namespace webrtc { |
49 | 49 |
50 #ifdef ENABLE_RTC_EVENT_LOG | 50 #ifdef ENABLE_RTC_EVENT_LOG |
51 | 51 |
52 class RtcEventLogImpl final : public RtcEventLog { | 52 class RtcEventLogImpl final : public RtcEventLog { |
53 public: | 53 public: |
54 explicit RtcEventLogImpl(const Clock* clock); | 54 explicit RtcEventLogImpl(); |
the sun
2016/11/18 15:43:59
no need for explicit
| |
55 ~RtcEventLogImpl() override; | 55 ~RtcEventLogImpl() override; |
56 | 56 |
57 bool StartLogging(const std::string& file_name, | 57 bool StartLogging(const std::string& file_name, |
58 int64_t max_size_bytes) override; | 58 int64_t max_size_bytes) override; |
59 bool StartLogging(rtc::PlatformFile platform_file, | 59 bool StartLogging(rtc::PlatformFile platform_file, |
60 int64_t max_size_bytes) override; | 60 int64_t max_size_bytes) override; |
61 void StopLogging() override; | 61 void StopLogging() override; |
62 void LogVideoReceiveStreamConfig( | 62 void LogVideoReceiveStreamConfig( |
63 const VideoReceiveStream::Config& config) override; | 63 const VideoReceiveStream::Config& config) override; |
64 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; | 64 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; |
(...skipping 15 matching lines...) Expand all Loading... | |
80 | 80 |
81 private: | 81 private: |
82 void StoreEvent(std::unique_ptr<rtclog::Event>* event); | 82 void StoreEvent(std::unique_ptr<rtclog::Event>* event); |
83 | 83 |
84 // Message queue for passing control messages to the logging thread. | 84 // Message queue for passing control messages to the logging thread. |
85 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; | 85 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
86 | 86 |
87 // Message queue for passing events to the logging thread. | 87 // Message queue for passing events to the logging thread. |
88 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; | 88 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; |
89 | 89 |
90 const Clock* const clock_; | |
91 | |
92 RtcEventLogHelperThread helper_thread_; | 90 RtcEventLogHelperThread helper_thread_; |
93 rtc::ThreadChecker thread_checker_; | 91 rtc::ThreadChecker thread_checker_; |
94 | |
95 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcEventLogImpl); | |
the sun
2016/11/18 15:43:59
Why'd this go?
nisse-webrtc
2016/11/21 07:58:02
Because otherwise it failed to compile... As far a
the sun
2016/11/21 08:35:01
Oh, sorry for being inattentive. You should use RT
nisse-webrtc
2016/11/28 14:26:41
Done.
| |
96 }; | 92 }; |
97 | 93 |
98 namespace { | 94 namespace { |
99 // The functions in this namespace convert enums from the runtime format | 95 // The functions in this namespace convert enums from the runtime format |
100 // that the rest of the WebRtc project can use, to the corresponding | 96 // that the rest of the WebRtc project can use, to the corresponding |
101 // serialized enum which is defined by the protobuf. | 97 // serialized enum which is defined by the protobuf. |
102 | 98 |
103 rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) { | 99 rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) { |
104 switch (rtcp_mode) { | 100 switch (rtcp_mode) { |
105 case RtcpMode::kCompound: | 101 case RtcpMode::kCompound: |
(...skipping 23 matching lines...) Expand all Loading... | |
129 return rtclog::ANY; | 125 return rtclog::ANY; |
130 } | 126 } |
131 | 127 |
132 // The RTP and RTCP buffers reserve space for twice the expected number of | 128 // The RTP and RTCP buffers reserve space for twice the expected number of |
133 // sent packets because they also contain received packets. | 129 // sent packets because they also contain received packets. |
134 static const int kEventsPerSecond = 1000; | 130 static const int kEventsPerSecond = 1000; |
135 static const int kControlMessagesPerSecond = 10; | 131 static const int kControlMessagesPerSecond = 10; |
136 } // namespace | 132 } // namespace |
137 | 133 |
138 // RtcEventLogImpl member functions. | 134 // RtcEventLogImpl member functions. |
139 RtcEventLogImpl::RtcEventLogImpl(const Clock* clock) | 135 RtcEventLogImpl::RtcEventLogImpl() |
140 // Allocate buffers for roughly one second of history. | 136 // Allocate buffers for roughly one second of history. |
141 : message_queue_(kControlMessagesPerSecond), | 137 : message_queue_(kControlMessagesPerSecond), |
142 event_queue_(kEventsPerSecond), | 138 event_queue_(kEventsPerSecond), |
143 clock_(clock), | 139 helper_thread_(&message_queue_, &event_queue_), |
144 helper_thread_(&message_queue_, &event_queue_, clock), | |
145 thread_checker_() { | 140 thread_checker_() { |
146 thread_checker_.DetachFromThread(); | 141 thread_checker_.DetachFromThread(); |
147 } | 142 } |
148 | 143 |
149 RtcEventLogImpl::~RtcEventLogImpl() { | 144 RtcEventLogImpl::~RtcEventLogImpl() { |
150 // The RtcEventLogHelperThread destructor closes the file | 145 // The RtcEventLogHelperThread destructor closes the file |
151 // and waits for the thread to terminate. | 146 // and waits for the thread to terminate. |
152 } | 147 } |
153 | 148 |
154 bool RtcEventLogImpl::StartLogging(const std::string& file_name, | 149 bool RtcEventLogImpl::StartLogging(const std::string& file_name, |
155 int64_t max_size_bytes) { | 150 int64_t max_size_bytes) { |
156 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 151 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
157 RtcEventLogHelperThread::ControlMessage message; | 152 RtcEventLogHelperThread::ControlMessage message; |
158 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 153 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
159 message.max_size_bytes = max_size_bytes <= 0 | 154 message.max_size_bytes = max_size_bytes <= 0 |
160 ? std::numeric_limits<int64_t>::max() | 155 ? std::numeric_limits<int64_t>::max() |
161 : max_size_bytes; | 156 : max_size_bytes; |
162 message.start_time = clock_->TimeInMicroseconds(); | 157 message.start_time = rtc::TimeMicros(); |
163 message.stop_time = std::numeric_limits<int64_t>::max(); | 158 message.stop_time = std::numeric_limits<int64_t>::max(); |
164 message.file.reset(FileWrapper::Create()); | 159 message.file.reset(FileWrapper::Create()); |
165 if (!message.file->OpenFile(file_name.c_str(), false)) { | 160 if (!message.file->OpenFile(file_name.c_str(), false)) { |
166 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 161 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
167 return false; | 162 return false; |
168 } | 163 } |
169 if (!message_queue_.Insert(&message)) { | 164 if (!message_queue_.Insert(&message)) { |
170 LOG(LS_ERROR) << "Message queue full. Can't start logging."; | 165 LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
171 return false; | 166 return false; |
172 } | 167 } |
173 helper_thread_.SignalNewEvent(); | 168 helper_thread_.SignalNewEvent(); |
174 LOG(LS_INFO) << "Starting WebRTC event log."; | 169 LOG(LS_INFO) << "Starting WebRTC event log."; |
175 return true; | 170 return true; |
176 } | 171 } |
177 | 172 |
178 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, | 173 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, |
179 int64_t max_size_bytes) { | 174 int64_t max_size_bytes) { |
180 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 175 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
181 RtcEventLogHelperThread::ControlMessage message; | 176 RtcEventLogHelperThread::ControlMessage message; |
182 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 177 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
183 message.max_size_bytes = max_size_bytes <= 0 | 178 message.max_size_bytes = max_size_bytes <= 0 |
184 ? std::numeric_limits<int64_t>::max() | 179 ? std::numeric_limits<int64_t>::max() |
185 : max_size_bytes; | 180 : max_size_bytes; |
186 message.start_time = clock_->TimeInMicroseconds(); | 181 message.start_time = rtc::TimeMicros(); |
187 message.stop_time = std::numeric_limits<int64_t>::max(); | 182 message.stop_time = std::numeric_limits<int64_t>::max(); |
188 message.file.reset(FileWrapper::Create()); | 183 message.file.reset(FileWrapper::Create()); |
189 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); | 184 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); |
190 if (!file_handle) { | 185 if (!file_handle) { |
191 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 186 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
192 // Even though we failed to open a FILE*, the platform_file is still open | 187 // Even though we failed to open a FILE*, the platform_file is still open |
193 // and needs to be closed. | 188 // and needs to be closed. |
194 if (!rtc::ClosePlatformFile(platform_file)) { | 189 if (!rtc::ClosePlatformFile(platform_file)) { |
195 LOG(LS_ERROR) << "Can't close file."; | 190 LOG(LS_ERROR) << "Can't close file."; |
196 } | 191 } |
197 return false; | 192 return false; |
198 } | 193 } |
199 if (!message.file->OpenFromFileHandle(file_handle)) { | 194 if (!message.file->OpenFromFileHandle(file_handle)) { |
200 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 195 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
201 return false; | 196 return false; |
202 } | 197 } |
203 if (!message_queue_.Insert(&message)) { | 198 if (!message_queue_.Insert(&message)) { |
204 LOG(LS_ERROR) << "Message queue full. Can't start logging."; | 199 LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
205 return false; | 200 return false; |
206 } | 201 } |
207 helper_thread_.SignalNewEvent(); | 202 helper_thread_.SignalNewEvent(); |
208 LOG(LS_INFO) << "Starting WebRTC event log."; | 203 LOG(LS_INFO) << "Starting WebRTC event log."; |
209 return true; | 204 return true; |
210 } | 205 } |
211 | 206 |
212 void RtcEventLogImpl::StopLogging() { | 207 void RtcEventLogImpl::StopLogging() { |
213 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 208 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
214 RtcEventLogHelperThread::ControlMessage message; | 209 RtcEventLogHelperThread::ControlMessage message; |
215 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; | 210 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; |
216 message.stop_time = clock_->TimeInMicroseconds(); | 211 message.stop_time = rtc::TimeMicros(); |
217 while (!message_queue_.Insert(&message)) { | 212 while (!message_queue_.Insert(&message)) { |
218 // TODO(terelius): We would like to have a blocking Insert function in the | 213 // TODO(terelius): We would like to have a blocking Insert function in the |
219 // SwapQueue, but for the time being we will just clear any previous | 214 // SwapQueue, but for the time being we will just clear any previous |
220 // messages. | 215 // messages. |
221 // Since StopLogging waits for the thread, it is essential that we don't | 216 // Since StopLogging waits for the thread, it is essential that we don't |
222 // clear any STOP_FILE messages. To ensure that there is only one call at a | 217 // clear any STOP_FILE messages. To ensure that there is only one call at a |
223 // time, we require that all calls to StopLogging are made on the same | 218 // time, we require that all calls to StopLogging are made on the same |
224 // thread. | 219 // thread. |
225 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging."; | 220 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging."; |
226 message_queue_.Clear(); | 221 message_queue_.Clear(); |
227 } | 222 } |
228 LOG(LS_INFO) << "Stopping WebRTC event log."; | 223 LOG(LS_INFO) << "Stopping WebRTC event log."; |
229 helper_thread_.WaitForFileFinished(); | 224 helper_thread_.WaitForFileFinished(); |
230 } | 225 } |
231 | 226 |
232 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 227 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
233 const VideoReceiveStream::Config& config) { | 228 const VideoReceiveStream::Config& config) { |
234 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 229 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
235 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 230 event->set_timestamp_us(rtc::TimeMicros()); |
236 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); | 231 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); |
237 | 232 |
238 rtclog::VideoReceiveConfig* receiver_config = | 233 rtclog::VideoReceiveConfig* receiver_config = |
239 event->mutable_video_receiver_config(); | 234 event->mutable_video_receiver_config(); |
240 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); | 235 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); |
241 receiver_config->set_local_ssrc(config.rtp.local_ssrc); | 236 receiver_config->set_local_ssrc(config.rtp.local_ssrc); |
242 | 237 |
243 receiver_config->set_rtcp_mode(ConvertRtcpMode(config.rtp.rtcp_mode)); | 238 receiver_config->set_rtcp_mode(ConvertRtcpMode(config.rtp.rtcp_mode)); |
244 receiver_config->set_remb(config.rtp.remb); | 239 receiver_config->set_remb(config.rtp.remb); |
245 | 240 |
(...skipping 15 matching lines...) Expand all Loading... | |
261 rtclog::DecoderConfig* decoder = receiver_config->add_decoders(); | 256 rtclog::DecoderConfig* decoder = receiver_config->add_decoders(); |
262 decoder->set_name(d.payload_name); | 257 decoder->set_name(d.payload_name); |
263 decoder->set_payload_type(d.payload_type); | 258 decoder->set_payload_type(d.payload_type); |
264 } | 259 } |
265 StoreEvent(&event); | 260 StoreEvent(&event); |
266 } | 261 } |
267 | 262 |
268 void RtcEventLogImpl::LogVideoSendStreamConfig( | 263 void RtcEventLogImpl::LogVideoSendStreamConfig( |
269 const VideoSendStream::Config& config) { | 264 const VideoSendStream::Config& config) { |
270 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 265 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
271 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 266 event->set_timestamp_us(rtc::TimeMicros()); |
272 event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); | 267 event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); |
273 | 268 |
274 rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); | 269 rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); |
275 | 270 |
276 for (const auto& ssrc : config.rtp.ssrcs) { | 271 for (const auto& ssrc : config.rtp.ssrcs) { |
277 sender_config->add_ssrcs(ssrc); | 272 sender_config->add_ssrcs(ssrc); |
278 } | 273 } |
279 | 274 |
280 for (const auto& e : config.rtp.extensions) { | 275 for (const auto& e : config.rtp.extensions) { |
281 rtclog::RtpHeaderExtension* extension = | 276 rtclog::RtpHeaderExtension* extension = |
282 sender_config->add_header_extensions(); | 277 sender_config->add_header_extensions(); |
283 extension->set_name(e.uri); | 278 extension->set_name(e.uri); |
284 extension->set_id(e.id); | 279 extension->set_id(e.id); |
285 } | 280 } |
286 | 281 |
287 for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) { | 282 for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) { |
288 sender_config->add_rtx_ssrcs(rtx_ssrc); | 283 sender_config->add_rtx_ssrcs(rtx_ssrc); |
289 } | 284 } |
290 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); | 285 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); |
291 | 286 |
292 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); | 287 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); |
293 encoder->set_name(config.encoder_settings.payload_name); | 288 encoder->set_name(config.encoder_settings.payload_name); |
294 encoder->set_payload_type(config.encoder_settings.payload_type); | 289 encoder->set_payload_type(config.encoder_settings.payload_type); |
295 StoreEvent(&event); | 290 StoreEvent(&event); |
296 } | 291 } |
297 | 292 |
298 void RtcEventLogImpl::LogAudioReceiveStreamConfig( | 293 void RtcEventLogImpl::LogAudioReceiveStreamConfig( |
299 const AudioReceiveStream::Config& config) { | 294 const AudioReceiveStream::Config& config) { |
300 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 295 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
301 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 296 event->set_timestamp_us(rtc::TimeMicros()); |
302 event->set_type(rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT); | 297 event->set_type(rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT); |
303 | 298 |
304 rtclog::AudioReceiveConfig* receiver_config = | 299 rtclog::AudioReceiveConfig* receiver_config = |
305 event->mutable_audio_receiver_config(); | 300 event->mutable_audio_receiver_config(); |
306 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); | 301 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); |
307 receiver_config->set_local_ssrc(config.rtp.local_ssrc); | 302 receiver_config->set_local_ssrc(config.rtp.local_ssrc); |
308 | 303 |
309 for (const auto& e : config.rtp.extensions) { | 304 for (const auto& e : config.rtp.extensions) { |
310 rtclog::RtpHeaderExtension* extension = | 305 rtclog::RtpHeaderExtension* extension = |
311 receiver_config->add_header_extensions(); | 306 receiver_config->add_header_extensions(); |
312 extension->set_name(e.uri); | 307 extension->set_name(e.uri); |
313 extension->set_id(e.id); | 308 extension->set_id(e.id); |
314 } | 309 } |
315 StoreEvent(&event); | 310 StoreEvent(&event); |
316 } | 311 } |
317 | 312 |
318 void RtcEventLogImpl::LogAudioSendStreamConfig( | 313 void RtcEventLogImpl::LogAudioSendStreamConfig( |
319 const AudioSendStream::Config& config) { | 314 const AudioSendStream::Config& config) { |
320 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 315 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
321 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 316 event->set_timestamp_us(rtc::TimeMicros()); |
322 event->set_type(rtclog::Event::AUDIO_SENDER_CONFIG_EVENT); | 317 event->set_type(rtclog::Event::AUDIO_SENDER_CONFIG_EVENT); |
323 | 318 |
324 rtclog::AudioSendConfig* sender_config = event->mutable_audio_sender_config(); | 319 rtclog::AudioSendConfig* sender_config = event->mutable_audio_sender_config(); |
325 | 320 |
326 sender_config->set_ssrc(config.rtp.ssrc); | 321 sender_config->set_ssrc(config.rtp.ssrc); |
327 | 322 |
328 for (const auto& e : config.rtp.extensions) { | 323 for (const auto& e : config.rtp.extensions) { |
329 rtclog::RtpHeaderExtension* extension = | 324 rtclog::RtpHeaderExtension* extension = |
330 sender_config->add_header_extensions(); | 325 sender_config->add_header_extensions(); |
331 extension->set_name(e.uri); | 326 extension->set_name(e.uri); |
(...skipping 17 matching lines...) Expand all Loading... | |
349 | 344 |
350 if (x) { | 345 if (x) { |
351 if (packet_length < 12u + cc * 4u + 4u) { | 346 if (packet_length < 12u + cc * 4u + 4u) { |
352 return; // Don't read outside the packet. | 347 return; // Don't read outside the packet. |
353 } | 348 } |
354 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); | 349 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); |
355 header_length += (x_len + 1) * 4; | 350 header_length += (x_len + 1) * 4; |
356 } | 351 } |
357 | 352 |
358 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); | 353 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); |
359 rtp_event->set_timestamp_us(clock_->TimeInMicroseconds()); | 354 rtp_event->set_timestamp_us(rtc::TimeMicros()); |
360 rtp_event->set_type(rtclog::Event::RTP_EVENT); | 355 rtp_event->set_type(rtclog::Event::RTP_EVENT); |
361 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); | 356 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); |
362 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); | 357 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
363 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); | 358 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); |
364 rtp_event->mutable_rtp_packet()->set_header(header, header_length); | 359 rtp_event->mutable_rtp_packet()->set_header(header, header_length); |
365 StoreEvent(&rtp_event); | 360 StoreEvent(&rtp_event); |
366 } | 361 } |
367 | 362 |
368 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, | 363 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
369 MediaType media_type, | 364 MediaType media_type, |
370 const uint8_t* packet, | 365 const uint8_t* packet, |
371 size_t length) { | 366 size_t length) { |
372 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); | 367 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); |
373 rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds()); | 368 rtcp_event->set_timestamp_us(rtc::TimeMicros()); |
374 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); | 369 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); |
375 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); | 370 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); |
376 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 371 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
377 | 372 |
378 rtcp::CommonHeader header; | 373 rtcp::CommonHeader header; |
379 const uint8_t* block_begin = packet; | 374 const uint8_t* block_begin = packet; |
380 const uint8_t* packet_end = packet + length; | 375 const uint8_t* packet_end = packet + length; |
381 RTC_DCHECK(length <= IP_PACKET_SIZE); | 376 RTC_DCHECK(length <= IP_PACKET_SIZE); |
382 uint8_t buffer[IP_PACKET_SIZE]; | 377 uint8_t buffer[IP_PACKET_SIZE]; |
383 uint32_t buffer_length = 0; | 378 uint32_t buffer_length = 0; |
(...skipping 26 matching lines...) Expand all Loading... | |
410 } | 405 } |
411 | 406 |
412 block_begin += block_size; | 407 block_begin += block_size; |
413 } | 408 } |
414 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); | 409 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); |
415 StoreEvent(&rtcp_event); | 410 StoreEvent(&rtcp_event); |
416 } | 411 } |
417 | 412 |
418 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 413 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
419 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 414 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
420 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 415 event->set_timestamp_us(rtc::TimeMicros()); |
421 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); | 416 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
422 auto playout_event = event->mutable_audio_playout_event(); | 417 auto playout_event = event->mutable_audio_playout_event(); |
423 playout_event->set_local_ssrc(ssrc); | 418 playout_event->set_local_ssrc(ssrc); |
424 StoreEvent(&event); | 419 StoreEvent(&event); |
425 } | 420 } |
426 | 421 |
427 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, | 422 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
428 uint8_t fraction_loss, | 423 uint8_t fraction_loss, |
429 int32_t total_packets) { | 424 int32_t total_packets) { |
430 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 425 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
431 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 426 event->set_timestamp_us(rtc::TimeMicros()); |
432 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); | 427 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); |
433 auto bwe_event = event->mutable_bwe_packet_loss_event(); | 428 auto bwe_event = event->mutable_bwe_packet_loss_event(); |
434 bwe_event->set_bitrate(bitrate); | 429 bwe_event->set_bitrate(bitrate); |
435 bwe_event->set_fraction_loss(fraction_loss); | 430 bwe_event->set_fraction_loss(fraction_loss); |
436 bwe_event->set_total_packets(total_packets); | 431 bwe_event->set_total_packets(total_packets); |
437 StoreEvent(&event); | 432 StoreEvent(&event); |
438 } | 433 } |
439 | 434 |
440 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { | 435 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { |
441 if (!event_queue_.Insert(event)) { | 436 if (!event_queue_.Insert(event)) { |
(...skipping 23 matching lines...) Expand all Loading... | |
465 bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file, | 460 bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file, |
466 int64_t max_size_bytes) { | 461 int64_t max_size_bytes) { |
467 // The platform_file is open and needs to be closed. | 462 // The platform_file is open and needs to be closed. |
468 if (!rtc::ClosePlatformFile(platform_file)) { | 463 if (!rtc::ClosePlatformFile(platform_file)) { |
469 LOG(LS_ERROR) << "Can't close file."; | 464 LOG(LS_ERROR) << "Can't close file."; |
470 } | 465 } |
471 return false; | 466 return false; |
472 } | 467 } |
473 | 468 |
474 // RtcEventLog member functions. | 469 // RtcEventLog member functions. |
475 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { | 470 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { |
476 #ifdef ENABLE_RTC_EVENT_LOG | 471 #ifdef ENABLE_RTC_EVENT_LOG |
477 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); | 472 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); |
478 #else | 473 #else |
479 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 474 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
480 #endif // ENABLE_RTC_EVENT_LOG | 475 #endif // ENABLE_RTC_EVENT_LOG |
481 } | 476 } |
482 | 477 |
483 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { | 478 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { |
484 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 479 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
485 } | 480 } |
486 | 481 |
487 } // namespace webrtc | 482 } // namespace webrtc |
OLD | NEW |