1 /**
2  * @file
3  * @brief Header file for global Settings 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_SETTINGS_H
32 #define OPENSHOT_SETTINGS_H
33 
34 #include <string>
35 
36 namespace openshot {
37 
38 	/**
39 	 * @brief This class is contains settings used by libopenshot (and can be safely toggled at any point)
40 	 *
41 	 * Settings class is used primarily to toggle scale settings between preview and rendering, and adjust
42 	 * other runtime related settings.
43 	 */
44 	class Settings {
45 	private:
46 
47 		/// Default constructor
Settings()48 		Settings(){}; 						 // Don't allow user to create an instance of this singleton
49 
50 #if __GNUC__ >=7
51 		/// Default copy method
52 		Settings(Settings const&) = delete; // Don't allow the user to assign this instance
53 
54 		/// Default assignment operator
55 		Settings & operator=(Settings const&) = delete;  // Don't allow the user to assign this instance
56 #else
57 		/// Default copy method
Settings(Settings const &)58 		Settings(Settings const&) {}; // Don't allow the user to assign this instance
59 
60 		/// Default assignment operator
61 		Settings & operator=(Settings const&);  // Don't allow the user to assign this instance
62 #endif
63 
64 		/// Private variable to keep track of singleton instance
65 		static Settings * m_pInstance;
66 
67 	public:
68 		/**
69 		 * @brief Use video codec for faster video decoding (if supported)
70 		 *
71 		 * 0 - No acceleration,
72 		 * 1 - Linux VA-API,
73 		 * 2 - nVidia NVDEC,
74 		 * 3 - Windows D3D9,
75 		 * 4 - Windows D3D11,
76 		 * 5 - MacOS / VideoToolBox,
77 		 * 6 - Linux VDPAU,
78 		 * 7 - Intel QSV
79 		 */
80 		int HARDWARE_DECODER = 0;
81 
82 		/// Scale mode used in FFmpeg decoding and encoding (used as an optimization for faster previews)
83 		bool HIGH_QUALITY_SCALING = false;
84 
85 		/// Number of threads of OpenMP
86 		int OMP_THREADS = 12;
87 
88 		/// Number of threads that ffmpeg uses
89 		int FF_THREADS = 8;
90 
91 		/// Maximum rows that hardware decode can handle
92 		int DE_LIMIT_HEIGHT_MAX = 1100;
93 
94 		/// Maximum columns that hardware decode can handle
95 		int DE_LIMIT_WIDTH_MAX = 1950;
96 
97 		/// Which GPU to use to decode (0 is the first)
98 		int HW_DE_DEVICE_SET = 0;
99 
100 		/// Which GPU to use to encode (0 is the first)
101 		int HW_EN_DEVICE_SET = 0;
102 
103 		/// The audio device name to use during playback
104 		std::string PLAYBACK_AUDIO_DEVICE_NAME = "";
105 
106 		/// The current install path of OpenShot (needs to be set when using Timeline(path), since certain
107 		/// paths depend on the location of OpenShot transitions and files)
108 		std::string PATH_OPENSHOT_INSTALL = "";
109 
110  		/// Whether to dump ZeroMQ debug messages to stderr
111 		bool DEBUG_TO_STDERR = false;
112 
113 		/// Create or get an instance of this logger singleton (invoke the class with this method)
114 		static Settings * Instance();
115 	};
116 
117 }
118 
119 #endif
120