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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 class RtcEventLogImpl final : public RtcEventLog { | 40 class RtcEventLogImpl final : public RtcEventLog { |
41 public: | 41 public: |
42 void SetBufferDuration(int64_t buffer_duration_us) override {} | 42 void SetBufferDuration(int64_t buffer_duration_us) override {} |
43 void StartLogging(const std::string& file_name, int duration_ms) override {} | 43 void StartLogging(const std::string& file_name, int duration_ms) override {} |
44 bool StartLogging(rtc::PlatformFile log_file) override { return false; } | 44 bool StartLogging(rtc::PlatformFile log_file) override { return false; } |
45 void StopLogging(void) override {} | 45 void StopLogging(void) override {} |
46 void LogVideoReceiveStreamConfig( | 46 void LogVideoReceiveStreamConfig( |
47 const VideoReceiveStream::Config& config) override {} | 47 const VideoReceiveStream::Config& config) override {} |
48 void LogVideoSendStreamConfig( | 48 void LogVideoSendStreamConfig( |
49 const VideoSendStream::Config& config) override {} | 49 const VideoSendStream::Config& config) override {} |
50 void LogRtpHeader(bool incoming, | 50 void LogRtpHeader(PacketDirection direction, |
51 MediaType media_type, | 51 MediaType media_type, |
52 const uint8_t* header, | 52 const uint8_t* header, |
53 size_t packet_length) override {} | 53 size_t packet_length) override {} |
54 void LogRtcpPacket(bool incoming, | 54 void LogRtcpPacket(PacketDirection direction, |
55 MediaType media_type, | 55 MediaType media_type, |
56 const uint8_t* packet, | 56 const uint8_t* packet, |
57 size_t length) override {} | 57 size_t length) override {} |
58 void LogAudioPlayout(uint32_t ssrc) override {} | 58 void LogAudioPlayout(uint32_t ssrc) override {} |
59 void LogBwePacketLossEvent(int32_t bitrate, | 59 void LogBwePacketLossEvent(int32_t bitrate, |
60 uint8_t fraction_loss, | 60 uint8_t fraction_loss, |
61 int32_t total_packets) override {} | 61 int32_t total_packets) override {} |
62 }; | 62 }; |
63 | 63 |
64 #else // ENABLE_RTC_EVENT_LOG is defined | 64 #else // ENABLE_RTC_EVENT_LOG is defined |
65 | 65 |
66 class RtcEventLogImpl final : public RtcEventLog { | 66 class RtcEventLogImpl final : public RtcEventLog { |
67 public: | 67 public: |
68 RtcEventLogImpl(); | 68 RtcEventLogImpl(); |
69 | 69 |
70 void SetBufferDuration(int64_t buffer_duration_us) override; | 70 void SetBufferDuration(int64_t buffer_duration_us) override; |
71 void StartLogging(const std::string& file_name, int duration_ms) override; | 71 void StartLogging(const std::string& file_name, int duration_ms) override; |
72 bool StartLogging(rtc::PlatformFile log_file) override; | 72 bool StartLogging(rtc::PlatformFile log_file) override; |
73 void StopLogging() override; | 73 void StopLogging() override; |
74 void LogVideoReceiveStreamConfig( | 74 void LogVideoReceiveStreamConfig( |
75 const VideoReceiveStream::Config& config) override; | 75 const VideoReceiveStream::Config& config) override; |
76 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; | 76 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; |
77 void LogRtpHeader(bool incoming, | 77 void LogRtpHeader(PacketDirection direction, |
78 MediaType media_type, | 78 MediaType media_type, |
79 const uint8_t* header, | 79 const uint8_t* header, |
80 size_t packet_length) override; | 80 size_t packet_length) override; |
81 void LogRtcpPacket(bool incoming, | 81 void LogRtcpPacket(PacketDirection direction, |
82 MediaType media_type, | 82 MediaType media_type, |
83 const uint8_t* packet, | 83 const uint8_t* packet, |
84 size_t length) override; | 84 size_t length) override; |
85 void LogAudioPlayout(uint32_t ssrc) override; | 85 void LogAudioPlayout(uint32_t ssrc) override; |
86 void LogBwePacketLossEvent(int32_t bitrate, | 86 void LogBwePacketLossEvent(int32_t bitrate, |
87 uint8_t fraction_loss, | 87 uint8_t fraction_loss, |
88 int32_t total_packets) override; | 88 int32_t total_packets) override; |
89 | 89 |
90 private: | 90 private: |
91 // Starts logging. This function assumes the file_ has been opened succesfully | 91 // Starts logging. This function assumes the file_ has been opened succesfully |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 sender_config->add_rtx_ssrcs(rtx_ssrc); | 320 sender_config->add_rtx_ssrcs(rtx_ssrc); |
321 } | 321 } |
322 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); | 322 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); |
323 | 323 |
324 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); | 324 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); |
325 encoder->set_name(config.encoder_settings.payload_name); | 325 encoder->set_name(config.encoder_settings.payload_name); |
326 encoder->set_payload_type(config.encoder_settings.payload_type); | 326 encoder->set_payload_type(config.encoder_settings.payload_type); |
327 HandleEvent(&event); | 327 HandleEvent(&event); |
328 } | 328 } |
329 | 329 |
330 void RtcEventLogImpl::LogRtpHeader(bool incoming, | 330 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
331 MediaType media_type, | 331 MediaType media_type, |
332 const uint8_t* header, | 332 const uint8_t* header, |
333 size_t packet_length) { | 333 size_t packet_length) { |
334 // Read header length (in bytes) from packet data. | 334 // Read header length (in bytes) from packet data. |
335 if (packet_length < 12u) { | 335 if (packet_length < 12u) { |
336 return; // Don't read outside the packet. | 336 return; // Don't read outside the packet. |
337 } | 337 } |
338 const bool x = (header[0] & 0x10) != 0; | 338 const bool x = (header[0] & 0x10) != 0; |
339 const uint8_t cc = header[0] & 0x0f; | 339 const uint8_t cc = header[0] & 0x0f; |
340 size_t header_length = 12u + cc * 4u; | 340 size_t header_length = 12u + cc * 4u; |
341 | 341 |
342 if (x) { | 342 if (x) { |
343 if (packet_length < 12u + cc * 4u + 4u) { | 343 if (packet_length < 12u + cc * 4u + 4u) { |
344 return; // Don't read outside the packet. | 344 return; // Don't read outside the packet. |
345 } | 345 } |
346 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); | 346 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); |
347 header_length += (x_len + 1) * 4; | 347 header_length += (x_len + 1) * 4; |
348 } | 348 } |
349 | 349 |
350 rtc::CritScope lock(&crit_); | 350 rtc::CritScope lock(&crit_); |
351 rtclog::Event rtp_event; | 351 rtclog::Event rtp_event; |
352 rtp_event.set_timestamp_us(clock_->TimeInMicroseconds()); | 352 rtp_event.set_timestamp_us(clock_->TimeInMicroseconds()); |
353 rtp_event.set_type(rtclog::Event::RTP_EVENT); | 353 rtp_event.set_type(rtclog::Event::RTP_EVENT); |
354 rtp_event.mutable_rtp_packet()->set_incoming(incoming); | 354 rtp_event.mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); |
355 rtp_event.mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); | 355 rtp_event.mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
356 rtp_event.mutable_rtp_packet()->set_packet_length(packet_length); | 356 rtp_event.mutable_rtp_packet()->set_packet_length(packet_length); |
357 rtp_event.mutable_rtp_packet()->set_header(header, header_length); | 357 rtp_event.mutable_rtp_packet()->set_header(header, header_length); |
358 HandleEvent(&rtp_event); | 358 HandleEvent(&rtp_event); |
359 } | 359 } |
360 | 360 |
361 void RtcEventLogImpl::LogRtcpPacket(bool incoming, | 361 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
362 MediaType media_type, | 362 MediaType media_type, |
363 const uint8_t* packet, | 363 const uint8_t* packet, |
364 size_t length) { | 364 size_t length) { |
365 rtc::CritScope lock(&crit_); | 365 rtc::CritScope lock(&crit_); |
366 rtclog::Event rtcp_event; | 366 rtclog::Event rtcp_event; |
367 rtcp_event.set_timestamp_us(clock_->TimeInMicroseconds()); | 367 rtcp_event.set_timestamp_us(clock_->TimeInMicroseconds()); |
368 rtcp_event.set_type(rtclog::Event::RTCP_EVENT); | 368 rtcp_event.set_type(rtclog::Event::RTCP_EVENT); |
369 rtcp_event.mutable_rtcp_packet()->set_incoming(incoming); | 369 rtcp_event.mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); |
370 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 370 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
371 | 371 |
372 RTCPUtility::RtcpCommonHeader header; | 372 RTCPUtility::RtcpCommonHeader header; |
373 const uint8_t* block_begin = packet; | 373 const uint8_t* block_begin = packet; |
374 const uint8_t* packet_end = packet + length; | 374 const uint8_t* packet_end = packet + length; |
375 RTC_DCHECK(length <= IP_PACKET_SIZE); | 375 RTC_DCHECK(length <= IP_PACKET_SIZE); |
376 uint8_t buffer[IP_PACKET_SIZE]; | 376 uint8_t buffer[IP_PACKET_SIZE]; |
377 uint32_t buffer_length = 0; | 377 uint32_t buffer_length = 0; |
378 while (block_begin < packet_end) { | 378 while (block_begin < packet_end) { |
379 if (!RtcpParseCommonHeader(block_begin, packet_end - block_begin, | 379 if (!RtcpParseCommonHeader(block_begin, packet_end - block_begin, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 514 } |
515 | 515 |
516 #endif // ENABLE_RTC_EVENT_LOG | 516 #endif // ENABLE_RTC_EVENT_LOG |
517 | 517 |
518 // RtcEventLog member functions. | 518 // RtcEventLog member functions. |
519 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { | 519 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { |
520 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); | 520 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); |
521 } | 521 } |
522 | 522 |
523 } // namespace webrtc | 523 } // namespace webrtc |
OLD | NEW |