From: Carl Hetherington Date: Sun, 14 Apr 2013 13:08:57 +0000 (+0100) Subject: Re-add some missing files. X-Git-Tag: v2.0.48~1337^2~441 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=133afe16d6149effe39a061311d2832c30a77222 Re-add some missing files. --- diff --git a/dcpomatic.desktop.in b/dcpomatic.desktop.in new file mode 100644 index 000000000..aabd992f5 --- /dev/null +++ b/dcpomatic.desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Exec=@PREFIX@/bin/dcpomatic +Name=DCP-o-matic +Icon=dcpomatic +Comment=DCP generator +Categories=AudioVideo;Video diff --git a/doc/manual/dcpomatic-html.xsl b/doc/manual/dcpomatic-html.xsl new file mode 100644 index 000000000..144675d47 --- /dev/null +++ b/doc/manual/dcpomatic-html.xsl @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/doc/manual/dcpomatic-pdf.xml b/doc/manual/dcpomatic-pdf.xml new file mode 100644 index 000000000..414fb64b8 --- /dev/null +++ b/doc/manual/dcpomatic-pdf.xml @@ -0,0 +1,17 @@ + + + + +colorlinks,linkcolor=black,urlcolor=black + + +0 +0 + + +scale=0.6 + + +3 + + diff --git a/doc/manual/dcpomatic.css b/doc/manual/dcpomatic.css new file mode 100644 index 000000000..0e4982f20 --- /dev/null +++ b/doc/manual/dcpomatic.css @@ -0,0 +1,19 @@ +body { + font-family: luxi sans, sans-serif; + margin-left: 4em; + margin-right: 4em; + margin-top: 1em; + margin-bottom: 1em; + background-color: #E2E8EE; +} + +div.sidebar { + margin-left: 1em; + margin-right: 1em; + padding-left: 1em; + padding-right: 1em; + border-color: #000000; + border-width: 2px; + border-style: solid; + background-color: #E2E8EE; +} diff --git a/doc/manual/dcpomatic.sty b/doc/manual/dcpomatic.sty new file mode 100644 index 000000000..834e581fc --- /dev/null +++ b/doc/manual/dcpomatic.sty @@ -0,0 +1,68 @@ +%% +%% This style is derivated from the docbook one +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{ardour}[2007/04/04 My DocBook Style] + +%% Just use the original package and pass the options +\RequirePackageWithOptions{docbook} + +% Use a nice font +\usepackage{lmodern} + +% Define \dbend as the dangerous bend sign +\font\manual=manfnt +\def\dbend{{\manual\char127}} + +% Redefine sidebar environment to use the dangerous bend style +% Danger, Will Robinson! +\def\sidebar{\begin{trivlist}\item[]\noindent% +\begingroup\hangindent=2pc\hangafter=-2%\clubpenalty=10000% +\def\par{\endgraf\endgroup}% +\hbox to0pt{\hskip-\hangindent\dbend\hfill}\ignorespaces} +\def\endsidebar{\par\end{trivlist}} + + +% Futz with the title page; basically a copy of +% /usr/share/texmf/tex/latex/dblatex/style/dbk_title.sty +% with authors added. + +\def\DBKcover{ +\ifthenelse{\equal{\DBKedition}{}}{\def\edhead{}}{\def\edhead{Ed. \DBKedition}} + +\pagestyle{empty} + +% interligne double +\setlength{\oldbaselineskip}{\baselineskip} +\setlength{\baselineskip}{2\oldbaselineskip} +\textsf{ +\vfill +\vspace{2.5cm} +\begin{center} + \huge{\textbf{\DBKtitle}}\\ % + \ \\ % + \ \\ % + \Large{\DBKauthor}\\ % + \ifx\DBKsubtitle\relax\else% + \underline{\ \ \ \ \ \ \ \ \ \ \ }\\ % + \ \\ % + \huge{\textbf{\DBKsubtitle}}\\ % + \fi +\end{center} +\vfill +\setlength{\baselineskip}{\oldbaselineskip} +\hspace{1cm} +\vspace{1cm} +\begin{center} +\begin{tabular}{p{7cm} p{7cm}} +\Large{\DBKreference{} \edhead} & \\ +\end{tabular} +\end{center} +} + +% Format for the other pages +\newpage +\setlength{\baselineskip}{\oldbaselineskip} +%\chead[]{\DBKcheadfront} +\lfoot[]{} +} diff --git a/doc/manual/dcpomatic.xml b/doc/manual/dcpomatic.xml new file mode 100644 index 000000000..ee7b96083 --- /dev/null +++ b/doc/manual/dcpomatic.xml @@ -0,0 +1,932 @@ + + + + +%dbcent; + +%extensions; +]> + + + +DCP-o-matic +CarlHetherington + + + +Introduction + + +Hello, and welcome to DCP-o-matic! + + +
+What is DCP-o-matic? + + +DCP-o-matic is a program to generate Digital +Cinema Packages (DCPs) from DVDs, Blu-Rays, video files such as MP4 +and AVI, or still images. The resulting DCPs will play on modern digital +cinema projectors. + + + +You might find it useful to make DVDs easier to present, to encode +independently-shot feature films, or to generate local advertising for +your cinema. + + +
+ +
+Licence + + +DCP-o-matic is licensed under the GNU GPL. + + +
+ +
+ + +Installation + +
+Windows + + +To install DCP-o-matic on Windows, simply download the installer from +http://carlh.net +and double-click it. Click through the installer wizard, and +DCP-o-matic will be installed onto your machine. + + + +If you are using a 32-bit version of Windows, you will need the 32-bit +installer. For 64-bit Windows, either installer will work, but I +suggest you used the 64-bit version as it will allow DCP-o-matic to +use more memory. You may find that DCP-o-matic crashes if you run +many parallel encoding threads (more than 4) on the 32-bit +version. + + +
+ +
+Ubuntu Linux + + +You can install DCP-o-matic on Ubuntu 12.04 (‘Precise +Pangolin’) or 12.10 (‘Quantal Quetzal’) using +.deb packages: download the appropriate package from +http://carlh.net and +double-click it. Ubuntu will install the necessary bits and pieces +and set DCP-o-matic up for you. + + +
+ +
+Other Linux distributions + + +Installation on non-Ubuntu Linux is currently a little involved, as +there are no packages available (yet); you will have to compile it +from source. If you are using a non-Ubuntu distribution, do let me +know via the mailing +list and I will see about building some packages. + + + +The following dependencies are required: + +FFmpeg +libsndfile +OpenSSL +libopenjpeg +ImageMagick +Boost +libssh +GTK +wxWidgets +libdcp + + + + +Once you have installed the development packages for the dependencies, +download the source code from http://carlh.net, +unpack it and run the following commands from inside the source +directory: + + + +./waf configure +./waf build +sudo ./waf install + + + +With any luck, this will build and install DCP-o-matic on your system. To run it, enter: + + + +dcpomatic + + + +in a shell. + + +
+
+ + +Creating a video DCP + + +In this chapter we will see how to create a video DCP using +DCP-o-matic. We will gloss over some of the finer details, which are +explained in later chapters. + + +
+Creating a new film + + +Let's make a very simple DCP to see how DCP-o-matic works. First, we +need some content. Download the low-resolution trailer for the open +movie Sintel from their +website. Generally, of course, one would want to use the +highest-resolution material available, but for this test we will use +the low-resolution version to save everyone's bandwidth bills. + + + +Now, start DCP-o-matic and its window will open. First, we will +create a new ‘film’. A ‘film’ is how DCP-o-matic refers to +a piece of content, along with some settings, which we will make into +a DCP. DCP-o-matic stores its data in a folder on your disk while it +creates the DCP. You can create a new film by selecting +New from the File menu, as +shown in . + + +
+ Creating a new film + + + + + +
+ + +This will open a dialogue box for the new film, as shown in . + + +
+ Dialogue box for creating a new film + + + + + +
+ + +In this dialogue box you can choose a name for the film. This will be +used to name the folder to store its data in, and also as the initial +name for the DCP itself. You can also choose whereabouts you want to create +the film. In the example from the figure, DCP-o-matic will create a +folder called ‘DCP Test’ inside my home folder (carl) into which it +will write its working files. + + + +If you always create your DCPs in a particular folder, you can use +DCP-o-matic's Preferences to make life a little +easier by setting the default folder that DCP-o-matic will offer in this dialogue. +See . + + +
+ +
+Selecting content + + +The next step is to set the content that you want to use. Click the +content selector, as shown in , and a file chooser will +open for you to select the content file to use, as shown in . + + +
+ Opening the content selector + + + + + +
+ +
+ Selecting a video content file + + + + + +
+ + +Select your content file and click Open. In this +case we are using the Sintel trailer that we downloaded earlier. + + + +When you do this, DCP-o-matic will take a look at your file. After a +short while (when the progress bar at the bottom right of the window +has finished), you can look through your content using the slider to +the right of the window, as shown in . + + +
+ Examining the content + + + + + +
+ + +Dragging the slider will move through your video. You can also click +the Play button to play the content back. Note +that there will be no sound, and playback might not be entirely +accurate (it may be slightly slower or faster than it should be, for +example). This player is really only intended for brief inspection of +content; if you need to check it more thoroughly, use another player +such as Totem, mplayer or VLC. + + +
+ +
+Setting up + + +Now there are a few things to set up to describe how the DCP should be +created. The settings are divided into four tabs: film, video, audio and subtitles. + + +
+Film tab + + +The ‘film’ tab contains settings that pertain to the whole film, as shown in . + + +
+ Film settings tab + + + + + +
+ + +The first thing here is the name. This is generally set to the title +of the film that is being encoded. If Use DCI +name is not ticked, the name that you specify will be used +as-is for the name of the DCP. If Use DCI name +is ticked, the name that you enter will be used as part of a +DCI-compliant name. + + + +Underneath the name field is a preview of the name that the DCP will +get. To use a DCI-compliant name, tick the Use DCI +name checkbox. The DCI name will be composed using details +of your content's soundtrack, the current date and other things that +can be specified in the DCI name details dialogue box, which you can +open by clicking on the Details button. + + + +If the DCP name is long, it may not all be visible. You can see the +full name by hovering the mouse pointer over the partial name. + + + +The Trust content's header button starts off +checked, and this means that DCP-o-matic will use the content's header +information to determine its length. If, for some reason, this header +length is wrong, uncheck the Trust content's +header button and DCP-o-matic will run through the content +to find its exact length. This may take a while for large pieces of content. + + + +Next up is the content type. This can be +‘feature’, ‘trailer’ or whatever; select the +required type from the drop-down list. + + + +The trim frames settings allow you to trim frames +from the beginning and end of the content; any trimmed frames will not +be included in the DCP. + + +
+ +
+Video tab + + +This tab contains settings related to the picture in your DCP, as shown in . + + +
+ Video settings tab + + + + + +
+ + +The first option on this tab is the format. This will govern the +shape that DCP-o-matic will make your image into. Select the aspect +ratio that your content should be presented in. The ‘4:3 within +Flat’ and ‘16:9 within Flat’ settings will put the +image at the specified ratio within a Flat (1.85:1) frame, so that you +can project the DCP using your projector's Flat preset. + + + +The remaining options can often be left alone, but may sometimes be +useful. The ‘crop’ settings can be used to crop your +content, which can be used to remove black borders from round the +edges of DVD images, for example. The specified number of pixels will +be trimmed from each edge, and the content image in the right of the +window will be updated to show the effect of the crop. + + + +The ‘filters’ settings allow you to apply various video +filters to the image. These may be useful to try to improve +poor-quality sources like DVDs. We will discuss filtering later in the manual. + + + + +The ‘scaler’ is the method that will be used to scale up +your content to the required size for the DCP, if required. We will +discuss the options in more detail later; Bicubic is a fine choice in +most situations. + + + + +The ‘colour look-up table’ specifies the colour space that +your input content will be expected to be in. If in doubt, leave it +set to ‘sRGB’. + + + +Finally, the ‘JPEG2000 bandwidth’ setting changes how big the final +image files used within the DCP will be. Larger numbers will give +better quality, but correspondingly larger DCPs. The bandwidth can be +between 50 and 250 megabits per second (MBps). + + +
+ +
+Audio tab + + +This tab contains settings related to the sound in your DCP, as shown in . + + +
+ Audio settings tab + + + + + +
+ + + +‘Audio Gain’ is used to alter the volume of the +soundtrack. The specified gain (in dB) will be applied to each sound +channel before it is written to the DCP. + + + +If you use a sound processor that DCP-o-matic knows about, it can help +you calculate changes in gain that you should apply. Say, for +example, that you make a test DCP and find that you have to run it at +volume 5 instead of volume 7 to get a good sound level in the screen. +If this is the case, click the Calculate... +button next to the audio gain entry, and the dialogue box in will open. + + +
+ Calculating audio gain + + + + + +
+ + +For our example, put 5 in the first box and 7 in the second and click +OK. DCP-o-matic will calculate the audio gain +that it should apply to make this happen. Then you can re-make the +DCP (this will be reasonably fast, as the video data will already have +been done) and it should play back at the correct volume with 7 on +your sound-rack fader. + + + +Current versions of DCP-o-matic only know about the Dolby CP750. If +you use a different sound processor, and know the gain curve of its +volume control, get in +touch. + + + +‘Audio Delay’ is used to adjust the synchronisation +between audio and video. A positive delay will move the audio later +with respect to the video, and a negative delay will move it earlier. + + + +By default the Use content‘s audio button +will be selected. This means that the DCP will use one of the +soundtracks from your content file; you can select the soundtrack that +you wish to use from the drop-down box. + + + +Note that if your content's audio is mono, DCP-o-matic will place it +in the centre channel in the DCP. + + + +Alternatively, you can supply different sound files by clicking the +Use external audio button and choosing a WAV file +for any channels that you want to appear in the DCP. These files can +be any bit depth and sampling rate, and will be re-sampled and +bit-depth converted if required. + + +
+
+Subtitles tab + + +This tab contains settings related to subtitles in your DCP, as shown in . + + +
+ Subtitle settings tab + + + + + +
+ + +DCP-o-matic will extract subtitles from the content, if present, and +they can be ‘burnt into’ the DCP (that is, they are +included in the image and not overlaid by the projector). Note that +DVD and Blu-Ray subtitles are stored as bitmaps, so it is not possible +(automatically) to use non-burnt-in subtitles with these sources. +Select the With Subtitles checkbox to enable +subtitles. The offset control moves the +subtitles up and down the image, and the scale +control changes their size. + + + +Future versions of DCP-o-matic will hopefully include the option to +use text subtitles (as is the norm with most professionally-mastered +DCPs). + + +
+
+ +
+Making the DCP + + +Now that we have set everything up, choose Make +DCP from the Jobs menu. DCP-o-matic +will encode your DCP. This may take some time (many hours in some +cases). While the job is in progress, DCP-o-matic will update you on +how it is getting on with the progress bar in the bottom of its window, as shown in . + + +
+ Making the DCP + + + + + +
+ + +When it has finished, the DCP will end up on your disk inside the +film's directory. You can then copy this to a projector via a USB +stick, hard-drive or network connection. + + + +Alternatively, if you have a projector or TMS that is accessible via +SCP across your network, you can upload the content directly from +DCP-o-matic. See . + + +
+
+ + + +Creating a still-image DCP + + +DCP-o-matic can also be used to create DCPs of a still image, perhaps +for an advertisement or an on-screen announcement. This chapter shows you +how to do it. + + + +As with video DCPs, the first step is to create a new +‘Film’; select New from the +File menu and the new film dialogue will open as +shown in . + + +
+ Dialogue box for creating a new film + + + + + +
+ + +Enter a name and click OK. Then we set up the +content; click the content selector as before, and this time we will +choose an image file, as shown in . + + +
+ Selecting a still content file + + + + + +
+ + +Setting up for a still image DCP is somewhat simpler than for a video; +the tabs are all the same, but many options are removed and a few are added. + + + +As with video, you can select a content type and the format (ratio) +that your image should be presented in. It will be scaled and padded +to fit the selected ratio, but in such a way that the pixel aspect +ratio is preserved. In other words, the image will not be stretched, +merely scaled; if you want to stretch your image, you will need to do +so in a separate program before importing it into DCP-o-matic. You +can also crop your image, if you so choose, and then set a duration +(in seconds) that the image should appear on screen. + + + +Still-image DCPs can include sound; this can be added from the +Audio tab. If your specified duration is shorter +than the audio, the audio will be cut off at the duration; if it is +longer, silence will be added after your audio. + + + +Finally, as with video, you can choose Make DCP +from the Jobs menu to create your DCP. This will +be much quicker than creating a video DCP, as DCP-o-matic only needs +to encode a single frame which it can then repeat. + + +
+ + + +Preferences + + +DCP-o-matic provides a few preferences which can be used to modify its +behaviour. This chapter explains those options. + + +
+The preferences dialogue + + +The preferences dialogue is opened by choosing +Preferences... from the Edit +menu. The dialogue is shown in . + + +
+ Preferences + + + + + +
+ +
+TMS setup + + +The first part of the dialogue gives some options for specifying +details about your TMS. If you do this, and your TMS accepts SSH +connections, you can upload DCPs directly from DCP-o-matic to the TMS. +This is discussed in . + + + +TMS IP address should be set to the IP address of +your TMS, TMS target path to the place that DCPs +should be uploaded to (which will be relative to the home directory of +the SSH user). Finally, the user name and password are the +credentials required to log into the TMS via SSH. + +
+ +
+Threads + + +When DCP-o-matic is encoding DCPs it can use multiple parallel threads +to speed things up. Set this value to the number of threads +DCP-o-matic should use. This would typically be set to the number of +processors (or processor cores) in your machine. + + +
+ +
+Default directory for new films + + +This is the directory which DCP-o-matic will suggest initially as a place to put new films. + + +
+ +
+A/B options + + +These options are for DCP-o-matic's special mode of making A/B +comparison DCPs for checking the performance of video filters. Their +use is described in . + + +
+ +
+Encoding servers + + +If you have spare machines sitting around on your network not doing +much, they can be pressed into service to speed up DCP encodes. This +is done by running a small server program on the machine, which will +encode video sent to it by the ‘master’ DCP-o-matic. This +option is described in more detail in . +Use these preferences to specify the encoding servers that should be +used. + + +
+ +
+
+ + +Advanced topics + +This chapter describes some parts of DCP-o-matic that are +probably not essential, but which you might find useful in some +circumstances. + + +
+Filtering + + +DCP-o-matic offers a variety of filters that can be applied to your +video content. You can set up the filters by clicking the +Edit button next to the filters entry in the +setup area of the DCP-o-matic window; this opens the filters selector +as shown in . + + +
+ Filters selector + + + + + +
+ + +After changing the filters setup, you will need to regenerate the DCP +to see the effect on the cinema screen. The preview in DCP-o-matic +will update itself whenever filters are changed, though of course this +image is much smaller and of lower resolution than a projected image! + + +
+ +
+Scaling + + +If your source material is not of the DCI-specified size, or if it +uses non-square pixels, DCP-o-matic will need to scale it. The +algorithm used to scale is set up by the Scaler +entry in the film setup area. We think ‘Bicubic’ is the +best all-round option, but tests are ongoing. + + +
+ +
+TMS upload + + +If you have configured details of a TMS in the preferences dialogue +() you can upload a completed DCP +straight to your TMS buy choosing Send DCP to TMS +from the Jobs menu. + + +
+ + +
+A/B comparison + + +When evaluating the effects of different filters or scalers on the +image quality, A/B mode might be useful. In this mode, DCP-o-matic +will generate a DCP where the left half of the image uses some +‘reference’ filtering and scaling, and the right half of +the image uses a different set of filters and a different scaler. +This DCP can then be played back on a projector and the image quality +evaluated. + + + +To enable A/B mode, click the A/B checkbox in the setup area of the +DCP-o-matic window. When you generate your DCP, the left half of the +screen will use the filters and scaler specified in the preferences dialogue, and the right +half will use the filters and scaler specified in the film setup. + + +
+ +
+Encoding servers + + +One way to increase the speed of DCP encoding is to use more +than one machine at the same time. An instance of DCP-o-matic can +offload some of the time-consuming JPEG2000 encoding to any number of +other machines on a network. To do this, one ‘master’ +machine runs DCP-o-matic, and the ‘server’ machines run +a small program called ‘servomatic’. + + +
+Running the servers + + +There are two options for the encoding server; +servomatic_cli, which runs on the command line, and +servomatic_gui, which has a simple GUI. The command line +version is well-suited to headless servers, especially on Linux, and +the GUI version works best on Windows where it will put an icon in the +system tray. + + + +To run the command line version, simply enter: + + + +servomatic_cli + + + +at a command prompt. If you are running the program on a machine with +a multi-core processor, you can run multiple parallel encoding threads +by doing something like: + + + +servomatic_cli -t 4 + + + +to run 4 threads in parallel. + + + +To run the GUI version on windows, run the ‘DCP-o-matic encode +server’ from the start menu. An icon will appear in the system +tray; right-click it to open a menu from whence you can quit the +server or open a window to show its status. + + +
+
+Setting up DCP-o-matic + + +Once your servers are running, you need to tell your master +DCP-o-matic instance about them. Start DCP-o-matic and open the +Preferences dialog from the +Edit menu. At the bottom of this dialog is a +section where you can add, edit and remove encoding servers. For each +encoding server you need only specify its IP address and the number of +threads that it is running, so that DCP-o-matic knows how many +parallel encode jobs to send to the server. + + + +Once this is done, any encodes that you start will split the workload +up between the master machine and the servers. + + +
+
+Some notes about encode servers + + +DCP-o-matic does not mind if servers come and go; if a server +disappears, DCP-o-matic will stop sending work to it, and will check +it every minute or so in case it has come back online. + + + +You will probably find that using a 1Gb/s or faster network will +provide a significant speed-up compared to a 100Mb/s network. + + + +Making changes to the server configuration in the master DCP-o-matic +will have no effect while an encode is running; the changes will only +be noticed when a new encode is started. + + +
+
+ +
+ + +
diff --git a/icons/128x128/dcpomatic.png b/icons/128x128/dcpomatic.png new file mode 100644 index 000000000..9936b39af Binary files /dev/null and b/icons/128x128/dcpomatic.png differ diff --git a/icons/16x16/dcpomatic.png b/icons/16x16/dcpomatic.png new file mode 100644 index 000000000..3c5a10f2d Binary files /dev/null and b/icons/16x16/dcpomatic.png differ diff --git a/icons/22x22/dcpomatic.png b/icons/22x22/dcpomatic.png new file mode 100644 index 000000000..dddb86298 Binary files /dev/null and b/icons/22x22/dcpomatic.png differ diff --git a/icons/32x32/dcpomatic.png b/icons/32x32/dcpomatic.png new file mode 100644 index 000000000..8cecf08f8 Binary files /dev/null and b/icons/32x32/dcpomatic.png differ diff --git a/icons/48x48/dcpomatic.png b/icons/48x48/dcpomatic.png new file mode 100644 index 000000000..07bf2d10b Binary files /dev/null and b/icons/48x48/dcpomatic.png differ diff --git a/icons/64x64/dcpomatic.png b/icons/64x64/dcpomatic.png new file mode 100644 index 000000000..35564a8a2 Binary files /dev/null and b/icons/64x64/dcpomatic.png differ diff --git a/run/dcpomatic b/run/dcpomatic new file mode 100755 index 000000000..7ea08778c --- /dev/null +++ b/run/dcpomatic @@ -0,0 +1,15 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:$LD_LIBRARY_PATH +if [ "$1" == "--debug" ]; then + shift + gdb --args build/src/tools/dcpomatic $* +elif [ "$1" == "--valgrind" ]; then + shift + valgrind --tool="memcheck" build/src/tools/dcpomatic $* +elif [ "$1" == "--i18n" ]; then + shift + LANGUAGE=fr_FR.UTF8 LANG=fr_FR.UTF8 build/src/tools/dcpomatic "$*" +else + build/src/tools/dcpomatic $* +fi diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc new file mode 100644 index 000000000..ee9f9977c --- /dev/null +++ b/src/tools/dcpomatic.cc @@ -0,0 +1,578 @@ +/* + Copyright (C) 2012 Carl Hetherington + + This program 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, + 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. + +*/ + +#include +#include +#ifdef __WXMSW__ +#include +#endif +#include +#include +#include +#include "wx/film_viewer.h" +#include "wx/film_editor.h" +#include "wx/job_manager_view.h" +#include "wx/config_dialog.h" +#include "wx/job_wrapper.h" +#include "wx/wx_util.h" +#include "wx/new_film_dialog.h" +#include "wx/properties_dialog.h" +#include "wx/wx_ui_signaller.h" +#include "lib/film.h" +#include "lib/format.h" +#include "lib/config.h" +#include "lib/filter.h" +#include "lib/util.h" +#include "lib/scaler.h" +#include "lib/exceptions.h" +#include "lib/version.h" +#include "lib/ui_signaller.h" +#include "lib/log.h" + +using std::cout; +using std::string; +using std::wstring; +using std::stringstream; +using std::map; +using std::make_pair; +using std::exception; +using boost::shared_ptr; + +static FilmEditor* film_editor = 0; +static FilmViewer* film_viewer = 0; +static shared_ptr film; +static std::string log_level; +static std::string film_to_load; +static std::string film_to_create; +static wxMenu* jobs_menu = 0; +static wxLocale* locale = 0; + +static void set_menu_sensitivity (); + +class FilmChangedDialog +{ +public: + FilmChangedDialog () + { + _dialog = new wxMessageDialog ( + 0, + wxString::Format (_("Save changes to film \"%s\" before closing?"), std_to_wx (film->name ()).data()), + _("Film changed"), + wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION + ); + } + + ~FilmChangedDialog () + { + _dialog->Destroy (); + } + + int run () + { + return _dialog->ShowModal (); + } + +private: + wxMessageDialog* _dialog; +}; + + +void +maybe_save_then_delete_film () +{ + if (!film) { + return; + } + + if (film->dirty ()) { + FilmChangedDialog d; + switch (d.run ()) { + case wxID_NO: + break; + case wxID_YES: + film->write_metadata (); + break; + } + } + + film.reset (); +} + +enum Sensitivity { + ALWAYS, + NEEDS_FILM +}; + +map menu_items; + +void +add_item (wxMenu* menu, wxString text, int id, Sensitivity sens) +{ + wxMenuItem* item = menu->Append (id, text); + menu_items.insert (make_pair (item, sens)); +} + +void +set_menu_sensitivity () +{ + for (map::iterator i = menu_items.begin(); i != menu_items.end(); ++i) { + if (i->second == NEEDS_FILM) { + i->first->Enable (film != 0); + } else { + i->first->Enable (true); + } + } +} + +enum { + ID_file_new = 1, + ID_file_open, + ID_file_save, + ID_file_properties, + ID_file_quit, + ID_edit_preferences, + ID_jobs_make_dcp, + ID_jobs_send_dcp_to_tms, + ID_jobs_show_dcp, + ID_jobs_analyse_audio, + ID_help_about +}; + +void +setup_menu (wxMenuBar* m) +{ + wxMenu* file = new wxMenu; + add_item (file, _("New..."), ID_file_new, ALWAYS); + add_item (file, _("&Open..."), ID_file_open, ALWAYS); + file->AppendSeparator (); + add_item (file, _("&Save"), ID_file_save, NEEDS_FILM); + file->AppendSeparator (); + add_item (file, _("&Properties..."), ID_file_properties, NEEDS_FILM); + file->AppendSeparator (); + add_item (file, _("&Quit"), ID_file_quit, ALWAYS); + + wxMenu* edit = new wxMenu; + add_item (edit, _("&Preferences..."), ID_edit_preferences, ALWAYS); + + jobs_menu = new wxMenu; + add_item (jobs_menu, _("&Make DCP"), ID_jobs_make_dcp, NEEDS_FILM); + add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM); + add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM); + jobs_menu->AppendSeparator (); + add_item (jobs_menu, _("&Analyse audio"), ID_jobs_analyse_audio, NEEDS_FILM); + + wxMenu* help = new wxMenu; + add_item (help, _("About"), ID_help_about, ALWAYS); + + m->Append (file, _("&File")); + m->Append (edit, _("&Edit")); + m->Append (jobs_menu, _("&Jobs")); + m->Append (help, _("&Help")); +} + +bool +window_closed (wxCommandEvent &) +{ + maybe_save_then_delete_film (); + return false; +} + +class Frame : public wxFrame +{ +public: + Frame (wxString const & title) + : wxFrame (NULL, -1, title) + { + wxMenuBar* bar = new wxMenuBar; + setup_menu (bar); + SetMenuBar (bar); + + Connect (ID_file_new, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_new)); + Connect (ID_file_open, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_open)); + Connect (ID_file_save, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_save)); + Connect (ID_file_properties, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_properties)); + Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit)); + Connect (ID_edit_preferences, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::edit_preferences)); + Connect (ID_jobs_make_dcp, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp)); + Connect (ID_jobs_send_dcp_to_tms, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_send_dcp_to_tms)); + Connect (ID_jobs_show_dcp, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_show_dcp)); + Connect (ID_jobs_analyse_audio, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_analyse_audio)); + Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about)); + + Connect (wxID_ANY, wxEVT_MENU_OPEN, wxMenuEventHandler (Frame::menu_opened)); + + wxPanel* panel = new wxPanel (this); + wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + s->Add (panel, 1, wxEXPAND); + SetSizer (s); + + film_editor = new FilmEditor (film, panel); + film_viewer = new FilmViewer (film, panel); + JobManagerView* job_manager_view = new JobManagerView (panel); + + _top_sizer = new wxBoxSizer (wxHORIZONTAL); + _top_sizer->Add (film_editor, 0, wxALL, 6); + _top_sizer->Add (film_viewer, 1, wxEXPAND | wxALL, 6); + + wxBoxSizer* main_sizer = new wxBoxSizer (wxVERTICAL); + main_sizer->Add (_top_sizer, 2, wxEXPAND | wxALL, 6); + main_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6); + panel->SetSizer (main_sizer); + + set_menu_sensitivity (); + + film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1)); + if (film) { + file_changed (film->directory ()); + } else { + file_changed (""); + } + + set_film (); + + film_editor->Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (Frame::film_editor_sized), 0, this); + } + +private: + + void film_editor_sized (wxSizeEvent &) + { + static bool in_layout = false; + if (!in_layout) { + in_layout = true; + _top_sizer->Layout (); + in_layout = false; + } + } + + void menu_opened (wxMenuEvent& ev) + { + if (ev.GetMenu() != jobs_menu) { + return; + } + + bool const have_dcp = film && film->have_dcp(); + jobs_menu->Enable (ID_jobs_send_dcp_to_tms, have_dcp); + jobs_menu->Enable (ID_jobs_show_dcp, have_dcp); + } + + void set_film () + { + film_viewer->set_film (film); + film_editor->set_film (film); + set_menu_sensitivity (); + } + + void file_changed (string f) + { + stringstream s; + s << wx_to_std (_("DCP-o-matic")); + if (!f.empty ()) { + s << " - " << f; + } + + SetTitle (std_to_wx (s.str())); + } + + void file_new (wxCommandEvent &) + { + NewFilmDialog* d = new NewFilmDialog (this); + int const r = d->ShowModal (); + + if (r == wxID_OK) { + + if (boost::filesystem::exists (d->get_path())) { + error_dialog (this, std_to_wx (String::compose (wx_to_std (_("The directory %1 already exists.")), d->get_path().c_str()))); + return; + } + + maybe_save_then_delete_film (); + film.reset (new Film (d->get_path (), false)); + film->log()->set_level (log_level); + film->set_name (boost::filesystem::path (d->get_path()).filename().generic_string()); + set_film (); + } + + d->Destroy (); + } + + void file_open (wxCommandEvent &) + { + wxDirDialog* c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + int r; + while (1) { + r = c->ShowModal (); + if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { + error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open.")); + } else { + break; + } + } + + if (r == wxID_OK) { + maybe_save_then_delete_film (); + try { + film.reset (new Film (wx_to_std (c->GetPath ()))); + film->log()->set_level (log_level); + set_film (); + } catch (std::exception& e) { + wxString p = c->GetPath (); + wxCharBuffer b = p.ToUTF8 (); + error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data())); + } + } + + c->Destroy (); + } + + void file_save (wxCommandEvent &) + { + film->write_metadata (); + } + + void file_properties (wxCommandEvent &) + { + PropertiesDialog* d = new PropertiesDialog (this, film); + d->ShowModal (); + d->Destroy (); + } + + void file_quit (wxCommandEvent &) + { + maybe_save_then_delete_film (); + Close (true); + } + + void edit_preferences (wxCommandEvent &) + { + ConfigDialog* d = new ConfigDialog (this); + d->ShowModal (); + d->Destroy (); + Config::instance()->write (); + } + + void jobs_make_dcp (wxCommandEvent &) + { + JobWrapper::make_dcp (this, film); + } + + void jobs_send_dcp_to_tms (wxCommandEvent &) + { + film->send_dcp_to_tms (); + } + + void jobs_show_dcp (wxCommandEvent &) + { +#ifdef __WXMSW__ + string d = film->directory(); + wstring w; + w.assign (d.begin(), d.end()); + ShellExecute (0, L"open", w.c_str(), 0, 0, SW_SHOWDEFAULT); +#else + int r = system ("which nautilus"); + if (WEXITSTATUS (r) == 0) { + system (string ("nautilus " + film->directory()).c_str ()); + } else { + int r = system ("which konqueror"); + if (WEXITSTATUS (r) == 0) { + system (string ("konqueror " + film->directory()).c_str ()); + } + } +#endif + } + + void jobs_analyse_audio (wxCommandEvent &) + { + film->analyse_audio (); + } + + void help_about (wxCommandEvent &) + { + wxAboutDialogInfo info; + info.SetName (_("DCP-o-matic")); + if (strcmp (dcpomatic_git_commit, "release") == 0) { + info.SetVersion (std_to_wx (String::compose ("version %1", dcpomatic_version))); + } else { + info.SetVersion (std_to_wx (String::compose ("version %1 git %2", dcpomatic_version, dcpomatic_git_commit))); + } + info.SetDescription (_("Free, open-source DCP generation from almost anything.")); + info.SetCopyright (_("(C) 2012-2013 Carl Hetherington, Terrence Meiczinger, Paul Davis, Ole Laursen")); + + wxArrayString authors; + authors.Add (wxT ("Carl Hetherington")); + authors.Add (wxT ("Terrence Meiczinger")); + authors.Add (wxT ("Paul Davis")); + authors.Add (wxT ("Ole Laursen")); + info.SetDevelopers (authors); + + wxArrayString translators; + translators.Add (wxT ("Olivier Perriere")); + translators.Add (wxT ("Lilian Lefranc")); + translators.Add (wxT ("Thierry Journet")); + translators.Add (wxT ("Massimiliano Broggi")); + translators.Add (wxT ("Manuel AC")); + translators.Add (wxT ("Adam Klotblixt")); + info.SetTranslators (translators); + + info.SetWebSite (wxT ("http://carlh.net/software/dcpomatic")); + wxAboutBox (info); + } + + wxSizer* _top_sizer; +}; + +#if wxMINOR_VERSION == 9 +static const wxCmdLineEntryDesc command_line_description[] = { + { wxCMD_LINE_OPTION, "l", "log", "set log level (silent, verbose or timing)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 } +}; +#else +static const wxCmdLineEntryDesc command_line_description[] = { + { wxCMD_LINE_OPTION, wxT("l"), wxT("log"), wxT("set log level (silent, verbose or timing)"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_SWITCH, wxT("n"), wxT("new"), wxT("create new film"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_PARAM, 0, 0, wxT("film to load or create"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_NONE, wxT(""), wxT(""), wxT(""), wxCmdLineParamType (0), 0 } +}; +#endif + +void +setup_i18n () +{ + int language = wxLANGUAGE_DEFAULT; + + if (Config::instance()->language()) { + wxLanguageInfo const * li = wxLocale::FindLanguageInfo (std_to_wx (Config::instance()->language().get())); + if (li) { + language = li->Language; + } + } + + if (wxLocale::IsAvailable (language)) { + locale = new wxLocale (language, wxLOCALE_LOAD_DEFAULT); + +#ifdef DCPOMATIC_WINDOWS + locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); +#endif + + locale->AddCatalog (wxT ("libdcpomatic-wx")); + locale->AddCatalog (wxT ("dcpomatic")); + + if (!locale->IsOk()) { + delete locale; + locale = new wxLocale (wxLANGUAGE_ENGLISH); + language = wxLANGUAGE_ENGLISH; + } + } + + if (locale) { + dcpomatic_setup_i18n (wx_to_std (locale->GetCanonicalName ())); + } +} + +class App : public wxApp +{ + bool OnInit () + { + if (!wxApp::OnInit()) { + return false; + } + +#ifdef DCPOMATIC_POSIX + unsetenv ("UBUNTU_MENUPROXY"); +#endif + + wxInitAllImageHandlers (); + + /* Enable i18n; this will create a Config object + to look for a force-configured language. This Config + object will be wrong, however, because dcpomatic_setup + hasn't yet been called and there aren't any scalers, filters etc. + set up yet. + */ + setup_i18n (); + + /* Set things up, including scalers / filters etc. + which will now be internationalised correctly. + */ + dcpomatic_setup (); + + /* Force the configuration to be re-loaded correctly next + time it is needed. + */ + Config::drop (); + + if (!film_to_load.empty() && boost::filesystem::is_directory (film_to_load)) { + try { + film.reset (new Film (film_to_load)); + film->log()->set_level (log_level); + } catch (exception& e) { + error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), film_to_load, e.what()))); + } + } + + if (!film_to_create.empty ()) { + film.reset (new Film (film_to_create, false)); + film->log()->set_level (log_level); + film->set_name (boost::filesystem::path (film_to_create).filename().generic_string ()); + } + + Frame* f = new Frame (_("DCP-o-matic")); + SetTopWindow (f); + f->Maximize (); + f->Show (); + + ui_signaller = new wxUISignaller (this); + this->Connect (-1, wxEVT_IDLE, wxIdleEventHandler (App::idle)); + + return true; + } + + void OnInitCmdLine (wxCmdLineParser& parser) + { + parser.SetDesc (command_line_description); + parser.SetSwitchChars (wxT ("-")); + } + + bool OnCmdLineParsed (wxCmdLineParser& parser) + { + if (parser.GetParamCount() > 0) { + if (parser.Found (wxT ("new"))) { + film_to_create = wx_to_std (parser.GetParam (0)); + } else { + film_to_load = wx_to_std (parser.GetParam(0)); + } + } + + wxString log; + if (parser.Found (wxT ("log"), &log)) { + log_level = wx_to_std (log); + } + + return true; + } + + void idle (wxIdleEvent &) + { + ui_signaller->ui_idle (); + } +}; + +IMPLEMENT_APP (App) diff --git a/windows/dcpomatic.bmp b/windows/dcpomatic.bmp new file mode 100644 index 000000000..0a196f7a0 Binary files /dev/null and b/windows/dcpomatic.bmp differ diff --git a/windows/dcpomatic.ico b/windows/dcpomatic.ico new file mode 100644 index 000000000..225008cfe Binary files /dev/null and b/windows/dcpomatic.ico differ diff --git a/windows/dcpomatic.rc b/windows/dcpomatic.rc new file mode 100644 index 000000000..3963873bc --- /dev/null +++ b/windows/dcpomatic.rc @@ -0,0 +1,3 @@ +id ICON "dcpomatic.ico" +taskbar_icon ICON "dcpomatic_taskbar.ico" +#include "wx-2.9/wx/msw/wx.rc" diff --git a/windows/dcpomatic_taskbar.ico b/windows/dcpomatic_taskbar.ico new file mode 100644 index 000000000..f4489fa14 Binary files /dev/null and b/windows/dcpomatic_taskbar.ico differ