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_OUTGOING_H_ 12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_OUTGOING_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 RtpPacketToSend; 32 33 class RtcEventRtpPacketOutgoing final : public RtcEvent { 34 public: 35 static constexpr Type kType = Type::RtpPacketOutgoing; 36 37 RtcEventRtpPacketOutgoing(const RtpPacketToSend& packet, 38 int probe_cluster_id); 39 ~RtcEventRtpPacketOutgoing() override; 40 GetType()41 Type GetType() const override { return kType; } IsConfigEvent()42 bool IsConfigEvent() const override { return false; } 43 44 std::unique_ptr<RtcEventRtpPacketOutgoing> Copy() const; 45 packet_length()46 size_t packet_length() const { return packet_.size(); } 47 RawHeader()48 rtc::ArrayView<const uint8_t> RawHeader() const { 49 return rtc::MakeArrayView(packet_.data(), header_length()); 50 } Ssrc()51 uint32_t Ssrc() const { return packet_.Ssrc(); } Timestamp()52 uint32_t Timestamp() const { return packet_.Timestamp(); } SequenceNumber()53 uint16_t SequenceNumber() const { return packet_.SequenceNumber(); } PayloadType()54 uint8_t PayloadType() const { return packet_.PayloadType(); } Marker()55 bool Marker() const { return packet_.Marker(); } 56 template <typename ExtensionTrait, typename... Args> GetExtension(Args &&...args)57 bool GetExtension(Args&&... args) const { 58 return packet_.GetExtension<ExtensionTrait>(std::forward<Args>(args)...); 59 } 60 template <typename ExtensionTrait> HasExtension()61 bool HasExtension() const { 62 return packet_.HasExtension<ExtensionTrait>(); 63 } 64 payload_length()65 size_t payload_length() const { return packet_.payload_size(); } header_length()66 size_t header_length() const { return packet_.headers_size(); } padding_length()67 size_t padding_length() const { return packet_.padding_size(); } probe_cluster_id()68 int probe_cluster_id() const { return probe_cluster_id_; } 69 Encode(rtc::ArrayView<const RtcEvent * > batch)70 static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) { 71 // TODO(terelius): Implement 72 return ""; 73 } 74 Parse(absl::string_view encoded_bytes,bool batched,std::map<uint32_t,std::vector<LoggedRtpPacketOutgoing>> & output)75 static RtcEventLogParseStatus Parse( 76 absl::string_view encoded_bytes, 77 bool batched, 78 std::map<uint32_t, std::vector<LoggedRtpPacketOutgoing>>& output) { 79 // TODO(terelius): Implement 80 return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__); 81 } 82 83 private: 84 RtcEventRtpPacketOutgoing(const RtcEventRtpPacketOutgoing& other); 85 86 const RtpPacket packet_; 87 // TODO(eladalon): Delete `probe_cluster_id_` along with legacy encoding. 88 const int probe_cluster_id_; 89 }; 90 91 } // namespace webrtc 92 93 #endif // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_RTP_PACKET_OUTGOING_H_ 94