X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Futil.h;h=579b1c231bf144874af2aa6fcc78b239e419dbe3;hp=a83426206f88e7398423a152b408573cb31066cb;hb=854f2e5bbb7ffb9758b823af87034033033f3cb8;hpb=bed373d380d35294b03d228a2ef41cfa8fceb4b0 diff --git a/src/lib/util.h b/src/lib/util.h index a83426206..579b1c231 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -31,7 +31,8 @@ #include #include #include -#include +#include +#include extern "C" { #include #include @@ -49,7 +50,13 @@ extern "C" { #undef check /** The maximum number of audio channels that we can cope with */ -#define MAX_AUDIO_CHANNELS 6 +#define MAX_AUDIO_CHANNELS 12 + +#define DCPOMATIC_HELLO "Boys, you gotta learn not to talk to nuns that way" + +namespace libdcp { + class Signer; +} class Job; @@ -61,8 +68,7 @@ extern double seconds (struct timeval); extern void dcpomatic_setup (); extern void dcpomatic_setup_gettext_i18n (std::string); extern std::vector split_at_spaces_considering_quotes (std::string); -extern std::string md5_digest (boost::filesystem::path); -extern std::string md5_digest_directory (boost::filesystem::path, boost::shared_ptr); +extern std::string md5_digest (std::vector, boost::shared_ptr); extern std::string md5_digest (void const *, int); extern void ensure_ui_thread (); extern std::string audio_channel_name (int); @@ -70,42 +76,11 @@ extern bool valid_image_file (boost::filesystem::path); #ifdef DCPOMATIC_WINDOWS extern boost::filesystem::path mo_path (); #endif - -struct FrameRateConversion -{ - FrameRateConversion (float, int); - - /** @return factor by which to multiply a source frame rate - to get the effective rate after any skip or repeat has happened. - */ - float factor () const { - if (skip) { - return 0.5; - } else if (repeat) { - return 2; - } - - return 1; - } - - /** true to skip every other frame */ - bool skip; - /** true to repeat every frame once */ - bool repeat; - /** true if this DCP will run its video faster or slower than the source - * without taking into account `repeat' nor `skip'. - * (e.g. change_speed will be true if - * source is 29.97fps, DCP is 30fps - * source is 14.50fps, DCP is 30fps - * but not if - * source is 15.00fps, DCP is 30fps - * source is 12.50fps, DCP is 25fps) - */ - bool change_speed; - - std::string description; -}; - +extern std::string tidy_for_filename (std::string); +extern boost::shared_ptr make_signer (); +extern dcp::Size fit_ratio_within (float ratio, dcp::Size); +extern std::string entities_to_text (std::string e); +extern std::map split_get_request (std::string url); extern int dcp_audio_frame_rate (int); extern int stride_round_up (int, int const *, int); extern std::multimap read_key_value (std::istream& s); @@ -114,6 +89,8 @@ extern float get_required_float (std::multimap const & extern std::string get_required_string (std::multimap const & kv, std::string k); extern int get_optional_int (std::multimap const & kv, std::string k); extern std::string get_optional_string (std::multimap const & kv, std::string k); +extern void* wrapped_av_malloc (size_t); +extern int64_t divide_with_round (int64_t a, int64_t b); /** @class Socket * @brief A class to wrap a boost::asio::ip::tcp::socket with some things @@ -126,13 +103,15 @@ class Socket { public: Socket (int timeout = 30); + ~Socket (); /** @return Our underlying socket */ boost::asio::ip::tcp::socket& socket () { return _socket; } - void connect (boost::asio::ip::basic_resolver_entry const & endpoint); + void connect (boost::asio::ip::tcp::endpoint); + void accept (int); void write (uint32_t n); void write (uint8_t const * data, int size); @@ -148,11 +127,10 @@ private: boost::asio::io_service _io_service; boost::asio::deadline_timer _deadline; boost::asio::ip::tcp::socket _socket; + boost::asio::ip::tcp::acceptor* _acceptor; int _timeout; }; -extern int64_t video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, float frames_per_second); - class LocaleGuard { public: @@ -163,6 +141,24 @@ private: char* _old; }; +class ScopedTemporary +{ +public: + ScopedTemporary (); + ~ScopedTemporary (); + + boost::filesystem::path file () const { + return _file; + } + + char const * c_str () const; + FILE* open (char const *); + void close (); + +private: + boost::filesystem::path _file; + FILE* _open; +}; #endif