blob: 1e919d0077b1a335acdc2477607877bf0fccff20 [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
14#include "modules/video_coding/encoded_frame.h"
15
16namespace webrtc {
17namespace video_coding {
18
philipel0fa82a62018-03-19 15:34:53 +010019// NOTE: This class is still under development and may change without notice.
20struct VideoLayerFrameId {
21 // TODO(philipel): The default ctor is currently used internaly, but have a
22 // look if we can remove it.
23 VideoLayerFrameId() : picture_id(-1), spatial_layer(0) {}
24 VideoLayerFrameId(int64_t picture_id, uint8_t spatial_layer)
25 : picture_id(picture_id), spatial_layer(spatial_layer) {}
26
27 bool operator==(const VideoLayerFrameId& rhs) const {
28 return picture_id == rhs.picture_id && spatial_layer == rhs.spatial_layer;
29 }
30
31 bool operator!=(const VideoLayerFrameId& rhs) const {
32 return !(*this == rhs);
33 }
34
35 bool operator<(const VideoLayerFrameId& rhs) const {
36 if (picture_id == rhs.picture_id)
37 return spatial_layer < rhs.spatial_layer;
38 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;
46 uint8_t spatial_layer;
47};
48
philipeld5a272f2018-02-21 14:30:34 +010049// TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance.
philipel0fa82a62018-03-19 15:34:53 +010050// TODO(philipel): Move transport specific info out of EncodedFrame.
51// NOTE: This class is still under development and may change without notice.
philipele7c891f2018-02-22 14:35:06 +010052class EncodedFrame : public webrtc::VCMEncodedFrame {
philipeld5a272f2018-02-21 14:30:34 +010053 public:
54 static const uint8_t kMaxFrameReferences = 5;
55
philipele7c891f2018-02-22 14:35:06 +010056 EncodedFrame() = default;
57 virtual ~EncodedFrame() {}
philipeld5a272f2018-02-21 14:30:34 +010058
59 virtual bool GetBitstream(uint8_t* destination) const = 0;
60
61 // The capture timestamp of this frame.
62 virtual uint32_t Timestamp() const = 0;
63
64 // When this frame was received.
65 virtual int64_t ReceivedTime() const = 0;
66
67 // When this frame should be rendered.
68 virtual int64_t RenderTime() const = 0;
69
70 // This information is currently needed by the timing calculation class.
71 // TODO(philipel): Remove this function when a new timing class has
72 // been implemented.
Niels Möllerbe682d42018-03-27 08:31:45 +020073 virtual bool delayed_by_retransmission() const;
philipeld5a272f2018-02-21 14:30:34 +010074
75 size_t size() const { return _length; }
76
77 bool is_keyframe() const { return num_references == 0; }
78
philipel0fa82a62018-03-19 15:34:53 +010079 VideoLayerFrameId id;
philipeld5a272f2018-02-21 14:30:34 +010080 uint32_t timestamp = 0;
81
82 // TODO(philipel): Add simple modify/access functions to prevent adding too
83 // many |references|.
84 size_t num_references = 0;
85 int64_t references[kMaxFrameReferences];
86 bool inter_layer_predicted = false;
87};
88
philipeld5a272f2018-02-21 14:30:34 +010089} // namespace video_coding
90} // namespace webrtc
91
92#endif // API_VIDEO_ENCODED_FRAME_H_