1 /* 2 * Copyright (c) 2019 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_ROUTE_CHANGE_H_ 12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_ROUTE_CHANGE_H_ 13 14 #include <memory> 15 #include <string> 16 #include <vector> 17 18 #include "absl/strings/string_view.h" 19 #include "api/rtc_event_log/rtc_event.h" 20 #include "api/units/timestamp.h" 21 #include "logging/rtc_event_log/events/rtc_event_field_encoding_parser.h" 22 23 namespace webrtc { 24 25 struct LoggedRouteChangeEvent { 26 LoggedRouteChangeEvent() = default; LoggedRouteChangeEventLoggedRouteChangeEvent27 LoggedRouteChangeEvent(Timestamp timestamp, bool connected, uint32_t overhead) 28 : timestamp(timestamp), connected(connected), overhead(overhead) {} 29 log_time_usLoggedRouteChangeEvent30 int64_t log_time_us() const { return timestamp.us(); } log_time_msLoggedRouteChangeEvent31 int64_t log_time_ms() const { return timestamp.ms(); } log_timeLoggedRouteChangeEvent32 Timestamp log_time() const { return timestamp; } 33 34 Timestamp timestamp = Timestamp::MinusInfinity(); 35 bool connected; 36 uint32_t overhead; 37 }; 38 39 class RtcEventRouteChange final : public RtcEvent { 40 public: 41 static constexpr Type kType = Type::RouteChangeEvent; 42 43 RtcEventRouteChange(bool connected, uint32_t overhead); 44 ~RtcEventRouteChange() override; 45 GetType()46 Type GetType() const override { return kType; } IsConfigEvent()47 bool IsConfigEvent() const override { return false; } 48 49 std::unique_ptr<RtcEventRouteChange> Copy() const; 50 connected()51 bool connected() const { return connected_; } overhead()52 uint32_t overhead() const { return overhead_; } 53 Encode(rtc::ArrayView<const RtcEvent * > batch)54 static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) { 55 // TODO(terelius): Implement 56 return ""; 57 } 58 Parse(absl::string_view encoded_bytes,bool batched,std::vector<LoggedRouteChangeEvent> & output)59 static RtcEventLogParseStatus Parse( 60 absl::string_view encoded_bytes, 61 bool batched, 62 std::vector<LoggedRouteChangeEvent>& output) { 63 // TODO(terelius): Implement 64 return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__); 65 } 66 67 private: 68 RtcEventRouteChange(const RtcEventRouteChange& other); 69 70 const bool connected_; 71 const uint32_t overhead_; 72 }; 73 74 } // namespace webrtc 75 #endif // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_ROUTE_CHANGE_H_ 76