OpenShot Library | libopenshot  0.2.5
DummyReader.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for DummyReader class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @ref License
7  */
8 
9 /* LICENSE
10  *
11  * Copyright (c) 2008-2019 OpenShot Studios, LLC
12  * <http://www.openshotstudios.com/>. This file is part of
13  * OpenShot Library (libopenshot), an open-source project dedicated to
14  * delivering high quality video editing and animation solutions to the
15  * world. For more information visit <http://www.openshot.org/>.
16  *
17  * OpenShot Library (libopenshot) is free software: you can redistribute it
18  * and/or modify it under the terms of the GNU Lesser General Public License
19  * as published by the Free Software Foundation, either version 3 of the
20  * License, or (at your option) any later version.
21  *
22  * OpenShot Library (libopenshot) is distributed in the hope that it will be
23  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public License
28  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29  */
30 
31 #ifndef OPENSHOT_DUMMY_READER_H
32 #define OPENSHOT_DUMMY_READER_H
33 
34 #include "ReaderBase.h"
35 
36 #include <cmath>
37 #include <ctime>
38 #include <iostream>
39 #include <omp.h>
40 #include <stdio.h>
41 #include <memory>
42 #include "CacheMemory.h"
43 #include "Exceptions.h"
44 #include "Fraction.h"
45 
46 namespace openshot
47 {
48  /**
49  * @brief This class is used as a simple, dummy reader, which always returns a blank frame.
50  *
51  * A dummy reader can be created with any framerate or samplerate. This is useful in unit
52  * tests that need to test different framerates or samplerates.
53  */
54  class DummyReader : public ReaderBase
55  {
56  private:
57  std::shared_ptr<openshot::Frame> image_frame;
58  bool is_open;
59 
60  public:
61 
62  /// Blank constructor for DummyReader, with default settings.
63  DummyReader();
64 
65  /// Constructor for DummyReader.
66  DummyReader(openshot::Fraction fps, int width, int height, int sample_rate, int channels, float duration);
67 
68  virtual ~DummyReader();
69 
70  /// Close File
71  void Close();
72 
73  /// Get the cache object used by this reader (always returns NULL for this reader)
74  CacheMemory* GetCache() { return NULL; };
75 
76  /// Get an openshot::Frame object for a specific frame number of this reader. All numbers
77  /// return the same Frame, since they all share the same image data.
78  ///
79  /// @returns The requested frame (containing the image)
80  /// @param requested_frame The frame number that is requested.
81  std::shared_ptr<openshot::Frame> GetFrame(int64_t requested_frame);
82 
83  /// Determine if reader is open or closed
84  bool IsOpen() { return is_open; };
85 
86  /// Return the type name of the class
87  std::string Name() { return "DummyReader"; };
88 
89  /// Get and Set JSON methods
90  std::string Json() const override; ///< Generate JSON string of this object
91  void SetJson(const std::string value); ///< Load JSON string into this object
92  Json::Value JsonValue() const override; ///< Generate Json::Value for this object
93  void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
94 
95  /// Open File - which is called by the constructor automatically
96  void Open();
97  };
98 
99 }
100 
101 #endif
Header file for Fraction class.
void SetJson(const std::string value)
Load JSON string into this object.
Header file for ReaderBase class.
This class is used as a simple, dummy reader, which always returns a blank frame. ...
Definition: DummyReader.h:54
CacheMemory * GetCache()
Get the cache object used by this reader (always returns NULL for this reader)
Definition: DummyReader.h:74
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:97
std::string Json() const override
Get and Set JSON methods.
DummyReader()
Blank constructor for DummyReader, with default settings.
Definition: DummyReader.cpp:36
Header file for CacheMemory class.
Header file for all Exception classes.
void Open()
Open File - which is called by the constructor automatically.
Definition: DummyReader.cpp:81
This class represents a fraction.
Definition: Fraction.h:45
std::shared_ptr< openshot::Frame > GetFrame(int64_t requested_frame)
void Close()
Close File.
Definition: DummyReader.cpp:95
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
bool IsOpen()
Determine if reader is open or closed.
Definition: DummyReader.h:84
This namespace is the default namespace for all code in the openshot library.
Json::Value JsonValue() const override
Generate Json::Value for this object.
This class is a memory-based cache manager for Frame objects.
Definition: CacheMemory.h:51
std::string Name()
Return the type name of the class.
Definition: DummyReader.h:87