Listen for server replies on different ports on main and batch, and get servers to...
[dcpomatic.git] / src / lib / util.h
1 /*
2     Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 /** @file src/util.h
22  *  @brief Some utility functions and classes.
23  */
24
25 #ifndef DCPOMATIC_UTIL_H
26 #define DCPOMATIC_UTIL_H
27
28 #include "types.h"
29 #include "dcpomatic_time.h"
30 #include "audio_mapping.h"
31 #include <dcp/util.h>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/optional.hpp>
34 #include <boost/filesystem.hpp>
35 #include <string>
36 #include <map>
37 #include <vector>
38
39 #undef check
40
41 namespace dcp {
42         class PictureAsset;
43         class SoundAsset;
44 }
45
46 #ifndef M_PI
47 #define M_PI (3.14159265358979323846)
48 #endif
49
50 /** The maximum number of audio channels that we can have in a DCP */
51 #define MAX_DCP_AUDIO_CHANNELS 16
52 /** Message broadcast to find possible encoding servers */
53 #define DCPOMATIC_HELLO "I mean really, Ray, it's used."
54 /** Number of films to keep in history */
55 #define HISTORY_SIZE 10
56 #define REPORT_PROBLEM _("Please report this problem by using Help -> Report a problem or via email to carl@dcpomatic.com")
57 #define TEXT_FONT_ID "font"
58 /** Largest KDM size (in bytes) that will be accepted */
59 #define MAX_KDM_SIZE (256 * 1024)
60
61 extern std::string program_name;
62 extern bool is_batch_converter;
63
64 struct AVSubtitle;
65 class AudioBuffers;
66
67 extern std::string seconds_to_hms (int);
68 extern std::string time_to_hmsf (DCPTime time, Frame rate);
69 extern std::string seconds_to_approximate_hms (int);
70 extern double seconds (struct timeval);
71 extern void dcpomatic_setup ();
72 extern void dcpomatic_setup_path_encoding ();
73 extern void dcpomatic_setup_gettext_i18n (std::string);
74 extern std::string digest_head_tail (std::vector<boost::filesystem::path>, boost::uintmax_t size);
75 extern void ensure_ui_thread ();
76 extern std::string audio_channel_name (int);
77 extern std::string short_audio_channel_name (int);
78 extern bool valid_image_file (boost::filesystem::path);
79 extern bool valid_sound_file (boost::filesystem::path);
80 extern bool valid_j2k_file (boost::filesystem::path);
81 #ifdef DCPOMATIC_WINDOWS
82 extern boost::filesystem::path mo_path ();
83 #endif
84 extern std::string tidy_for_filename (std::string);
85 extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
86 extern int stride_round_up (int, int const *, int);
87 extern void* wrapped_av_malloc (size_t);
88 extern void set_backtrace_file (boost::filesystem::path);
89 extern std::map<std::string, std::string> split_get_request (std::string url);
90 extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
91 extern std::string audio_asset_filename (boost::shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
92 extern float relaxed_string_to_float (std::string);
93 extern std::string careful_string_filter (std::string);
94 extern std::pair<int, int> audio_channel_types (std::list<int> mapped, int channels);
95 extern boost::shared_ptr<AudioBuffers> remap (boost::shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map);
96 extern Eyes increment_eyes (Eyes e);
97
98 #endif