1 /* 2 * Copyright (c) 2017 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 LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_INCOMING_H_ 12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_INCOMING_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <map> 17 #include <memory> 18 #include <string> 19 #include <utility> 20 #include <vector> 21 22 #include "absl/strings/string_view.h" 23 #include "api/array_view.h" 24 #include "api/rtc_event_log/rtc_event.h" 25 #include "logging/rtc_event_log/events/logged_rtp_rtcp.h" 26 #include "logging/rtc_event_log/events/rtc_event_field_encoding_parser.h" 27 #include "modules/rtp_rtcp/source/rtp_packet.h" 28 29 namespace webrtc { 30 31 class RtpPacketReceived; 32 33 class RtcEventRtpPacketIncoming final : public RtcEvent { 34 public: 35 static constexpr Type kType = Type::RtpPacketIncoming; 36 37 explicit RtcEventRtpPacketIncoming(const RtpPacketReceived& packet); 38 ~RtcEventRtpPacketIncoming() override; 39 GetType()40 Type GetType() const override { return kType; } IsConfigEvent()41 bool IsConfigEvent() const override { return false; } 42 43 std::unique_ptr<RtcEventRtpPacketIncoming> Copy() const; 44 packet_length()45 size_t packet_length() const { return packet_.size(); } 46 RawHeader()47 rtc::ArrayView<const uint8_t> RawHeader() const { 48 return rtc::MakeArrayView(packet_.data(), header_length()); 49 } Ssrc()50 uint32_t Ssrc() const { return packet_.Ssrc(); } Timestamp()51 uint32_t Timestamp() const { return packet_.Timestamp(); } SequenceNumber()52 uint16_t SequenceNumber() const { return packet_.SequenceNumber(); } PayloadType()53 uint8_t PayloadType() const { return packet_.PayloadType(); } Marker()54 bool Marker() const { return packet_.Marker(); } 55 template <typename ExtensionTrait, typename... Args> GetExtension(Args &&...args)56 bool GetExtension(Args&&... args) const { 57 return packet_.GetExtension<ExtensionTrait>(std::forward<Args>(args)...); 58 } 59 template <typename ExtensionTrait> HasExtension()60 bool HasExtension() const { 61 return packet_.HasExtension<ExtensionTrait>(); 62 } 63 payload_length()64 size_t payload_length() const { return packet_.payload_size(); } header_length()65 size_t header_length() const { return packet_.headers_size(); } padding_length()66 size_t padding_length() const { return packet_.padding_size(); } 67 Encode(rtc::ArrayView<const RtcEvent * > batch)68 static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) { 69 // TODO(terelius): Implement 70 return ""; 71 } 72 Parse(absl::string_view encoded_bytes,bool batched,std::map<uint32_t,std::vector<LoggedRtpPacketIncoming>> & output)73 static RtcEventLogParseStatus Parse( 74 absl::string_view encoded_bytes, 75 bool batched, 76 std::map<uint32_t, std::vector<LoggedRtpPacketIncoming>>& output) { 77 // TODO(terelius): Implement 78 return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__); 79 } 80 81 private: 82 RtcEventRtpPacketIncoming(const RtcEventRtpPacketIncoming& other); 83 84 const RtpPacket packet_; 85 }; 86 87 } // namespace webrtc 88 89 #endif // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_INCOMING_H_ 90