2 Copyright (C) 2012-2020 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/>.
23 * @brief Some utility functions and classes.
27 #ifndef DCPOMATIC_UTIL_H
28 #define DCPOMATIC_UTIL_H
31 #include "audio_mapping.h"
32 #include "dcpomatic_time.h"
33 #include "pixel_quanta.h"
35 #include <dcp/atmos_asset.h>
36 #include <dcp/decrypted_kdm.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>
55 extern std::string program_name;
56 extern bool is_batch_converter;
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 ();
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 void capture_asdcp_logs ();
97 extern std::string error_details(boost::system::error_code ec);
98 extern bool contains_assetmap(boost::filesystem::path dir);