blob: f5a707efe4d275d581d7cb6e3ee81896f75acaff [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
Henrik Kjellander2557b862015-11-18 22:00:21 +010011#ifndef WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_
12#define WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010014#include "webrtc/modules/include/module_common_types.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010015#include "webrtc/modules/video_coding/include/video_coding.h"
16#include "webrtc/modules/video_coding/encoded_frame.h"
17#include "webrtc/modules/video_coding/jitter_buffer_common.h"
18#include "webrtc/modules/video_coding/session_info.h"
pbos@webrtc.orga4407322013-07-16 12:32:05 +000019#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
agalusza@google.comd818dcb2013-07-29 21:48:11 +000021namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
agalusza@google.comd818dcb2013-07-29 21:48:11 +000023class VCMFrameBuffer : public VCMEncodedFrame {
24 public:
25 VCMFrameBuffer();
26 virtual ~VCMFrameBuffer();
niklase@google.com470e71d2011-07-07 08:21:25 +000027
agalusza@google.comd818dcb2013-07-29 21:48:11 +000028 VCMFrameBuffer(const VCMFrameBuffer& rhs);
niklase@google.com470e71d2011-07-07 08:21:25 +000029
agalusza@google.comd818dcb2013-07-29 21:48:11 +000030 virtual void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000031
agalusza@google.comd818dcb2013-07-29 21:48:11 +000032 VCMFrameBufferEnum InsertPacket(const VCMPacket& packet,
33 int64_t timeInMs,
agalusza@google.coma7e360e2013-08-01 03:15:08 +000034 VCMDecodeErrorMode decode_error_mode,
agalusza@google.comd818dcb2013-07-29 21:48:11 +000035 const FrameData& frame_data);
niklase@google.com470e71d2011-07-07 08:21:25 +000036
agalusza@google.comd818dcb2013-07-29 21:48:11 +000037 // State
38 // Get current state of frame
39 VCMFrameBufferStateEnum GetState() const;
40 // Get current state and timestamp of frame
41 VCMFrameBufferStateEnum GetState(uint32_t& timeStamp) const;
42 void PrepareForDecode(bool continuous);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
agalusza@google.comd818dcb2013-07-29 21:48:11 +000044 bool IsRetransmitted() const;
45 bool IsSessionComplete() const;
46 bool HaveFirstPacket() const;
47 bool HaveLastPacket() const;
48 int NumPackets() const;
49 // Makes sure the session contain a decodable stream.
50 void MakeSessionDecodable();
niklase@google.com470e71d2011-07-07 08:21:25 +000051
agalusza@google.comd818dcb2013-07-29 21:48:11 +000052 // Sequence numbers
53 // Get lowest packet sequence number in frame
54 int32_t GetLowSeqNum() const;
55 // Get highest packet sequence number in frame
56 int32_t GetHighSeqNum() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
agalusza@google.comd818dcb2013-07-29 21:48:11 +000058 int PictureId() const;
59 int TemporalId() const;
60 bool LayerSync() const;
61 int Tl0PicId() const;
62 bool NonReference() const;
stefan@webrtc.orgffd28f92011-10-19 15:55:39 +000063
asapersson9a4cd872015-10-23 00:27:14 -070064 void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
65
agalusza@google.comd818dcb2013-07-29 21:48:11 +000066 // Increments a counter to keep track of the number of packets of this frame
67 // which were NACKed before they arrived.
68 void IncrementNackCount();
69 // Returns the number of packets of this frame which were NACKed before they
70 // arrived.
71 int16_t GetNackCount() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000072
agalusza@google.comd818dcb2013-07-29 21:48:11 +000073 int64_t LatestPacketTimeMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000074
agalusza@google.comd818dcb2013-07-29 21:48:11 +000075 webrtc::FrameType FrameType() const;
76 void SetPreviousFrameLoss();
niklase@google.com470e71d2011-07-07 08:21:25 +000077
asapersson9a4cd872015-10-23 00:27:14 -070078 // The number of packets discarded because the decoder can't make use of them.
mikhal@webrtc.org3c5a9242013-09-03 20:45:36 +000079 int NotDecodablePackets() const;
agalusza@google.comd177c102013-08-08 01:12:33 +000080
agalusza@google.comd818dcb2013-07-29 21:48:11 +000081 private:
82 void SetState(VCMFrameBufferStateEnum state); // Set state of frame
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000083
asapersson9a4cd872015-10-23 00:27:14 -070084 VCMFrameBufferStateEnum _state; // Current state of the frame
85 VCMSessionInfo _sessionInfo;
86 uint16_t _nackCount;
87 int64_t _latestPacketTimeMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000088};
89
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000090} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000091
Henrik Kjellander2557b862015-11-18 22:00:21 +010092#endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER_H_