niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
stefan@webrtc.org | 2979461 | 2012-02-08 08:58:55 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_FRAME_BUFFER_H_ |
| 12 | #define MODULES_VIDEO_CODING_FRAME_BUFFER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
stefan | a669a3a | 2016-10-06 05:04:52 -0700 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/include/module_common_types.h" |
| 17 | #include "modules/video_coding/include/video_coding.h" |
| 18 | #include "modules/video_coding/encoded_frame.h" |
| 19 | #include "modules/video_coding/jitter_buffer_common.h" |
| 20 | #include "modules/video_coding/session_info.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame^] | 21 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 23 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 25 | class VCMFrameBuffer : public VCMEncodedFrame { |
| 26 | public: |
| 27 | VCMFrameBuffer(); |
| 28 | virtual ~VCMFrameBuffer(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 30 | VCMFrameBuffer(const VCMFrameBuffer& rhs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 32 | virtual void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 34 | VCMFrameBufferEnum InsertPacket(const VCMPacket& packet, |
| 35 | int64_t timeInMs, |
agalusza@google.com | a7e360e | 2013-08-01 03:15:08 +0000 | [diff] [blame] | 36 | VCMDecodeErrorMode decode_error_mode, |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 37 | const FrameData& frame_data); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 39 | // State |
| 40 | // Get current state of frame |
| 41 | VCMFrameBufferStateEnum GetState() const; |
| 42 | // Get current state and timestamp of frame |
| 43 | VCMFrameBufferStateEnum GetState(uint32_t& timeStamp) const; |
| 44 | void PrepareForDecode(bool continuous); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 46 | bool IsRetransmitted() const; |
| 47 | bool IsSessionComplete() const; |
| 48 | bool HaveFirstPacket() const; |
| 49 | bool HaveLastPacket() const; |
| 50 | int NumPackets() const; |
| 51 | // Makes sure the session contain a decodable stream. |
| 52 | void MakeSessionDecodable(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 54 | // Sequence numbers |
| 55 | // Get lowest packet sequence number in frame |
| 56 | int32_t GetLowSeqNum() const; |
| 57 | // Get highest packet sequence number in frame |
| 58 | int32_t GetHighSeqNum() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 60 | int PictureId() const; |
| 61 | int TemporalId() const; |
| 62 | bool LayerSync() const; |
| 63 | int Tl0PicId() const; |
| 64 | bool NonReference() const; |
stefan@webrtc.org | ffd28f9 | 2011-10-19 15:55:39 +0000 | [diff] [blame] | 65 | |
stefan | a669a3a | 2016-10-06 05:04:52 -0700 | [diff] [blame] | 66 | std::vector<NaluInfo> GetNaluInfos() const; |
| 67 | |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 68 | void SetGofInfo(const GofInfoVP9& gof_info, size_t idx); |
| 69 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 70 | // Increments a counter to keep track of the number of packets of this frame |
| 71 | // which were NACKed before they arrived. |
| 72 | void IncrementNackCount(); |
| 73 | // Returns the number of packets of this frame which were NACKed before they |
| 74 | // arrived. |
| 75 | int16_t GetNackCount() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 77 | int64_t LatestPacketTimeMs() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 79 | webrtc::FrameType FrameType() const; |
| 80 | void SetPreviousFrameLoss(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 82 | // The number of packets discarded because the decoder can't make use of them. |
mikhal@webrtc.org | 3c5a924 | 2013-09-03 20:45:36 +0000 | [diff] [blame] | 83 | int NotDecodablePackets() const; |
agalusza@google.com | d177c10 | 2013-08-08 01:12:33 +0000 | [diff] [blame] | 84 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 85 | private: |
| 86 | void SetState(VCMFrameBufferStateEnum state); // Set state of frame |
stefan@webrtc.org | 4cf1a8a | 2013-06-27 15:20:14 +0000 | [diff] [blame] | 87 | |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 88 | VCMFrameBufferStateEnum _state; // Current state of the frame |
| 89 | VCMSessionInfo _sessionInfo; |
| 90 | uint16_t _nackCount; |
| 91 | int64_t _latestPacketTimeMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 94 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 96 | #endif // MODULES_VIDEO_CODING_FRAME_BUFFER_H_ |