xref: /aosp_15_r20/external/webrtc/api/video/recordable_encoded_frame.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 API_VIDEO_RECORDABLE_ENCODED_FRAME_H_
12 #define API_VIDEO_RECORDABLE_ENCODED_FRAME_H_
13 
14 #include "api/array_view.h"
15 #include "api/scoped_refptr.h"
16 #include "api/units/timestamp.h"
17 #include "api/video/color_space.h"
18 #include "api/video/encoded_image.h"
19 #include "api/video/video_codec_type.h"
20 
21 namespace webrtc {
22 
23 // Interface for accessing recordable elements of an encoded frame.
24 class RecordableEncodedFrame {
25  public:
26   // Encoded resolution in pixels
27   // TODO(bugs.webrtc.org/12114) : remove in favor of Resolution.
28   struct EncodedResolution {
emptyEncodedResolution29     bool empty() const { return width == 0 && height == 0; }
30 
31     unsigned width = 0;
32     unsigned height = 0;
33   };
34 
35   virtual ~RecordableEncodedFrame() = default;
36 
37   // Provides access to encoded data
38   virtual rtc::scoped_refptr<const EncodedImageBufferInterface> encoded_buffer()
39       const = 0;
40 
41   // Optionally returns the colorspace of the encoded frame. This can differ
42   // from the eventually decoded frame's colorspace.
43   virtual absl::optional<webrtc::ColorSpace> color_space() const = 0;
44 
45   // Returns the codec of the encoded frame
46   virtual VideoCodecType codec() const = 0;
47 
48   // Returns whether the encoded frame is a key frame
49   virtual bool is_key_frame() const = 0;
50 
51   // Returns the frame's encoded resolution. May be 0x0 if the frame
52   // doesn't contain resolution information
53   virtual EncodedResolution resolution() const = 0;
54 
55   // Returns the computed render time
56   virtual Timestamp render_time() const = 0;
57 };
58 
59 }  // namespace webrtc
60 
61 #endif  // API_VIDEO_RECORDABLE_ENCODED_FRAME_H_
62