Handle multiple audio streams in a single piece of content
[dcpomatic.git] / src / wx / dcp_panel.cc
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "dcp_panel.h"
21 #include "wx_util.h"
22 #include "key_dialog.h"
23 #include "isdcf_metadata_dialog.h"
24 #include "lib/ratio.h"
25 #include "lib/config.h"
26 #include "lib/dcp_content_type.h"
27 #include "lib/util.h"
28 #include "lib/film.h"
29 #include "lib/ffmpeg_content.h"
30 #include <dcp/key.h>
31 #include <wx/wx.h>
32 #include <wx/notebook.h>
33 #include <wx/gbsizer.h>
34 #include <wx/spinctrl.h>
35 #include <boost/lexical_cast.hpp>
36
37 using std::cout;
38 using std::list;
39 using std::string;
40 using std::vector;
41 using boost::lexical_cast;
42 using boost::shared_ptr;
43
44 DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f)
45         : _film (f)
46         , _generally_sensitive (true)
47 {
48         _panel = new wxPanel (n);
49         _sizer = new wxBoxSizer (wxVERTICAL);
50         _panel->SetSizer (_sizer);
51
52         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
53         _sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
54
55         int r = 0;
56         
57         add_label_to_grid_bag_sizer (grid, _panel, _("Name"), true, wxGBPosition (r, 0));
58         _name = new wxTextCtrl (_panel, wxID_ANY);
59         grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
60         ++r;
61         
62         int flags = wxALIGN_CENTER_VERTICAL;
63 #ifdef __WXOSX__
64         flags |= wxALIGN_RIGHT;
65 #endif  
66
67         _use_isdcf_name = new wxCheckBox (_panel, wxID_ANY, _("Use ISDCF name"));
68         grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
69
70         {
71                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
72                 _edit_isdcf_button = new wxButton (_panel, wxID_ANY, _("Details..."));
73                 s->Add (_edit_isdcf_button, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
74                 _copy_isdcf_name_button = new wxButton (_panel, wxID_ANY, _("Copy as name"));
75                 s->Add (_copy_isdcf_name_button, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_X_GAP);
76                 grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
77                 ++r;
78         }
79
80         /* wxST_ELLIPSIZE_MIDDLE works around a bug in GTK2 and/or wxWidgets, see
81            http://trac.wxwidgets.org/ticket/12539
82         */
83         _dcp_name = new wxStaticText (
84                 _panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize,
85                 wxALIGN_CENTRE_HORIZONTAL | wxST_NO_AUTORESIZE | wxST_ELLIPSIZE_MIDDLE
86                 );
87
88         grid->Add (_dcp_name, wxGBPosition(r, 0), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL | wxEXPAND);
89         ++r;
90
91         add_label_to_grid_bag_sizer (grid, _panel, _("Content Type"), true, wxGBPosition (r, 0));
92         _dcp_content_type = new wxChoice (_panel, wxID_ANY);
93         grid->Add (_dcp_content_type, wxGBPosition (r, 1));
94         ++r;
95
96         _notebook = new wxNotebook (_panel, wxID_ANY);
97         _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
98
99         _notebook->AddPage (make_video_panel (), _("Video"), false);
100         _notebook->AddPage (make_audio_panel (), _("Audio"), false);
101         
102         _signed = new wxCheckBox (_panel, wxID_ANY, _("Signed"));
103         grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
104         ++r;
105         
106         _encrypted = new wxCheckBox (_panel, wxID_ANY, _("Encrypted"));
107         grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
108         ++r;
109
110         wxClientDC dc (_panel);
111         wxSize size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
112         size.SetHeight (-1);
113
114         {
115                add_label_to_grid_bag_sizer (grid, _panel, _("Key"), true, wxGBPosition (r, 0));
116                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
117                _key = new wxStaticText (_panel, wxID_ANY, "", wxDefaultPosition, size);
118                s->Add (_key, 1, wxALIGN_CENTER_VERTICAL);
119                _edit_key = new wxButton (_panel, wxID_ANY, _("Edit..."));
120                s->Add (_edit_key);
121                grid->Add (s, wxGBPosition (r, 1));
122                ++r;
123         }
124         
125         add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0));
126         _standard = new wxChoice (_panel, wxID_ANY);
127         grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
128         ++r;
129
130         _name->Bind              (wxEVT_COMMAND_TEXT_UPDATED,         boost::bind (&DCPPanel::name_changed, this));
131         _use_isdcf_name->Bind    (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::use_isdcf_name_toggled, this));
132         _edit_isdcf_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&DCPPanel::edit_isdcf_button_clicked, this));
133         _copy_isdcf_name_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&DCPPanel::copy_isdcf_name_button_clicked, this));
134         _dcp_content_type->Bind  (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::dcp_content_type_changed, this));
135         _signed->Bind            (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::signed_toggled, this));
136         _encrypted->Bind         (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::encrypted_toggled, this));
137         _edit_key->Bind          (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&DCPPanel::edit_key_clicked, this));
138         _standard->Bind          (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::standard_changed, this));
139
140         vector<DCPContentType const *> const ct = DCPContentType::all ();
141         for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
142                 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
143         }
144
145         _standard->Append (_("SMPTE"));
146         _standard->Append (_("Interop"));
147
148         Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this));
149 }
150
151 void
152 DCPPanel::edit_key_clicked ()
153 {
154         KeyDialog* d = new KeyDialog (_panel, _film->key ());
155         if (d->ShowModal () == wxID_OK) {
156                 _film->set_key (d->key ());
157         }
158         d->Destroy ();
159 }
160
161 void
162 DCPPanel::name_changed ()
163 {
164         if (!_film) {
165                 return;
166         }
167
168         _film->set_name (string (_name->GetValue().mb_str()));
169 }
170
171 void
172 DCPPanel::j2k_bandwidth_changed ()
173 {
174         if (!_film) {
175                 return;
176         }
177         
178         _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
179 }
180
181 void
182 DCPPanel::signed_toggled ()
183 {
184         if (!_film) {
185                 return;
186         }
187
188         _film->set_signed (_signed->GetValue ());
189 }
190
191 void
192 DCPPanel::burn_subtitles_toggled ()
193 {
194         if (!_film) {
195                 return;
196         }
197
198         _film->set_burn_subtitles (_burn_subtitles->GetValue ());
199 }
200
201 void
202 DCPPanel::encrypted_toggled ()
203 {
204         if (!_film) {
205                 return;
206         }
207
208         _film->set_encrypted (_encrypted->GetValue ());
209 }
210                                
211 /** Called when the frame rate choice widget has been changed */
212 void
213 DCPPanel::frame_rate_choice_changed ()
214 {
215         if (!_film) {
216                 return;
217         }
218
219         _film->set_video_frame_rate (
220                 boost::lexical_cast<int> (
221                         wx_to_std (_frame_rate_choice->GetString (_frame_rate_choice->GetSelection ()))
222                         )
223                 );
224 }
225
226 /** Called when the frame rate spin widget has been changed */
227 void
228 DCPPanel::frame_rate_spin_changed ()
229 {
230         if (!_film) {
231                 return;
232         }
233
234         _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
235 }
236
237 void
238 DCPPanel::audio_channels_changed ()
239 {
240         if (!_film) {
241                 return;
242         }
243
244         _film->set_audio_channels ((_audio_channels->GetSelection () + 1) * 2);
245 }
246
247 void
248 DCPPanel::resolution_changed ()
249 {
250         if (!_film) {
251                 return;
252         }
253
254         _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
255 }
256
257 void
258 DCPPanel::standard_changed ()
259 {
260         if (!_film) {
261                 return;
262         }
263
264         _film->set_interop (_standard->GetSelection() == 1);
265 }
266
267 void
268 DCPPanel::film_changed (int p)
269 {
270         switch (p) {
271         case Film::NONE:
272                 break;
273         case Film::CONTAINER:
274                 setup_container ();
275                 break;
276         case Film::NAME:
277                 checked_set (_name, _film->name());
278                 setup_dcp_name ();
279                 break;
280         case Film::DCP_CONTENT_TYPE:
281                 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
282                 setup_dcp_name ();
283                 break;
284         case Film::BURN_SUBTITLES:
285                 checked_set (_burn_subtitles, _film->burn_subtitles ());
286                 break;
287         case Film::SIGNED:
288                 checked_set (_signed, _film->is_signed ());
289                 break;
290         case Film::ENCRYPTED:
291                 checked_set (_encrypted, _film->encrypted ());
292                 if (_film->encrypted ()) {
293                         _film->set_signed (true);
294                         _signed->Enable (false);
295                         _key->Enable (_generally_sensitive);
296                         _edit_key->Enable (_generally_sensitive);
297                 } else {
298                         _signed->Enable (_generally_sensitive);
299                         _key->Enable (false);
300                         _edit_key->Enable (false);
301                 }
302                 break;
303         case Film::KEY:
304                 checked_set (_key, _film->key().hex().substr (0, 8) + "...");
305                 break;
306         case Film::RESOLUTION:
307                 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
308                 setup_container ();
309                 setup_dcp_name ();
310                 break;
311         case Film::J2K_BANDWIDTH:
312                 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
313                 break;
314         case Film::USE_ISDCF_NAME:
315         {
316                 checked_set (_use_isdcf_name, _film->use_isdcf_name ());
317                 setup_dcp_name ();
318                 _edit_isdcf_button->Enable (_film->use_isdcf_name ());
319                 break;
320         }
321         case Film::ISDCF_METADATA:
322                 setup_dcp_name ();
323                 break;
324         case Film::VIDEO_FRAME_RATE:
325         {
326                 bool done = false;
327                 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
328                         if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
329                                 checked_set (_frame_rate_choice, i);
330                                 done = true;
331                                 break;
332                         }
333                 }
334
335                 if (!done) {
336                         checked_set (_frame_rate_choice, -1);
337                 }
338
339                 _frame_rate_spin->SetValue (_film->video_frame_rate ());
340
341                 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
342                 break;
343         }
344         case Film::AUDIO_CHANNELS:
345                 checked_set (_audio_channels, (_film->audio_channels () / 2) - 1);
346                 setup_dcp_name ();
347                 break;
348         case Film::THREE_D:
349                 checked_set (_three_d, _film->three_d ());
350                 setup_dcp_name ();
351                 break;
352         case Film::INTEROP:
353                 checked_set (_standard, _film->interop() ? 1 : 0);
354                 setup_dcp_name ();
355                 break;
356         default:
357                 break;
358         }
359 }
360
361 void
362 DCPPanel::film_content_changed (int property)
363 {
364         if (property == FFmpegContentProperty::AUDIO_STREAMS ||
365             property == SubtitleContentProperty::USE_SUBTITLES ||
366             property == VideoContentProperty::VIDEO_SCALE) {
367                 setup_dcp_name ();
368         }
369 }
370
371
372 void
373 DCPPanel::setup_container ()
374 {
375         int n = 0;
376         vector<Ratio const *> ratios = Ratio::all ();
377         vector<Ratio const *>::iterator i = ratios.begin ();
378         while (i != ratios.end() && *i != _film->container ()) {
379                 ++i;
380                 ++n;
381         }
382         
383         if (i == ratios.end()) {
384                 checked_set (_container, -1);
385                 checked_set (_container_size, wxT (""));
386         } else {
387                 checked_set (_container, n);
388                 dcp::Size const size = fit_ratio_within (_film->container()->ratio(), _film->full_frame ());
389                 checked_set (_container_size, wxString::Format ("%dx%d", size.width, size.height));
390         }
391         
392         setup_dcp_name ();
393 }       
394
395 /** Called when the container widget has been changed */
396 void
397 DCPPanel::container_changed ()
398 {
399         if (!_film) {
400                 return;
401         }
402
403         int const n = _container->GetSelection ();
404         if (n >= 0) {
405                 vector<Ratio const *> ratios = Ratio::all ();
406                 DCPOMATIC_ASSERT (n < int (ratios.size()));
407                 _film->set_container (ratios[n]);
408         }
409 }
410
411 /** Called when the DCP content type widget has been changed */
412 void
413 DCPPanel::dcp_content_type_changed ()
414 {
415         if (!_film) {
416                 return;
417         }
418
419         int const n = _dcp_content_type->GetSelection ();
420         if (n != wxNOT_FOUND) {
421                 _film->set_dcp_content_type (DCPContentType::from_index (n));
422         }
423 }
424
425 void
426 DCPPanel::set_film (shared_ptr<Film> film)
427 {
428         _film = film;
429         
430         film_changed (Film::NAME);
431         film_changed (Film::USE_ISDCF_NAME);
432         film_changed (Film::CONTENT);
433         film_changed (Film::DCP_CONTENT_TYPE);
434         film_changed (Film::CONTAINER);
435         film_changed (Film::RESOLUTION);
436         film_changed (Film::SIGNED);
437         film_changed (Film::BURN_SUBTITLES);
438         film_changed (Film::ENCRYPTED);
439         film_changed (Film::KEY);
440         film_changed (Film::J2K_BANDWIDTH);
441         film_changed (Film::ISDCF_METADATA);
442         film_changed (Film::VIDEO_FRAME_RATE);
443         film_changed (Film::AUDIO_CHANNELS);
444         film_changed (Film::SEQUENCE_VIDEO);
445         film_changed (Film::THREE_D);
446         film_changed (Film::INTEROP);
447 }
448
449 void
450 DCPPanel::set_general_sensitivity (bool s)
451 {
452         _name->Enable (s);
453         _use_isdcf_name->Enable (s);
454         _edit_isdcf_button->Enable (s);
455         _dcp_content_type->Enable (s);
456         _copy_isdcf_name_button->Enable (s);
457
458         bool si = s;
459         if (_film && _film->encrypted ()) {
460                 si = false;
461         }
462         _burn_subtitles->Enable (s);
463         _signed->Enable (si);
464         
465         _encrypted->Enable (s);
466         _key->Enable (s && _film && _film->encrypted ());
467         _edit_key->Enable (s && _film && _film->encrypted ());
468         _frame_rate_choice->Enable (s);
469         _frame_rate_spin->Enable (s);
470         _audio_channels->Enable (s);
471         _j2k_bandwidth->Enable (s);
472         _container->Enable (s);
473         _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
474         _resolution->Enable (s);
475         _three_d->Enable (s);
476         _standard->Enable (s);
477 }
478
479 void
480 DCPPanel::use_isdcf_name_toggled ()
481 {
482         if (!_film) {
483                 return;
484         }
485
486         _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
487 }
488
489 void
490 DCPPanel::edit_isdcf_button_clicked ()
491 {
492         if (!_film) {
493                 return;
494         }
495
496         ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata ());
497         d->ShowModal ();
498         _film->set_isdcf_metadata (d->isdcf_metadata ());
499         d->Destroy ();
500 }
501
502 void
503 DCPPanel::setup_dcp_name ()
504 {
505         _dcp_name->SetLabel (std_to_wx (_film->dcp_name (true)));
506 }
507
508 void
509 DCPPanel::best_frame_rate_clicked ()
510 {
511         if (!_film) {
512                 return;
513         }
514         
515         _film->set_video_frame_rate (_film->best_video_frame_rate ());
516 }
517
518 void
519 DCPPanel::three_d_changed ()
520 {
521         if (!_film) {
522                 return;
523         }
524
525         _film->set_three_d (_three_d->GetValue ());
526 }
527
528 void
529 DCPPanel::config_changed ()
530 {
531         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
532         setup_frame_rate_widget ();
533 }
534
535 void
536 DCPPanel::setup_frame_rate_widget ()
537 {
538         if (Config::instance()->allow_any_dcp_frame_rate ()) {
539                 _frame_rate_choice->Hide ();
540                 _frame_rate_spin->Show ();
541         } else {
542                 _frame_rate_choice->Show ();
543                 _frame_rate_spin->Hide ();
544         }
545
546         _frame_rate_sizer->Layout ();
547 }
548
549 wxPanel *
550 DCPPanel::make_video_panel ()
551 {
552         wxPanel* panel = new wxPanel (_notebook);
553         wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
554         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
555         sizer->Add (grid, 0, wxALL, 8);
556         panel->SetSizer (sizer);
557
558         int r = 0;
559         
560         add_label_to_grid_bag_sizer (grid, panel, _("Container"), true, wxGBPosition (r, 0));
561         {
562                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
563                 _container = new wxChoice (panel, wxID_ANY);
564                 s->Add (_container, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
565                 _container_size = new wxStaticText (panel, wxID_ANY, wxT (""));
566                 s->Add (_container_size, 1, wxLEFT | wxALIGN_CENTER_VERTICAL);
567                 grid->Add (s, wxGBPosition (r,1 ), wxDefaultSpan, wxEXPAND);
568                 ++r;
569         }
570
571         {
572                 add_label_to_grid_bag_sizer (grid, panel, _("Frame Rate"), true, wxGBPosition (r, 0));
573                 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
574                 _frame_rate_choice = new wxChoice (panel, wxID_ANY);
575                 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
576                 _frame_rate_spin = new wxSpinCtrl (panel, wxID_ANY);
577                 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
578                 setup_frame_rate_widget ();
579                 _best_frame_rate = new wxButton (panel, wxID_ANY, _("Use best"));
580                 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
581                 grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
582         }
583         ++r;
584
585         _burn_subtitles = new wxCheckBox (panel, wxID_ANY, _("Burn subtitles into image"));
586         grid->Add (_burn_subtitles, wxGBPosition (r, 0), wxGBSpan (1, 2));
587         ++r;
588
589         _three_d = new wxCheckBox (panel, wxID_ANY, _("3D"));
590         grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
591         ++r;
592
593         add_label_to_grid_bag_sizer (grid, panel, _("Resolution"), true, wxGBPosition (r, 0));
594         _resolution = new wxChoice (panel, wxID_ANY);
595         grid->Add (_resolution, wxGBPosition (r, 1));
596         ++r;
597
598         {
599                 add_label_to_grid_bag_sizer (grid, panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
600                 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
601                 _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
602                 s->Add (_j2k_bandwidth, 1);
603                 add_label_to_sizer (s, panel, _("Mbit/s"), false);
604                 grid->Add (s, wxGBPosition (r, 1));
605         }
606         ++r;
607
608         _container->Bind        (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::container_changed, this));
609         _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::frame_rate_choice_changed, this));
610         _frame_rate_spin->Bind  (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::frame_rate_spin_changed, this));
611         _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&DCPPanel::best_frame_rate_clicked, this));
612         _burn_subtitles->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::burn_subtitles_toggled, this));
613         _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
614         /* Also listen to wxEVT_COMMAND_TEXT_UPDATED so that typing numbers directly in is always noticed */
615         _j2k_bandwidth->Bind    (wxEVT_COMMAND_TEXT_UPDATED,          boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
616         _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::resolution_changed, this));
617         _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::three_d_changed, this));
618
619         vector<Ratio const *> const ratio = Ratio::all ();
620         for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
621                 _container->Append (std_to_wx ((*i)->nickname ()));
622         }
623
624         list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
625         for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
626                 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
627         }
628
629         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
630         _frame_rate_spin->SetRange (1, 480);
631
632         _resolution->Append (_("2K"));
633         _resolution->Append (_("4K"));
634
635         return panel;
636 }
637
638 wxPanel *
639 DCPPanel::make_audio_panel ()
640 {
641         wxPanel* panel = new wxPanel (_notebook);
642         wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
643         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
644         sizer->Add (grid, 0, wxALL, 8);
645         panel->SetSizer (sizer);
646
647         int r = 0;
648         add_label_to_grid_bag_sizer (grid, panel, _("Channels"), true, wxGBPosition (r, 0));
649         _audio_channels = new wxChoice (panel, wxID_ANY);
650         for (int i = 2; i <= 12; i += 2) {
651                 _audio_channels->Append (wxString::Format ("%d", i));
652         }
653         grid->Add (_audio_channels, wxGBPosition (r, 1));
654         ++r;
655
656         _audio_channels->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::audio_channels_changed, this));
657
658         return panel;
659 }
660
661 void
662 DCPPanel::copy_isdcf_name_button_clicked ()
663 {
664         _film->set_name (_film->isdcf_name (false));
665         _film->set_use_isdcf_name (false);
666 }