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

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

Issue 2395383002: Replace rtcp parser in rtc event log handlers. (Closed)
Patch Set: 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 | « no previous file | webrtc/tools/event_log_visualizer/analyzer.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
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/call.h" 21 #include "webrtc/call.h"
22 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" 22 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 25 #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/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_reports.h"
30 #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/rtpfb.h"
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h"
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
26 #include "webrtc/system_wrappers/include/clock.h" 35 #include "webrtc/system_wrappers/include/clock.h"
27 #include "webrtc/system_wrappers/include/file_wrapper.h" 36 #include "webrtc/system_wrappers/include/file_wrapper.h"
28 #include "webrtc/system_wrappers/include/logging.h" 37 #include "webrtc/system_wrappers/include/logging.h"
29 38
30 #ifdef ENABLE_RTC_EVENT_LOG 39 #ifdef ENABLE_RTC_EVENT_LOG
31 // Files generated at build-time by the protobuf compiler. 40 // Files generated at build-time by the protobuf compiler.
32 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 41 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
33 #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"
34 #else 43 #else
35 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" 44 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, 325 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction,
317 MediaType media_type, 326 MediaType media_type,
318 const uint8_t* packet, 327 const uint8_t* packet,
319 size_t length) { 328 size_t length) {
320 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); 329 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event());
321 rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds()); 330 rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds());
322 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); 331 rtcp_event->set_type(rtclog::Event::RTCP_EVENT);
323 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); 332 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket);
324 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); 333 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type));
325 334
326 RTCPUtility::RtcpCommonHeader header; 335 rtcp::CommonHeader header;
327 const uint8_t* block_begin = packet; 336 const uint8_t* block_begin = packet;
328 const uint8_t* packet_end = packet + length; 337 const uint8_t* packet_end = packet + length;
329 RTC_DCHECK(length <= IP_PACKET_SIZE); 338 RTC_DCHECK(length <= IP_PACKET_SIZE);
330 uint8_t buffer[IP_PACKET_SIZE]; 339 uint8_t buffer[IP_PACKET_SIZE];
331 uint32_t buffer_length = 0; 340 uint32_t buffer_length = 0;
332 while (block_begin < packet_end) { 341 while (block_begin < packet_end) {
333 if (!RtcpParseCommonHeader(block_begin, packet_end - block_begin, 342 if (!header.Parse(block_begin, packet_end - block_begin)) {
334 &header)) {
335 break; // Incorrect message header. 343 break; // Incorrect message header.
336 } 344 }
337 uint32_t block_size = header.BlockSize(); 345 const uint8_t* next_block = header.NextPacket();
338 switch (header.packet_type) { 346 uint32_t block_size = next_block - block_begin;
339 case RTCPUtility::PT_SR: 347 switch (header.type()) {
340 FALLTHROUGH(); 348 case rtcp::SenderReport::kPacketType:
341 case RTCPUtility::PT_RR: 349 case rtcp::ReceiverReport::kPacketType:
342 FALLTHROUGH(); 350 case rtcp::Bye::kPacketType:
343 case RTCPUtility::PT_BYE: 351 case rtcp::ExtendedJitterReport::kPacketType:
344 FALLTHROUGH(); 352 case rtcp::Rtpfb::kPacketType:
345 case RTCPUtility::PT_IJ: 353 case rtcp::Psfb::kPacketType:
346 FALLTHROUGH(); 354 case rtcp::ExtendedReports::kPacketType:
terelius 2016/10/07 12:39:25 There is no need for annotating the fall-through?
danilchap 2016/10/07 12:45:18 shouldn't be needed when the block is empty. FALLT
347 case RTCPUtility::PT_RTPFB:
348 FALLTHROUGH();
349 case RTCPUtility::PT_PSFB:
350 FALLTHROUGH();
351 case RTCPUtility::PT_XR:
352 // We log sender reports, receiver reports, bye messages 355 // We log sender reports, receiver reports, bye messages
353 // inter-arrival jitter, third-party loss reports, payload-specific 356 // inter-arrival jitter, third-party loss reports, payload-specific
354 // feedback and extended reports. 357 // feedback and extended reports.
355 memcpy(buffer + buffer_length, block_begin, block_size); 358 memcpy(buffer + buffer_length, block_begin, block_size);
356 buffer_length += block_size; 359 buffer_length += block_size;
357 break; 360 break;
358 case RTCPUtility::PT_SDES: 361 case rtcp::Sdes::kPacketType:
359 FALLTHROUGH(); 362 case rtcp::App::kPacketType:
360 case RTCPUtility::PT_APP:
361 FALLTHROUGH();
362 default: 363 default:
363 // We don't log sender descriptions, application defined messages 364 // We don't log sender descriptions, application defined messages
364 // or message blocks of unknown type. 365 // or message blocks of unknown type.
365 break; 366 break;
366 } 367 }
367 368
368 block_begin += block_size; 369 block_begin += block_size;
369 } 370 }
370 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); 371 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length);
371 StoreEvent(&rtcp_event); 372 StoreEvent(&rtcp_event);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 #else 435 #else
435 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 436 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
436 #endif // ENABLE_RTC_EVENT_LOG 437 #endif // ENABLE_RTC_EVENT_LOG
437 } 438 }
438 439
439 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { 440 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
440 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 441 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
441 } 442 }
442 443
443 } // namespace webrtc 444 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/tools/event_log_visualizer/analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698