xref: /aosp_15_r20/external/webrtc/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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_AUDIO_NETWORK_ADAPTATION_H_
12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_NETWORK_ADAPTATION_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 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
23 
24 namespace webrtc {
25 
26 struct LoggedAudioNetworkAdaptationEvent {
27   LoggedAudioNetworkAdaptationEvent() = default;
LoggedAudioNetworkAdaptationEventLoggedAudioNetworkAdaptationEvent28   LoggedAudioNetworkAdaptationEvent(Timestamp timestamp,
29                                     const AudioEncoderRuntimeConfig& config)
30       : timestamp(timestamp), config(config) {}
31 
log_time_usLoggedAudioNetworkAdaptationEvent32   int64_t log_time_us() const { return timestamp.us(); }
log_time_msLoggedAudioNetworkAdaptationEvent33   int64_t log_time_ms() const { return timestamp.ms(); }
log_timeLoggedAudioNetworkAdaptationEvent34   Timestamp log_time() const { return timestamp; }
35 
36   Timestamp timestamp = Timestamp::MinusInfinity();
37   AudioEncoderRuntimeConfig config;
38 };
39 
40 struct AudioEncoderRuntimeConfig;
41 
42 class RtcEventAudioNetworkAdaptation final : public RtcEvent {
43  public:
44   static constexpr Type kType = Type::AudioNetworkAdaptation;
45 
46   explicit RtcEventAudioNetworkAdaptation(
47       std::unique_ptr<AudioEncoderRuntimeConfig> config);
48   ~RtcEventAudioNetworkAdaptation() override;
49 
GetType()50   Type GetType() const override { return kType; }
IsConfigEvent()51   bool IsConfigEvent() const override { return false; }
52 
53   std::unique_ptr<RtcEventAudioNetworkAdaptation> Copy() const;
54 
config()55   const AudioEncoderRuntimeConfig& config() const { return *config_; }
56 
Encode(rtc::ArrayView<const RtcEvent * > batch)57   static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) {
58     // TODO(terelius): Implement
59     return "";
60   }
61 
Parse(absl::string_view encoded_bytes,bool batched,std::vector<LoggedAudioNetworkAdaptationEvent> & output)62   static RtcEventLogParseStatus Parse(
63       absl::string_view encoded_bytes,
64       bool batched,
65       std::vector<LoggedAudioNetworkAdaptationEvent>& output) {
66     // TODO(terelius): Implement
67     return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__);
68   }
69 
70  private:
71   RtcEventAudioNetworkAdaptation(const RtcEventAudioNetworkAdaptation& other);
72 
73   const std::unique_ptr<const AudioEncoderRuntimeConfig> config_;
74 };
75 
76 }  // namespace webrtc
77 
78 #endif  // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_AUDIO_NETWORK_ADAPTATION_H_
79