Overte C++ Documentation
PointerClip.h
1 //
2 // Created by Bradley Austin Davis 2015/11/05
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #pragma once
10 #ifndef hifi_Recording_Impl_PointerClip_h
11 #define hifi_Recording_Impl_PointerClip_h
12 
13 #include "ArrayClip.h"
14 
15 #include <mutex>
16 
17 #include <QtCore/QJsonDocument>
18 
19 #include "../Frame.h"
20 
21 namespace recording {
22 
23 struct PointerFrameHeader : public FrameHeader {
24  FrameType type;
25  Frame::Time timeOffset;
26  uint16_t size;
27  quint64 fileOffset;
28 };
29 
30 using PointerFrameHeaderList = std::list<PointerFrameHeader>;
31 
32 class PointerClip : public ArrayClip<PointerFrameHeader> {
33 public:
34  using Pointer = std::shared_ptr<PointerClip>;
35 
36  PointerClip() {};
37  PointerClip(uchar* data, size_t size) { init(data, size); }
38 
39  void init(uchar* data, size_t size);
40  virtual void addFrame(FrameConstPointer) override;
41  const QJsonDocument& getHeader() const {
42  return _header;
43  }
44 
45  // FIXME move to frame?
46  static const qint64 MINIMUM_FRAME_SIZE = sizeof(FrameType) + sizeof(Frame::Time) + sizeof(FrameSize);
47 protected:
48  void reset() override;
49  virtual FrameConstPointer readFrame(size_t index) const override;
50  QJsonDocument _header;
51  uchar* _data { nullptr };
52  size_t _size { 0 };
53  bool _compressed { true };
54 };
55 
56 }
57 
58 #endif