Markus Handell | 9982efa | 2019-11-21 10:56:50 | [diff] [blame] | 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 | |
Dor Hen | 9fb83a1 | 2024-08-18 14:36:02 | [diff] [blame] | 14 | #include "absl/types/optional.h" |
Markus Handell | 9982efa | 2019-11-21 10:56:50 | [diff] [blame] | 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" |
Markus Handell | 9982efa | 2019-11-21 10:56:50 | [diff] [blame] | 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 |
Jonas Oreland | 0deda15 | 2022-09-23 10:08:57 | [diff] [blame] | 27 | // TODO(bugs.webrtc.org/12114) : remove in favor of Resolution. |
Markus Handell | 9982efa | 2019-11-21 10:56:50 | [diff] [blame] | 28 | struct EncodedResolution { |
Markus Handell | 588f9b3 | 2021-04-08 17:19:50 | [diff] [blame] | 29 | bool empty() const { return width == 0 && height == 0; } |
| 30 | |
| 31 | unsigned width = 0; |
| 32 | unsigned height = 0; |
Markus Handell | 9982efa | 2019-11-21 10:56:50 | [diff] [blame] | 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_ |