blob: 4682b1593cbace89a529669393abff9a824d409d [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
Jonas Olssona4d87372019-07-05 19:08:33 +020017#include "modules/video_coding/encoded_frame.h"
18
philipeld5a272f2018-02-21 14:30:34 +010019namespace webrtc {
20namespace video_coding {
21
philipel0fa82a62018-03-19 15:34:53 +010022// NOTE: This class is still under development and may change without notice.
23struct VideoLayerFrameId {
24 // TODO(philipel): The default ctor is currently used internaly, but have a
25 // look if we can remove it.
philipelf1091932021-02-11 15:25:08 +010026 VideoLayerFrameId() : picture_id(-1) {}
27 explicit VideoLayerFrameId(int64_t picture_id) : picture_id(picture_id) {}
philipel0fa82a62018-03-19 15:34:53 +010028
29 bool operator==(const VideoLayerFrameId& rhs) const {
philipelf1091932021-02-11 15:25:08 +010030 return picture_id == rhs.picture_id;
philipel0fa82a62018-03-19 15:34:53 +010031 }
32
33 bool operator!=(const VideoLayerFrameId& rhs) const {
34 return !(*this == rhs);
35 }
36
37 bool operator<(const VideoLayerFrameId& rhs) const {
philipel0fa82a62018-03-19 15:34:53 +010038 return picture_id < rhs.picture_id;
39 }
40
41 bool operator<=(const VideoLayerFrameId& rhs) const { return !(rhs < *this); }
42 bool operator>(const VideoLayerFrameId& rhs) const { return rhs < *this; }
43 bool operator>=(const VideoLayerFrameId& rhs) const { return rhs <= *this; }
44
45 int64_t picture_id;
philipel0fa82a62018-03-19 15:34:53 +010046};
47
philipeld5a272f2018-02-21 14:30:34 +010048// TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance.
philipel0fa82a62018-03-19 15:34:53 +010049// TODO(philipel): Move transport specific info out of EncodedFrame.
50// NOTE: This class is still under development and may change without notice.
philipele7c891f2018-02-22 14:35:06 +010051class EncodedFrame : public webrtc::VCMEncodedFrame {
philipeld5a272f2018-02-21 14:30:34 +010052 public:
53 static const uint8_t kMaxFrameReferences = 5;
54
philipele7c891f2018-02-22 14:35:06 +010055 EncodedFrame() = default;
philipel6c42d922019-06-20 11:13:03 +020056 EncodedFrame(const EncodedFrame&) = default;
philipele7c891f2018-02-22 14:35:06 +010057 virtual ~EncodedFrame() {}
philipeld5a272f2018-02-21 14:30:34 +010058
philipeld5a272f2018-02-21 14:30:34 +010059 // When this frame was received.
60 virtual int64_t ReceivedTime() const = 0;
61
62 // When this frame should be rendered.
63 virtual int64_t RenderTime() const = 0;
64
65 // This information is currently needed by the timing calculation class.
66 // TODO(philipel): Remove this function when a new timing class has
67 // been implemented.
Niels Möllerbe682d42018-03-27 08:31:45 +020068 virtual bool delayed_by_retransmission() const;
philipeld5a272f2018-02-21 14:30:34 +010069
philipeld5a272f2018-02-21 14:30:34 +010070 bool is_keyframe() const { return num_references == 0; }
71
philipel0fa82a62018-03-19 15:34:53 +010072 VideoLayerFrameId id;
philipeld5a272f2018-02-21 14:30:34 +010073
74 // TODO(philipel): Add simple modify/access functions to prevent adding too
75 // many |references|.
76 size_t num_references = 0;
77 int64_t references[kMaxFrameReferences];
Ilya Nikolaevskiy5546aef2018-12-04 15:54:52 +010078 // Is this subframe the last one in the superframe (In RTP stream that would
79 // mean that the last packet has a marker bit set).
80 bool is_last_spatial_layer = true;
philipeld5a272f2018-02-21 14:30:34 +010081};
82
philipeld5a272f2018-02-21 14:30:34 +010083} // namespace video_coding
84} // namespace webrtc
85
86#endif // API_VIDEO_ENCODED_FRAME_H_