| 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 <stddef.h> |
| 15 | #include <stdint.h> |
| 16 |
| 17 | #include "absl/types/optional.h" |
| 18 | #include "api/units/timestamp.h" |
| 19 | #include "api/video/encoded_image.h" |
| 20 | #include "api/video/video_codec_type.h" |
| 21 | #include "modules/rtp_rtcp/source/rtp_video_header.h" |
| 22 | #include "modules/video_coding/include/video_codec_interface.h" |
| 23 | #include "modules/video_coding/include/video_coding_defines.h" |
| 24 |
| 25 | namespace webrtc { |
| 26 |
| 27 | // TODO(philipel): Move transport specific info out of EncodedFrame. |
| 28 | // NOTE: This class is still under development and may change without notice. |
| 29 | class EncodedFrame : public EncodedImage { |
| 30 | public: |
| 31 | static const uint8_t kMaxFrameReferences = 5; |
| 32 |
| 33 | EncodedFrame() = default; |
| 34 | EncodedFrame(const EncodedFrame&) = default; |
| 35 | virtual ~EncodedFrame() {} |
| 36 |
| 37 | // When this frame was received. |
| 38 | // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. |
| 39 | virtual int64_t ReceivedTime() const { return -1; } |
| 40 | // Returns a Timestamp from `ReceivedTime`, or nullopt if there is no receive |
| 41 | // time. |
| 42 | absl::optional<webrtc::Timestamp> ReceivedTimestamp() const; |
| 43 |
| 44 | // When this frame should be rendered. |
| 45 | // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. |
| 46 | virtual int64_t RenderTime() const { return _renderTimeMs; } |
| 47 | // TODO(bugs.webrtc.org/13756): Migrate to ReceivedTimestamp. |
| 48 | int64_t RenderTimeMs() const { return _renderTimeMs; } |
| 49 | // Returns a Timestamp from `RenderTime`, or nullopt if there is no |
| 50 | // render time. |
| 51 | absl::optional<webrtc::Timestamp> RenderTimestamp() const; |
| 52 |
| 53 | // This information is currently needed by the timing calculation class. |
| 54 | // TODO(philipel): Remove this function when a new timing class has |
| 55 | // been implemented. |
| 56 | virtual bool delayed_by_retransmission() const; |
| 57 |
| 58 | bool is_keyframe() const { return num_references == 0; } |
| 59 |
| 60 | void SetId(int64_t id) { id_ = id; } |
| 61 | int64_t Id() const { return id_; } |
| 62 |
| 63 | uint8_t PayloadType() const { return _payloadType; } |
| 64 |
| 65 | void SetRenderTime(const int64_t renderTimeMs) { |
| 66 | _renderTimeMs = renderTimeMs; |
| 67 | } |
| 68 |
| 69 | const webrtc::EncodedImage& EncodedImage() const { |
| 70 | return static_cast<const webrtc::EncodedImage&>(*this); |
| 71 | } |
| 72 |
| 73 | const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; } |
| 74 | void SetCodecSpecific(const CodecSpecificInfo* codec_specific) { |
| 75 | _codecSpecificInfo = *codec_specific; |
| 76 | } |
| 77 |
| 78 | // TODO(philipel): Add simple modify/access functions to prevent adding too |
| 79 | // many `references`. |
| 80 | size_t num_references = 0; |
| 81 | int64_t references[kMaxFrameReferences]; |
| 82 | // Is this subframe the last one in the superframe (In RTP stream that would |
| 83 | // mean that the last packet has a marker bit set). |
| 84 | bool is_last_spatial_layer = true; |
| 85 |
| 86 | protected: |
| 87 | // TODO(https://bugs.webrtc.org/9378): Move RTP specifics down into a |
| 88 | // transport-aware subclass, eg RtpFrameObject. |
| 89 | void CopyCodecSpecific(const RTPVideoHeader* header); |
| 90 |
| 91 | // TODO(https://bugs.webrtc.org/9378): Make fields private with |
| 92 | // getters/setters as needed. |
| 93 | int64_t _renderTimeMs = -1; |
| 94 | uint8_t _payloadType = 0; |
| 95 | CodecSpecificInfo _codecSpecificInfo; |
| 96 | VideoCodecType _codec = kVideoCodecGeneric; |
| 97 |
| 98 | private: |
| 99 | // The ID of the frame is determined from RTP level information. The IDs are |
| 100 | // used to describe order and dependencies between frames. |
| 101 | int64_t id_ = -1; |
| 102 | }; |
| 103 |
| 104 | } // namespace webrtc |
| 105 |
| 106 | #endif // API_VIDEO_ENCODED_FRAME_H_ |
| 107 |