Missed update to private test repo version.
[dcpomatic.git] / src / lib / util.h
1 /*
2     Copyright (C) 2012-2020 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
22 /** @file src/util.h
23  *  @brief Some utility functions and classes.
24  */
25
26
27 #ifndef DCPOMATIC_UTIL_H
28 #define DCPOMATIC_UTIL_H
29
30
31 #include "audio_mapping.h"
32 #include "dcpomatic_time.h"
33 #include "pixel_quanta.h"
34 #include "types.h"
35 #include <dcp/atmos_asset.h>
36 #include <dcp/decrypted_kdm.h>
37 #include <dcp/util.h>
38 #include <dcp/subtitle_image.h>
39 #include <boost/optional.hpp>
40 #include <boost/filesystem.hpp>
41 #include <boost/date_time/gregorian/gregorian.hpp>
42 #include <string>
43 #include <map>
44 #include <vector>
45
46 #undef check
47
48
49 namespace dcp {
50         class PictureAsset;
51         class SoundAsset;
52         class SubtitleAsset;
53 }
54
55 extern std::string program_name;
56 extern bool is_batch_converter;
57
58 class AudioBuffers;
59 class TextDecoder;
60
61 extern std::string seconds_to_hms (int);
62 extern std::string time_to_hmsf (dcpomatic::DCPTime time, Frame rate);
63 extern std::string seconds_to_approximate_hms (int);
64 extern double seconds (struct timeval);
65 extern void dcpomatic_setup ();
66 extern void dcpomatic_setup_path_encoding ();
67 extern void dcpomatic_setup_gettext_i18n (std::string);
68 extern std::string digest_head_tail (std::vector<boost::filesystem::path>, boost::uintmax_t size);
69 extern std::string simple_digest (std::vector<boost::filesystem::path> paths);
70 extern void ensure_ui_thread ();
71 extern std::string audio_channel_name (int);
72 extern std::string short_audio_channel_name (int);
73 extern bool valid_image_file (boost::filesystem::path);
74 extern bool valid_sound_file (boost::filesystem::path);
75 extern bool valid_j2k_file (boost::filesystem::path);
76 #ifdef DCPOMATIC_WINDOWS
77 extern boost::filesystem::path mo_path ();
78 #endif
79 extern std::string tidy_for_filename (std::string);
80 extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
81 extern void set_backtrace_file (boost::filesystem::path);
82 extern std::string video_asset_filename (std::shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
83 extern std::string audio_asset_filename (std::shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
84 extern std::string subtitle_asset_filename (std::shared_ptr<dcp::SubtitleAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary, std::string extension);
85 extern std::string atmos_asset_filename (std::shared_ptr<dcp::AtmosAsset> asset, int reel_index, int reel_count, boost::optional<std::string> content_summary);
86 extern std::string careful_string_filter (std::string);
87 extern std::pair<int, int> audio_channel_types (std::list<int> mapped, int channels);
88 extern std::shared_ptr<AudioBuffers> remap (std::shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map);
89 extern size_t utf8_strlen (std::string s);
90 extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, std::shared_ptr<TextDecoder> decoder);
91 extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)>);
92 extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta);
93 extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm);
94 extern boost::filesystem::path default_font_file ();
95 extern void start_of_thread (std::string name);
96 extern std::string error_details(boost::system::error_code ec);
97 extern bool contains_assetmap(boost::filesystem::path dir);
98 extern std::string word_wrap(std::string input, int columns);
99 extern void capture_ffmpeg_logs();
100 extern std::string screen_names_to_string(std::vector<std::string> names);
101
102 #endif