OpenShot Library | libopenshot  0.3.3
DummyReader.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_DUMMY_READER_H
14 #define OPENSHOT_DUMMY_READER_H
15 
16 #include "ReaderBase.h"
17 
18 #include <cmath>
19 #include <ctime>
20 #include <iostream>
21 #include <omp.h>
22 #include <stdio.h>
23 #include <memory>
24 #include "CacheMemory.h"
25 #include "Fraction.h"
26 
27 namespace openshot
28 {
85  class DummyReader : public ReaderBase
86  {
87  private:
88  CacheBase* dummy_cache;
89  std::shared_ptr<openshot::Frame> image_frame;
90  std::shared_ptr<openshot::Frame> last_cached_frame;
91  bool is_open;
92 
94  void init(Fraction fps, int width, int height, int sample_rate, int channels, float duration);
95 
96  public:
97 
99  DummyReader();
100 
102  DummyReader(openshot::Fraction fps, int width, int height, int sample_rate, int channels, float duration);
103 
105  DummyReader(openshot::Fraction fps, int width, int height, int sample_rate, int channels, float duration, CacheBase* cache);
106 
107  virtual ~DummyReader();
108 
110  void Close() override;
111 
113  CacheMemory* GetCache() override { return NULL; };
114 
120  std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame) override;
121 
123  bool IsOpen() override { return is_open; };
124 
126  std::string Name() override { return "DummyReader"; };
127 
128  // Get and Set JSON methods
129  std::string Json() const override;
130  void SetJson(const std::string value) override;
131  Json::Value JsonValue() const override;
132  void SetJsonValue(const Json::Value root) override;
133 
135  void Open() override;
136  };
137 
138 }
139 
140 #endif
Fraction.h
Header file for Fraction class.
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::Fraction
This class represents a fraction.
Definition: Fraction.h:30
openshot::DummyReader::Open
void Open() override
Open File - which is called by the constructor automatically.
Definition: DummyReader.cpp:79
openshot::DummyReader
This class is used as a simple, dummy reader, which can be very useful when writing unit tests....
Definition: DummyReader.h:85
openshot::CacheBase
All cache managers in libopenshot are based on this CacheBase class.
Definition: CacheBase.h:34
openshot::DummyReader::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: DummyReader.cpp:167
openshot::DummyReader::Name
std::string Name() override
Return the type name of the class.
Definition: DummyReader.h:126
openshot::CacheMemory
This class is a memory-based cache manager for Frame objects.
Definition: CacheMemory.h:29
openshot::DummyReader::IsOpen
bool IsOpen() override
Determine if reader is open or closed.
Definition: DummyReader.h:123
CacheMemory.h
Header file for CacheMemory class.
openshot::DummyReader::~DummyReader
virtual ~DummyReader()
Definition: DummyReader.cpp:75
openshot::DummyReader::GetCache
CacheMemory * GetCache() override
Get the cache object used by this reader (always returns NULL for this reader)
Definition: DummyReader.h:113
openshot::DummyReader::Close
void Close() override
Close File.
Definition: DummyReader.cpp:93
openshot::DummyReader::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: DummyReader.cpp:156
ReaderBase.h
Header file for ReaderBase class.
openshot::DummyReader::DummyReader
DummyReader()
Blank constructor for DummyReader, with default settings.
Definition: DummyReader.cpp:50
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:75
openshot::DummyReader::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: DummyReader.cpp:184
openshot::DummyReader::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
Definition: DummyReader.cpp:105
openshot::DummyReader::Json
std::string Json() const override
Generate JSON string of this object.
Definition: DummyReader.cpp:149