blob: 72c1197af252d4b72c3fb2af343d334cf89b6105 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
stefan@webrtc.org29794612012-02-08 08:58:55 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_FRAME_BUFFER_H_
12#define MODULES_VIDEO_CODING_FRAME_BUFFER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
stefana669a3a2016-10-06 05:04:52 -070014#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#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 Bonadei71207422017-09-15 13:58:09 +020021#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000022
agalusza@google.comd818dcb2013-07-29 21:48:11 +000023namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000024
agalusza@google.comd818dcb2013-07-29 21:48:11 +000025class VCMFrameBuffer : public VCMEncodedFrame {
26 public:
27 VCMFrameBuffer();
28 virtual ~VCMFrameBuffer();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
agalusza@google.comd818dcb2013-07-29 21:48:11 +000030 VCMFrameBuffer(const VCMFrameBuffer& rhs);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
agalusza@google.comd818dcb2013-07-29 21:48:11 +000032 virtual void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000033
agalusza@google.comd818dcb2013-07-29 21:48:11 +000034 VCMFrameBufferEnum InsertPacket(const VCMPacket& packet,
35 int64_t timeInMs,
agalusza@google.coma7e360e2013-08-01 03:15:08 +000036 VCMDecodeErrorMode decode_error_mode,
agalusza@google.comd818dcb2013-07-29 21:48:11 +000037 const FrameData& frame_data);
niklase@google.com470e71d2011-07-07 08:21:25 +000038
agalusza@google.comd818dcb2013-07-29 21:48:11 +000039 // 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.com470e71d2011-07-07 08:21:25 +000045
agalusza@google.comd818dcb2013-07-29 21:48:11 +000046 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.com470e71d2011-07-07 08:21:25 +000053
agalusza@google.comd818dcb2013-07-29 21:48:11 +000054 // 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.com470e71d2011-07-07 08:21:25 +000059
agalusza@google.comd818dcb2013-07-29 21:48:11 +000060 int PictureId() const;
61 int TemporalId() const;
62 bool LayerSync() const;
63 int Tl0PicId() const;
64 bool NonReference() const;
stefan@webrtc.orgffd28f92011-10-19 15:55:39 +000065
stefana669a3a2016-10-06 05:04:52 -070066 std::vector<NaluInfo> GetNaluInfos() const;
67
asapersson9a4cd872015-10-23 00:27:14 -070068 void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
69
agalusza@google.comd818dcb2013-07-29 21:48:11 +000070 // 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.com470e71d2011-07-07 08:21:25 +000076
agalusza@google.comd818dcb2013-07-29 21:48:11 +000077 int64_t LatestPacketTimeMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000078
agalusza@google.comd818dcb2013-07-29 21:48:11 +000079 webrtc::FrameType FrameType() const;
80 void SetPreviousFrameLoss();
niklase@google.com470e71d2011-07-07 08:21:25 +000081
asapersson9a4cd872015-10-23 00:27:14 -070082 // The number of packets discarded because the decoder can't make use of them.
mikhal@webrtc.org3c5a9242013-09-03 20:45:36 +000083 int NotDecodablePackets() const;
agalusza@google.comd177c102013-08-08 01:12:33 +000084
agalusza@google.comd818dcb2013-07-29 21:48:11 +000085 private:
86 void SetState(VCMFrameBufferStateEnum state); // Set state of frame
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000087
asapersson9a4cd872015-10-23 00:27:14 -070088 VCMFrameBufferStateEnum _state; // Current state of the frame
89 VCMSessionInfo _sessionInfo;
90 uint16_t _nackCount;
91 int64_t _latestPacketTimeMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000092};
93
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000094} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000095
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020096#endif // MODULES_VIDEO_CODING_FRAME_BUFFER_H_