Rest of src/lib/*.h tidying.
[dcpomatic.git] / src / lib / util.h
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file src/util.h
21  *  @brief Some utility functions and classes.
22  */
23
24 #ifndef DCPOMATIC_UTIL_H
25 #define DCPOMATIC_UTIL_H
26
27 #include "types.h"
28 #include "dcpomatic_time.h"
29 #include <dcp/util.h>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/optional.hpp>
32 #include <boost/filesystem.hpp>
33 #include <string>
34 #include <vector>
35
36 #undef check
37
38 namespace dcp {
39         class PictureAsset;
40         class SoundAsset;
41 }
42
43 /** The maximum number of audio channels that we can have in a DCP */
44 #define MAX_DCP_AUDIO_CHANNELS 12
45 /** Message broadcast to find possible encoding servers */
46 #define DCPOMATIC_HELLO "I mean really, Ray, it's used."
47 /** Number of films to keep in history */
48 #define HISTORY_SIZE 10
49 #define REPORT_PROBLEM _("Please report this problem by using Help -> Report a problem or via email to carl@dcpomatic.com")
50
51 extern std::string program_name;
52
53 class Job;
54 struct AVSubtitle;
55
56 extern std::string seconds_to_hms (int);
57 extern std::string seconds_to_approximate_hms (int);
58 extern double seconds (struct timeval);
59 extern void dcpomatic_setup ();
60 extern void dcpomatic_setup_path_encoding ();
61 extern void dcpomatic_setup_gettext_i18n (std::string);
62 extern std::string md5_digest_head_tail (std::vector<boost::filesystem::path>, boost::uintmax_t size);
63 extern void ensure_ui_thread ();
64 extern std::string audio_channel_name (int);
65 extern bool valid_image_file (boost::filesystem::path);
66 extern bool valid_j2k_file (boost::filesystem::path);
67 #ifdef DCPOMATIC_WINDOWS
68 extern boost::filesystem::path mo_path ();
69 #endif
70 extern std::string tidy_for_filename (std::string);
71 extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
72 extern int stride_round_up (int, int const *, int);
73 extern void* wrapped_av_malloc (size_t);
74
75 class FFmpegSubtitlePeriod
76 {
77 public:
78         FFmpegSubtitlePeriod (ContentTime f)
79                 : from (f)
80         {}
81
82         FFmpegSubtitlePeriod (ContentTime f, ContentTime t)
83                 : from (f)
84                 , to (t)
85         {}
86
87         ContentTime from;
88         boost::optional<ContentTime> to;
89 };
90
91 extern FFmpegSubtitlePeriod subtitle_period (AVSubtitle const &);
92 extern void set_backtrace_file (boost::filesystem::path);
93 extern std::map<std::string, std::string> split_get_request (std::string url);
94 extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset);
95 extern std::string audio_asset_filename (boost::shared_ptr<dcp::SoundAsset> asset);
96
97 #endif