Supporters update.
[dcpomatic.git] / src / lib / environment_info.cc
1 /*
2     Copyright (C) 2012-2021 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 #include "compose.hpp"
23 #include "cross.h"
24 #include "log.h"
25 #include "version.h"
26 #include <dcp/version.h>
27 #include <dcp/warnings.h>
28 #include <libssh/libssh.h>
29 LIBDCP_DISABLE_WARNINGS
30 extern "C" {
31 #include <libavcodec/avcodec.h>
32 #include <libavformat/avformat.h>
33 #include <libavfilter/avfilter.h>
34 #include <libswscale/swscale.h>
35 #include <libavutil/pixfmt.h>
36 }
37 LIBDCP_ENABLE_WARNINGS
38 #include <boost/thread.hpp>
39
40 #include "i18n.h"
41
42
43 using std::list;
44 using std::pair;
45 using std::shared_ptr;
46 using std::string;
47
48
49 /** @param v Version as used by FFmpeg.
50  *  @return A string representation of v.
51  */
52 static
53 string
54 ffmpeg_version_to_string (int v)
55 {
56         char buffer[64];
57         snprintf (buffer, sizeof(buffer), "%d.%d.%d", ((v & 0xff0000) >> 16), ((v & 0xff00) >> 8), (v & 0xff));
58         return buffer;
59 }
60
61
62 /** Return a user-readable string summarising the versions of our dependencies */
63 static
64 string
65 dependency_version_summary ()
66 {
67         char buffer[512];
68         snprintf (
69                 buffer, sizeof(buffer), "libavcodec %s, libavfilter %s, libavformat %s, libavutil %s, libswscale %s, libssh %s, libdcp %s git %s",
70                 ffmpeg_version_to_string(avcodec_version()).c_str(),
71                 ffmpeg_version_to_string(avfilter_version()).c_str(),
72                 ffmpeg_version_to_string(avformat_version()).c_str(),
73                 ffmpeg_version_to_string(avutil_version()).c_str(),
74                 ffmpeg_version_to_string(swscale_version()).c_str(),
75                 ssh_version(0),
76                 dcp::version, dcp::git_commit
77                 );
78
79         return buffer;
80 }
81
82
83 list<string>
84 environment_info ()
85 {
86         list<string> info;
87
88         info.push_back (String::compose ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()));
89
90         {
91                 char buffer[128];
92                 gethostname (buffer, sizeof (buffer));
93                 info.push_back (String::compose ("Host name %1", &buffer[0]));
94         }
95
96 #ifdef DCPOMATIC_DEBUG
97         info.push_back ("DCP-o-matic built in debug mode.");
98 #else
99         info.push_back ("DCP-o-matic built in optimised mode.");
100 #endif
101 #ifdef LIBDCP_DEBUG
102         info.push_back ("libdcp built in debug mode.");
103 #else
104         info.push_back ("libdcp built in optimised mode.");
105 #endif
106
107 #ifdef DCPOMATIC_WINDOWS
108         OSVERSIONINFO os_info;
109         os_info.dwOSVersionInfoSize = sizeof (os_info);
110         GetVersionEx (&os_info);
111         info.push_back (
112                 String::compose (
113                         "Windows version %1.%2.%3",
114                         (int) os_info.dwMajorVersion, (int) os_info.dwMinorVersion, (int) os_info.dwBuildNumber
115                         )
116                 );
117         if (os_info.dwMajorVersion == 5 && os_info.dwMinorVersion == 0) {
118                 info.push_back ("Windows 2000");
119         } else if (os_info.dwMajorVersion == 5 && os_info.dwMinorVersion == 1) {
120                 info.push_back ("Windows XP");
121         } else if (os_info.dwMajorVersion == 5 && os_info.dwMinorVersion == 2) {
122                 info.push_back ("Windows XP 64-bit or Windows Server 2003");
123         } else if (os_info.dwMajorVersion == 6 && os_info.dwMinorVersion == 0) {
124                 info.push_back ("Windows Vista or Windows Server 2008");
125         } else if (os_info.dwMajorVersion == 6 && os_info.dwMinorVersion == 1) {
126                 info.push_back ("Windows 7 or Windows Server 2008");
127         } else if (os_info.dwMajorVersion == 6 && (os_info.dwMinorVersion == 2 || os_info.dwMinorVersion == 3)) {
128                 info.push_back ("Windows 8 or Windows Server 2012");
129         } else if (os_info.dwMajorVersion == 10 && os_info.dwMinorVersion == 0) {
130                 info.push_back ("Windows 10 or Windows Server 2016");
131         }
132 #endif
133
134 #if __GNUC__
135 #if __x86_64__
136         info.push_back ("Built for x86 64-bit");
137 #elif __aarch64__
138         info.push_back ("Built for ARM 64-bit");
139 #else
140         info.push_back ("Built for x86 32-bit");
141 #endif
142 #endif
143
144         info.push_back (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency()));
145         for (auto const& i: mount_info()) {
146                 info.push_back (String::compose("Mount: %1 %2", i.first, i.second));
147         }
148
149         return info;
150 }