blob: 0b8c220a60eaa9834e746693e7e398ba0406b9a6 [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"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/video_coding/encoded_frame.h"
Yves Gerey665174f2018-06-19 15:03:05 +020018#include "modules/video_coding/include/video_coding.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/video_coding/jitter_buffer_common.h"
20#include "modules/video_coding/session_info.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
agalusza@google.comd818dcb2013-07-29 21:48:11 +000022namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
agalusza@google.comd818dcb2013-07-29 21:48:11 +000024class VCMFrameBuffer : public VCMEncodedFrame {
25 public:
26 VCMFrameBuffer();
27 virtual ~VCMFrameBuffer();
niklase@google.com470e71d2011-07-07 08:21:25 +000028
agalusza@google.comd818dcb2013-07-29 21:48:11 +000029 virtual void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000030
agalusza@google.comd818dcb2013-07-29 21:48:11 +000031 VCMFrameBufferEnum InsertPacket(const VCMPacket& packet,
32 int64_t timeInMs,
agalusza@google.coma7e360e2013-08-01 03:15:08 +000033 VCMDecodeErrorMode decode_error_mode,
agalusza@google.comd818dcb2013-07-29 21:48:11 +000034 const FrameData& frame_data);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
agalusza@google.comd818dcb2013-07-29 21:48:11 +000036 // State
37 // Get current state of frame
38 VCMFrameBufferStateEnum GetState() const;
agalusza@google.comd818dcb2013-07-29 21:48:11 +000039 void PrepareForDecode(bool continuous);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
agalusza@google.comd818dcb2013-07-29 21:48:11 +000041 bool IsSessionComplete() const;
42 bool HaveFirstPacket() const;
agalusza@google.comd818dcb2013-07-29 21:48:11 +000043 int NumPackets() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000044
agalusza@google.comd818dcb2013-07-29 21:48:11 +000045 // Sequence numbers
46 // Get lowest packet sequence number in frame
47 int32_t GetLowSeqNum() const;
48 // Get highest packet sequence number in frame
49 int32_t GetHighSeqNum() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
agalusza@google.comd818dcb2013-07-29 21:48:11 +000051 int PictureId() const;
52 int TemporalId() const;
53 bool LayerSync() const;
54 int Tl0PicId() const;
stefan@webrtc.orgffd28f92011-10-19 15:55:39 +000055
stefana669a3a2016-10-06 05:04:52 -070056 std::vector<NaluInfo> GetNaluInfos() const;
57
asapersson9a4cd872015-10-23 00:27:14 -070058 void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
59
agalusza@google.comd818dcb2013-07-29 21:48:11 +000060 // Increments a counter to keep track of the number of packets of this frame
61 // which were NACKed before they arrived.
62 void IncrementNackCount();
63 // Returns the number of packets of this frame which were NACKed before they
64 // arrived.
65 int16_t GetNackCount() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
agalusza@google.comd818dcb2013-07-29 21:48:11 +000067 int64_t LatestPacketTimeMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000068
agalusza@google.comd818dcb2013-07-29 21:48:11 +000069 webrtc::FrameType FrameType() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000070
agalusza@google.comd818dcb2013-07-29 21:48:11 +000071 private:
72 void SetState(VCMFrameBufferStateEnum state); // Set state of frame
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000073
asapersson9a4cd872015-10-23 00:27:14 -070074 VCMFrameBufferStateEnum _state; // Current state of the frame
75 VCMSessionInfo _sessionInfo;
76 uint16_t _nackCount;
77 int64_t _latestPacketTimeMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000078};
79
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000080} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000081
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // MODULES_VIDEO_CODING_FRAME_BUFFER_H_