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