philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [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 WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_ |
| 13 | |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 14 | #include "webrtc/common_types.h" |
| 15 | #include "webrtc/modules/include/module_common_types.h" |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 16 | #include "webrtc/modules/video_coding/encoded_frame.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 17 | #include "webrtc/rtc_base/optional.h" |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | namespace video_coding { |
| 21 | |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 22 | class FrameObject : public webrtc::VCMEncodedFrame { |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 23 | public: |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 24 | static const uint8_t kMaxFrameReferences = 5; |
| 25 | |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 26 | FrameObject(); |
philipel | b4d3108 | 2016-07-11 08:46:29 -0700 | [diff] [blame] | 27 | virtual ~FrameObject() {} |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 28 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 29 | virtual bool GetBitstream(uint8_t* destination) const = 0; |
philipel | b4d3108 | 2016-07-11 08:46:29 -0700 | [diff] [blame] | 30 | |
| 31 | // The capture timestamp of this frame. |
| 32 | virtual uint32_t Timestamp() const = 0; |
| 33 | |
| 34 | // When this frame was received. |
| 35 | virtual int64_t ReceivedTime() const = 0; |
| 36 | |
| 37 | // When this frame should be rendered. |
| 38 | virtual int64_t RenderTime() const = 0; |
| 39 | |
philipel | e075430 | 2017-01-25 08:56:23 -0800 | [diff] [blame] | 40 | // This information is currently needed by the timing calculation class. |
| 41 | // TODO(philipel): Remove this function when a new timing class has |
| 42 | // been implemented. |
| 43 | virtual bool delayed_by_retransmission() const { return 0; } |
| 44 | |
philipel | c18f1d7 | 2017-08-02 04:18:02 -0700 | [diff] [blame] | 45 | size_t size() { return _length; } |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 46 | |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 47 | // The tuple (|picture_id|, |spatial_layer|) uniquely identifies a frame |
| 48 | // object. For codec types that don't necessarily have picture ids they |
| 49 | // have to be constructed from the header data relevant to that codec. |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 50 | uint16_t picture_id; |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 51 | uint8_t spatial_layer; |
philipel | be7a9e5 | 2016-05-19 12:19:35 +0200 | [diff] [blame] | 52 | uint32_t timestamp; |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 53 | |
philipel | 112adf9 | 2017-06-15 09:06:21 -0700 | [diff] [blame] | 54 | // TODO(philipel): Add simple modify/access functions to prevent adding too |
| 55 | // many |references|. |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 56 | size_t num_references; |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 57 | uint16_t references[kMaxFrameReferences]; |
philipel | a105987 | 2016-05-09 11:41:48 +0200 | [diff] [blame] | 58 | bool inter_layer_predicted; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | class PacketBuffer; |
| 62 | |
| 63 | class RtpFrameObject : public FrameObject { |
| 64 | public: |
| 65 | RtpFrameObject(PacketBuffer* packet_buffer, |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 66 | uint16_t first_seq_num, |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 67 | uint16_t last_seq_num, |
| 68 | size_t frame_size, |
philipel | b4d3108 | 2016-07-11 08:46:29 -0700 | [diff] [blame] | 69 | int times_nacked, |
| 70 | int64_t received_time); |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 71 | |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 72 | ~RtpFrameObject(); |
philipel | f413933 | 2016-04-20 10:26:34 +0200 | [diff] [blame] | 73 | uint16_t first_seq_num() const; |
| 74 | uint16_t last_seq_num() const; |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 75 | int times_nacked() const; |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 76 | enum FrameType frame_type() const; |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 77 | VideoCodecType codec_type() const; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 78 | bool GetBitstream(uint8_t* destination) const override; |
philipel | b4d3108 | 2016-07-11 08:46:29 -0700 | [diff] [blame] | 79 | uint32_t Timestamp() const override; |
| 80 | int64_t ReceivedTime() const override; |
| 81 | int64_t RenderTime() const override; |
philipel | e075430 | 2017-01-25 08:56:23 -0800 | [diff] [blame] | 82 | bool delayed_by_retransmission() const override; |
philipel | 8848828 | 2016-11-03 08:56:54 -0700 | [diff] [blame] | 83 | rtc::Optional<RTPVideoTypeHeader> GetCodecHeader() const; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 84 | |
| 85 | private: |
philipel | 17deeb4 | 2016-08-11 15:09:26 +0200 | [diff] [blame] | 86 | rtc::scoped_refptr<PacketBuffer> packet_buffer_; |
philipel | 552866c | 2016-07-04 16:18:55 +0200 | [diff] [blame] | 87 | enum FrameType frame_type_; |
philipel | 02447bc | 2016-05-13 06:01:03 -0700 | [diff] [blame] | 88 | VideoCodecType codec_type_; |
| 89 | uint16_t first_seq_num_; |
| 90 | uint16_t last_seq_num_; |
philipel | b4d3108 | 2016-07-11 08:46:29 -0700 | [diff] [blame] | 91 | uint32_t timestamp_; |
| 92 | int64_t received_time_; |
philipel | 5ceaaae | 2016-05-24 10:20:47 +0200 | [diff] [blame] | 93 | |
| 94 | // Equal to times nacked of the packet with the highet times nacked |
| 95 | // belonging to this frame. |
| 96 | int times_nacked_; |
philipel | c707ab7 | 2016-04-01 02:01:54 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace video_coding |
| 100 | } // namespace webrtc |
| 101 | |
| 102 | #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_OBJECT_H_ |