2 Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 * @brief Some utility functions and classes.
25 #ifndef DCPOMATIC_UTIL_H
26 #define DCPOMATIC_UTIL_H
29 #include "dcpomatic_time.h"
31 #include <boost/shared_ptr.hpp>
32 #include <boost/optional.hpp>
33 #include <boost/filesystem.hpp>
45 /** The maximum number of audio channels that we can have in a DCP */
46 #define MAX_DCP_AUDIO_CHANNELS 16
47 /** Message broadcast to find possible encoding servers */
48 #define DCPOMATIC_HELLO "I mean really, Ray, it's used."
49 /** Number of films to keep in history */
50 #define HISTORY_SIZE 10
51 #define REPORT_PROBLEM _("Please report this problem by using Help -> Report a problem or via email to carl@dcpomatic.com")
52 #define TEXT_FONT_ID "font"
54 extern std::string program_name;
58 extern std::string seconds_to_hms (int);
59 extern std::string seconds_to_approximate_hms (int);
60 extern double seconds (struct timeval);
61 extern void dcpomatic_setup ();
62 extern void dcpomatic_setup_path_encoding ();
63 extern void dcpomatic_setup_gettext_i18n (std::string);
64 extern std::string digest_head_tail (std::vector<boost::filesystem::path>, boost::uintmax_t size);
65 extern void ensure_ui_thread ();
66 extern std::string audio_channel_name (int);
67 extern std::string short_audio_channel_name (int);
68 extern bool valid_image_file (boost::filesystem::path);
69 extern bool valid_j2k_file (boost::filesystem::path);
70 #ifdef DCPOMATIC_WINDOWS
71 extern boost::filesystem::path mo_path ();
73 extern std::string tidy_for_filename (std::string);
74 extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
75 extern int stride_round_up (int, int const *, int);
76 extern void* wrapped_av_malloc (size_t);
77 extern void set_backtrace_file (boost::filesystem::path);
78 extern std::map<std::string, std::string> split_get_request (std::string url);
79 extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
80 extern std::string audio_asset_filename (boost::shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
81 extern float relaxed_string_to_float (std::string);