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