Add Content::set_paths().
[dcpomatic.git] / src / lib / cross.cc
index 4e801f44cb4940fb1667ffd897b6de57ba93dc9f..831a1a2b2b0c2e1913646834d420c5e53c67b18c 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
@@ -21,6 +22,9 @@
 #include "compose.hpp"
 #include "log.h"
 #include "exceptions.h"
+extern "C" {
+#include <libavformat/avio.h>
+}
 #include <boost/algorithm/string.hpp>
 #ifdef DCPOMATIC_LINUX
 #include <unistd.h>
@@ -395,3 +399,28 @@ start_batch_converter (boost::filesystem::path dcpomatic)
        CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info);
 #endif
 }
+
+uint64_t
+thread_id ()
+{
+#ifdef DCPOMATIC_WINDOWS
+       return (uint64_t) GetCurrentThreadId ();
+#else
+       return (uint64_t) pthread_self ();
+#endif
+}
+
+int
+avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
+{
+#ifdef DCPOMATIC_WINDOWS
+       int const length = (file.string().length() + 1) * 2;
+       char* utf8 = new char[length];
+       WideCharToMultiByte (CP_UTF8, 0, file.c_str(), -1, utf8, length, 0, 0);
+       int const r = avio_open (s, utf8, flags);
+       delete[] utf8;
+       return r;
+#else
+       return avio_open (s, file.c_str(), flags);
+#endif
+}