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 | |
| 14 | #include "modules/video_coding/encoded_frame.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | namespace video_coding { |
| 18 | |
philipel | 0fa82a6 | 2018-03-19 15:34:53 +0100 | [diff] [blame^] | 19 | // NOTE: This class is still under development and may change without notice. |
| 20 | struct 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 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 49 | // TODO(philipel): Remove webrtc::VCMEncodedFrame inheritance. |
philipel | 0fa82a6 | 2018-03-19 15:34:53 +0100 | [diff] [blame^] | 50 | // TODO(philipel): Move transport specific info out of EncodedFrame. |
| 51 | // NOTE: This class is still under development and may change without notice. |
philipel | e7c891f | 2018-02-22 14:35:06 +0100 | [diff] [blame] | 52 | class EncodedFrame : public webrtc::VCMEncodedFrame { |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 53 | public: |
| 54 | static const uint8_t kMaxFrameReferences = 5; |
| 55 | |
philipel | e7c891f | 2018-02-22 14:35:06 +0100 | [diff] [blame] | 56 | EncodedFrame() = default; |
| 57 | virtual ~EncodedFrame() {} |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 58 | |
| 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. |
| 73 | virtual bool delayed_by_retransmission() const { return 0; } |
| 74 | |
| 75 | size_t size() const { return _length; } |
| 76 | |
| 77 | bool is_keyframe() const { return num_references == 0; } |
| 78 | |
philipel | 0fa82a6 | 2018-03-19 15:34:53 +0100 | [diff] [blame^] | 79 | VideoLayerFrameId id; |
| 80 | // TODO(philipel): Remove the two references below when downstream projects |
| 81 | // have been updated. |
| 82 | int64_t& picture_id = id.picture_id; |
| 83 | uint8_t& spatial_layer = id.spatial_layer; |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 84 | uint32_t timestamp = 0; |
| 85 | |
| 86 | // TODO(philipel): Add simple modify/access functions to prevent adding too |
| 87 | // many |references|. |
| 88 | size_t num_references = 0; |
| 89 | int64_t references[kMaxFrameReferences]; |
| 90 | bool inter_layer_predicted = false; |
| 91 | }; |
| 92 | |
philipel | d5a272f | 2018-02-21 14:30:34 +0100 | [diff] [blame] | 93 | } // namespace video_coding |
| 94 | } // namespace webrtc |
| 95 | |
| 96 | #endif // API_VIDEO_ENCODED_FRAME_H_ |