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 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
stefan | a669a3a | 2016-10-06 05:04:52 -0700 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 19 | #include "modules/video_coding/codecs/h264/include/h264_globals.h" |
| 20 | #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "modules/video_coding/encoded_frame.h" |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 22 | #include "modules/video_coding/include/video_coding.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "modules/video_coding/jitter_buffer_common.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 24 | #include "modules/video_coding/packet.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "modules/video_coding/session_info.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 27 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 29 | class VCMFrameBuffer : public VCMEncodedFrame { |
| 30 | public: |
| 31 | VCMFrameBuffer(); |
| 32 | virtual ~VCMFrameBuffer(); |
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 | virtual void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 36 | VCMFrameBufferEnum InsertPacket(const VCMPacket& packet, |
| 37 | int64_t timeInMs, |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 38 | const FrameData& frame_data); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 40 | // State |
| 41 | // Get current state of frame |
| 42 | VCMFrameBufferStateEnum GetState() const; |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 43 | void PrepareForDecode(bool continuous); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 45 | bool IsSessionComplete() const; |
| 46 | bool HaveFirstPacket() const; |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 47 | int NumPackets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 49 | // Sequence numbers |
| 50 | // Get lowest packet sequence number in frame |
| 51 | int32_t GetLowSeqNum() const; |
| 52 | // Get highest packet sequence number in frame |
| 53 | int32_t GetHighSeqNum() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 55 | int PictureId() const; |
| 56 | int TemporalId() const; |
| 57 | bool LayerSync() const; |
| 58 | int Tl0PicId() const; |
stefan@webrtc.org | ffd28f9 | 2011-10-19 15:55:39 +0000 | [diff] [blame] | 59 | |
stefan | a669a3a | 2016-10-06 05:04:52 -0700 | [diff] [blame] | 60 | std::vector<NaluInfo> GetNaluInfos() const; |
| 61 | |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 62 | void SetGofInfo(const GofInfoVP9& gof_info, size_t idx); |
| 63 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 64 | // Increments a counter to keep track of the number of packets of this frame |
| 65 | // which were NACKed before they arrived. |
| 66 | void IncrementNackCount(); |
| 67 | // Returns the number of packets of this frame which were NACKed before they |
| 68 | // arrived. |
| 69 | int16_t GetNackCount() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 71 | int64_t LatestPacketTimeMs() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | |
Niels Möller | 87e2d78 | 2019-03-07 10:18:23 +0100 | [diff] [blame] | 73 | webrtc::VideoFrameType FrameType() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | |
agalusza@google.com | d818dcb | 2013-07-29 21:48:11 +0000 | [diff] [blame] | 75 | private: |
| 76 | void SetState(VCMFrameBufferStateEnum state); // Set state of frame |
stefan@webrtc.org | 4cf1a8a | 2013-06-27 15:20:14 +0000 | [diff] [blame] | 77 | |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 78 | VCMFrameBufferStateEnum _state; // Current state of the frame |
Niels Möller | 2449d7a | 2019-09-30 10:18:16 +0200 | [diff] [blame] | 79 | // Set with SetEncodedData, but keep pointer to the concrete class here, to |
| 80 | // enable reallocation and mutation. |
| 81 | rtc::scoped_refptr<EncodedImageBuffer> encoded_image_buffer_; |
asapersson | 9a4cd87 | 2015-10-23 00:27:14 -0700 | [diff] [blame] | 82 | VCMSessionInfo _sessionInfo; |
| 83 | uint16_t _nackCount; |
| 84 | int64_t _latestPacketTimeMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 87 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 89 | #endif // MODULES_VIDEO_CODING_FRAME_BUFFER_H_ |