OpenShot Library | libopenshot  0.3.1
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
Header file for CacheMemory class.
Header file for Fraction class.
Header file for ReaderBase class.
All cache managers in libopenshot are based on this CacheBase class.
Definition: CacheBase.h:35
This class is a memory-based cache manager for Frame objects.
Definition: CacheMemory.h:29
This class is used as a simple, dummy reader, which can be very useful when writing unit tests....
Definition: DummyReader.h:86
bool IsOpen() override
Determine if reader is open or closed.
Definition: DummyReader.h:123
DummyReader()
Blank constructor for DummyReader, with default settings.
Definition: DummyReader.cpp:50
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame) override
void SetJson(const std::string value) override
Load JSON string into this object.
Json::Value JsonValue() const override
Generate Json::Value for this object.
std::string Json() const override
Generate JSON string of this object.
void Open() override
Open File - which is called by the constructor automatically.
Definition: DummyReader.cpp:79
CacheMemory * GetCache() override
Get the cache object used by this reader (always returns NULL for this reader)
Definition: DummyReader.h:113
void Close() override
Close File.
Definition: DummyReader.cpp:93
std::string Name() override
Return the type name of the class.
Definition: DummyReader.h:126
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
This class represents a fraction.
Definition: Fraction.h:30
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:76
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:29