blob: 47fb91cd6e1e1f1b6e7ff5a04614aed3f050447a [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
Yves Gerey3e707812018-11-28 16:47:49 +010016#include <stddef.h>
17#include <stdint.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.
26 VideoLayerFrameId() : picture_id(-1), spatial_layer(0) {}
27 VideoLayerFrameId(int64_t picture_id, uint8_t spatial_layer)
28 : picture_id(picture_id), spatial_layer(spatial_layer) {}
29
30 bool operator==(const VideoLayerFrameId& rhs) const {
31 return picture_id == rhs.picture_id && spatial_layer == rhs.spatial_layer;
32 }
33
34 bool operator!=(const VideoLayerFrameId& rhs) const {
35 return !(*this == rhs);
36 }
37
38 bool operator<(const VideoLayerFrameId& rhs) const {
39 if (picture_id == rhs.picture_id)
40 return spatial_layer < rhs.spatial_layer;
41 return picture_id < rhs.picture_id;
42 }
43
44 bool operator<=(const VideoLayerFrameId& rhs) const { return !(rhs < *this); }
45 bool operator>(const VideoLayerFrameId& rhs) const { return rhs < *this; }
46 bool operator>=(const VideoLayerFrameId& rhs) const { return rhs <= *this; }
47
48 int64_t picture_id;
49 uint8_t spatial_layer;
50};
51
philipeld5a272f2018-02-21 14:30:34 +010052// TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance.
philipel0fa82a62018-03-19 15:34:53 +010053// TODO(philipel): Move transport specific info out of EncodedFrame.
54// NOTE: This class is still under development and may change without notice.
philipele7c891f2018-02-22 14:35:06 +010055class EncodedFrame : public webrtc::VCMEncodedFrame {
philipeld5a272f2018-02-21 14:30:34 +010056 public:
57 static const uint8_t kMaxFrameReferences = 5;
58
philipele7c891f2018-02-22 14:35:06 +010059 EncodedFrame() = default;
60 virtual ~EncodedFrame() {}
philipeld5a272f2018-02-21 14:30:34 +010061
Niels Möller648a7ce2018-11-28 15:14:54 +010062 // TODO(nisse): Deprecated and unused. Delete method and default
63 // implementation as soon as downstream overrides are deleted.
64 virtual bool GetBitstream(uint8_t* destination) const;
philipeld5a272f2018-02-21 14:30:34 +010065
philipeld5a272f2018-02-21 14:30:34 +010066 // When this frame was received.
67 virtual int64_t ReceivedTime() const = 0;
68
69 // When this frame should be rendered.
70 virtual int64_t RenderTime() const = 0;
71
72 // This information is currently needed by the timing calculation class.
73 // TODO(philipel): Remove this function when a new timing class has
74 // been implemented.
Niels Möllerbe682d42018-03-27 08:31:45 +020075 virtual bool delayed_by_retransmission() const;
philipeld5a272f2018-02-21 14:30:34 +010076
77 size_t size() const { return _length; }
78
79 bool is_keyframe() const { return num_references == 0; }
80
philipel0fa82a62018-03-19 15:34:53 +010081 VideoLayerFrameId id;
philipeld5a272f2018-02-21 14:30:34 +010082
83 // TODO(philipel): Add simple modify/access functions to prevent adding too
84 // many |references|.
85 size_t num_references = 0;
86 int64_t references[kMaxFrameReferences];
87 bool inter_layer_predicted = false;
88};
89
philipeld5a272f2018-02-21 14:30:34 +010090} // namespace video_coding
91} // namespace webrtc
92
93#endif // API_VIDEO_ENCODED_FRAME_H_