• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FRAME_DECODED_H_
12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_FRAME_DECODED_H_
13 
14 #include <stdint.h>
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 #include "absl/strings/string_view.h"
22 #include "api/rtc_event_log/rtc_event.h"
23 #include "api/units/timestamp.h"
24 #include "api/video/video_codec_type.h"
25 #include "logging/rtc_event_log/events/rtc_event_field_encoding_parser.h"
26 
27 namespace webrtc {
28 
29 struct LoggedFrameDecoded {
log_time_usLoggedFrameDecoded30   int64_t log_time_us() const { return timestamp.us(); }
log_time_msLoggedFrameDecoded31   int64_t log_time_ms() const { return timestamp.ms(); }
log_timeLoggedFrameDecoded32   Timestamp log_time() const { return timestamp; }
33 
34   Timestamp timestamp = Timestamp::MinusInfinity();
35   int64_t render_time_ms;
36   uint32_t ssrc;
37   int width;
38   int height;
39   VideoCodecType codec;
40   uint8_t qp;
41 };
42 
43 class RtcEventFrameDecoded final : public RtcEvent {
44  public:
45   static constexpr Type kType = Type::FrameDecoded;
46 
47   RtcEventFrameDecoded(int64_t render_time_ms,
48                        uint32_t ssrc,
49                        int width,
50                        int height,
51                        VideoCodecType codec,
52                        uint8_t qp);
53   ~RtcEventFrameDecoded() override = default;
54 
GetType()55   Type GetType() const override { return kType; }
IsConfigEvent()56   bool IsConfigEvent() const override { return false; }
57 
58   std::unique_ptr<RtcEventFrameDecoded> Copy() const;
59 
render_time_ms()60   int64_t render_time_ms() const { return render_time_ms_; }
ssrc()61   uint32_t ssrc() const { return ssrc_; }
width()62   int width() const { return width_; }
height()63   int height() const { return height_; }
codec()64   VideoCodecType codec() const { return codec_; }
qp()65   uint8_t qp() const { return qp_; }
66 
Encode(rtc::ArrayView<const RtcEvent * > batch)67   static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) {
68     // TODO(terelius): Implement
69     return "";
70   }
71 
Parse(absl::string_view encoded_bytes,bool batched,std::map<uint32_t,std::vector<LoggedFrameDecoded>> & output)72   static RtcEventLogParseStatus Parse(
73       absl::string_view encoded_bytes,
74       bool batched,
75       std::map<uint32_t, std::vector<LoggedFrameDecoded>>& output) {
76     // TODO(terelius): Implement
77     return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__);
78   }
79 
80  private:
81   RtcEventFrameDecoded(const RtcEventFrameDecoded& other);
82 
83   const int64_t render_time_ms_;
84   const uint32_t ssrc_;
85   const int width_;
86   const int height_;
87   const VideoCodecType codec_;
88   const uint8_t qp_;
89 };
90 
91 }  // namespace webrtc
92 
93 #endif  // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_FRAME_DECODED_H_
94