philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 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_ENCODED_FRAME_H_ |
| 12 | #define API_VIDEO_ENCODED_FRAME_H_ |
| 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
| 16 | |
Evan Shrubsole | d6cdf80 | 2022-03-02 15:13:55 +0100 | [diff] [blame] | 17 | #include "absl/types/optional.h" |
| 18 | #include "api/units/timestamp.h" |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 19 | #include "modules/video_coding/encoded_frame.h" |
| 20 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 21 | namespace webrtc { |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 22 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 23 | // TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance. |
philipel | 0fa82a6 | 2018-03-19 15:34:53 +0100 | [diff] [blame] | 24 | // TODO(philipel): Move transport specific info out of EncodedFrame. |
| 25 | // NOTE: This class is still under development and may change without notice. |
philipel | e7c891f | 2018-02-22 14:35:06 +0100 | [diff] [blame] | 26 | class EncodedFrame : public webrtc::VCMEncodedFrame { |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 27 | public: |
| 28 | static const uint8_t kMaxFrameReferences = 5; |
| 29 | |
philipel | e7c891f | 2018-02-22 14:35:06 +0100 | [diff] [blame] | 30 | EncodedFrame() = default; |
philipel | 6c42d92 | 2019-06-20 11:13:03 +0200 | [diff] [blame] | 31 | EncodedFrame(const EncodedFrame&) = default; |
philipel | e7c891f | 2018-02-22 14:35:06 +0100 | [diff] [blame] | 32 | virtual ~EncodedFrame() {} |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 33 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 34 | // When this frame was received. |
Evan Shrubsole | d6cdf80 | 2022-03-02 15:13:55 +0100 | [diff] [blame] | 35 | // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 36 | virtual int64_t ReceivedTime() const = 0; |
Evan Shrubsole | e9126c1 | 2022-03-07 14:50:51 +0100 | [diff] [blame^] | 37 | // Returns a Timestamp from `ReceivedTime`, or nullopt if there is no receive |
| 38 | // time. |
| 39 | absl::optional<webrtc::Timestamp> ReceivedTimestamp() const; |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 40 | |
| 41 | // When this frame should be rendered. |
Evan Shrubsole | d6cdf80 | 2022-03-02 15:13:55 +0100 | [diff] [blame] | 42 | // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 43 | virtual int64_t RenderTime() const = 0; |
Evan Shrubsole | d6cdf80 | 2022-03-02 15:13:55 +0100 | [diff] [blame] | 44 | // Returns a Timestamp from `RenderTime`, or nullopt if there is no |
| 45 | // render time. |
| 46 | absl::optional<webrtc::Timestamp> RenderTimestamp() const; |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 47 | |
| 48 | // This information is currently needed by the timing calculation class. |
| 49 | // TODO(philipel): Remove this function when a new timing class has |
| 50 | // been implemented. |
Niels Möller | be682d4 | 2018-03-27 08:31:45 +0200 | [diff] [blame] | 51 | virtual bool delayed_by_retransmission() const; |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 52 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 53 | bool is_keyframe() const { return num_references == 0; } |
| 54 | |
philipel | d6c81db | 2021-02-16 11:13:25 +0100 | [diff] [blame] | 55 | void SetId(int64_t id) { id_ = id; } |
| 56 | int64_t Id() const { return id_; } |
philipel | 9aa9b8d | 2021-02-15 13:31:29 +0100 | [diff] [blame] | 57 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 58 | // TODO(philipel): Add simple modify/access functions to prevent adding too |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 59 | // many `references`. |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 60 | size_t num_references = 0; |
| 61 | int64_t references[kMaxFrameReferences]; |
Ilya Nikolaevskiy | 5546aef | 2018-12-04 15:54:52 +0100 | [diff] [blame] | 62 | // Is this subframe the last one in the superframe (In RTP stream that would |
| 63 | // mean that the last packet has a marker bit set). |
| 64 | bool is_last_spatial_layer = true; |
philipel | d6c81db | 2021-02-16 11:13:25 +0100 | [diff] [blame] | 65 | |
| 66 | private: |
| 67 | // The ID of the frame is determined from RTP level information. The IDs are |
| 68 | // used to describe order and dependencies between frames. |
| 69 | int64_t id_ = -1; |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 72 | } // namespace webrtc |
| 73 | |
| 74 | #endif // API_VIDEO_ENCODED_FRAME_H_ |