blob: 3e5a7ff3c8f9d28d1f000d7a1c8707faa6a2def9 [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
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
stefana669a3a2016-10-06 05:04:52 -070016#include <vector>
17
Yves Gerey3e707812018-11-28 16:47:49 +010018#include "modules/video_coding/codecs/h264/include/h264_globals.h"
19#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/video_coding/encoded_frame.h"
Yves Gerey665174f2018-06-19 15:03:05 +020021#include "modules/video_coding/include/video_coding.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "modules/video_coding/jitter_buffer_common.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "modules/video_coding/packet.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020024#include "modules/video_coding/session_info.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000025
agalusza@google.comd818dcb2013-07-29 21:48:11 +000026namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000027
agalusza@google.comd818dcb2013-07-29 21:48:11 +000028class VCMFrameBuffer : public VCMEncodedFrame {
29 public:
30 VCMFrameBuffer();
31 virtual ~VCMFrameBuffer();
niklase@google.com470e71d2011-07-07 08:21:25 +000032
agalusza@google.comd818dcb2013-07-29 21:48:11 +000033 virtual void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000034
agalusza@google.comd818dcb2013-07-29 21:48:11 +000035 VCMFrameBufferEnum InsertPacket(const VCMPacket& packet,
36 int64_t timeInMs,
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;
agalusza@google.comd818dcb2013-07-29 21:48:11 +000042 void PrepareForDecode(bool continuous);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
agalusza@google.comd818dcb2013-07-29 21:48:11 +000044 bool IsSessionComplete() const;
45 bool HaveFirstPacket() const;
agalusza@google.comd818dcb2013-07-29 21:48:11 +000046 int NumPackets() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000047
agalusza@google.comd818dcb2013-07-29 21:48:11 +000048 // Sequence numbers
49 // Get lowest packet sequence number in frame
50 int32_t GetLowSeqNum() const;
51 // Get highest packet sequence number in frame
52 int32_t GetHighSeqNum() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000053
agalusza@google.comd818dcb2013-07-29 21:48:11 +000054 int PictureId() const;
55 int TemporalId() const;
56 bool LayerSync() const;
57 int Tl0PicId() const;
stefan@webrtc.orgffd28f92011-10-19 15:55:39 +000058
stefana669a3a2016-10-06 05:04:52 -070059 std::vector<NaluInfo> GetNaluInfos() const;
60
asapersson9a4cd872015-10-23 00:27:14 -070061 void SetGofInfo(const GofInfoVP9& gof_info, size_t idx);
62
agalusza@google.comd818dcb2013-07-29 21:48:11 +000063 // Increments a counter to keep track of the number of packets of this frame
64 // which were NACKed before they arrived.
65 void IncrementNackCount();
66 // Returns the number of packets of this frame which were NACKed before they
67 // arrived.
68 int16_t GetNackCount() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000069
agalusza@google.comd818dcb2013-07-29 21:48:11 +000070 int64_t LatestPacketTimeMs() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000071
Niels Möller87e2d782019-03-07 10:18:23 +010072 webrtc::VideoFrameType FrameType() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000073
agalusza@google.comd818dcb2013-07-29 21:48:11 +000074 private:
75 void SetState(VCMFrameBufferStateEnum state); // Set state of frame
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000076
asapersson9a4cd872015-10-23 00:27:14 -070077 VCMFrameBufferStateEnum _state; // Current state of the frame
78 VCMSessionInfo _sessionInfo;
79 uint16_t _nackCount;
80 int64_t _latestPacketTimeMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000081};
82
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000083} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000084
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020085#endif // MODULES_VIDEO_CODING_FRAME_BUFFER_H_