blob: 610c988ebd643b8f4ca452c16764874203302b86 [file] [log] [blame]
philipeld5a272f2018-02-21 14:30:34 +01001/*
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 Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
16
Evan Shrubsoled6cdf802022-03-02 15:13:55 +010017#include "absl/types/optional.h"
18#include "api/units/timestamp.h"
Jonas Olssona4d87372019-07-05 19:08:33 +020019#include "modules/video_coding/encoded_frame.h"
20
philipeld5a272f2018-02-21 14:30:34 +010021namespace webrtc {
philipeld5a272f2018-02-21 14:30:34 +010022
philipeld5a272f2018-02-21 14:30:34 +010023// TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance.
philipel0fa82a62018-03-19 15:34:53 +010024// TODO(philipel): Move transport specific info out of EncodedFrame.
25// NOTE: This class is still under development and may change without notice.
philipele7c891f2018-02-22 14:35:06 +010026class EncodedFrame : public webrtc::VCMEncodedFrame {
philipeld5a272f2018-02-21 14:30:34 +010027 public:
28 static const uint8_t kMaxFrameReferences = 5;
29
philipele7c891f2018-02-22 14:35:06 +010030 EncodedFrame() = default;
philipel6c42d922019-06-20 11:13:03 +020031 EncodedFrame(const EncodedFrame&) = default;
philipele7c891f2018-02-22 14:35:06 +010032 virtual ~EncodedFrame() {}
philipeld5a272f2018-02-21 14:30:34 +010033
philipeld5a272f2018-02-21 14:30:34 +010034 // When this frame was received.
Evan Shrubsoled6cdf802022-03-02 15:13:55 +010035 // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int.
philipeld5a272f2018-02-21 14:30:34 +010036 virtual int64_t ReceivedTime() const = 0;
37
38 // When this frame should be rendered.
Evan Shrubsoled6cdf802022-03-02 15:13:55 +010039 // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int.
philipeld5a272f2018-02-21 14:30:34 +010040 virtual int64_t RenderTime() const = 0;
Evan Shrubsoled6cdf802022-03-02 15:13:55 +010041 // Returns a Timestamp from `RenderTime`, or nullopt if there is no
42 // render time.
43 absl::optional<webrtc::Timestamp> RenderTimestamp() const;
philipeld5a272f2018-02-21 14:30:34 +010044
45 // This information is currently needed by the timing calculation class.
46 // TODO(philipel): Remove this function when a new timing class has
47 // been implemented.
Niels Möllerbe682d42018-03-27 08:31:45 +020048 virtual bool delayed_by_retransmission() const;
philipeld5a272f2018-02-21 14:30:34 +010049
philipeld5a272f2018-02-21 14:30:34 +010050 bool is_keyframe() const { return num_references == 0; }
51
philipeld6c81db2021-02-16 11:13:25 +010052 void SetId(int64_t id) { id_ = id; }
53 int64_t Id() const { return id_; }
philipel9aa9b8d2021-02-15 13:31:29 +010054
philipeld5a272f2018-02-21 14:30:34 +010055 // TODO(philipel): Add simple modify/access functions to prevent adding too
Artem Titov0e61fdd2021-07-25 21:50:14 +020056 // many `references`.
philipeld5a272f2018-02-21 14:30:34 +010057 size_t num_references = 0;
58 int64_t references[kMaxFrameReferences];
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010059 // Is this subframe the last one in the superframe (In RTP stream that would
60 // mean that the last packet has a marker bit set).
61 bool is_last_spatial_layer = true;
philipeld6c81db2021-02-16 11:13:25 +010062
63 private:
64 // The ID of the frame is determined from RTP level information. The IDs are
65 // used to describe order and dependencies between frames.
66 int64_t id_ = -1;
philipeld5a272f2018-02-21 14:30:34 +010067};
68
philipeld5a272f2018-02-21 14:30:34 +010069} // namespace webrtc
70
71#endif // API_VIDEO_ENCODED_FRAME_H_