eebb00c092e568a14c0af3ce513d34f6b4ee834d from master; limit DCP channels and bump...
[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         add_label_to_grid_bag_sizer (grid, _panel, _("DCP Name"), true, wxGBPosition (r, 0));
81         _dcp_name = new wxStaticText (_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
82         grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxEXPAND);
83         ++r;
84
85         add_label_to_grid_bag_sizer (grid, _panel, _("Content Type"), true, wxGBPosition (r, 0));
86         _dcp_content_type = new wxChoice (_panel, wxID_ANY);
87         grid->Add (_dcp_content_type, wxGBPosition (r, 1));
88         ++r;
89
90         _notebook = new wxNotebook (_panel, wxID_ANY);
91         _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
92
93         _notebook->AddPage (make_video_panel (), _("Video"), false);
94         _notebook->AddPage (make_audio_panel (), _("Audio"), false);
95         
96         _signed = new wxCheckBox (_panel, wxID_ANY, _("Signed"));
97         grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
98         ++r;
99         
100         _encrypted = new wxCheckBox (_panel, wxID_ANY, _("Encrypted"));
101         grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
102         ++r;
103
104         wxClientDC dc (_panel);
105         wxSize size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
106         size.SetHeight (-1);
107
108         {
109                add_label_to_grid_bag_sizer (grid, _panel, _("Key"), true, wxGBPosition (r, 0));
110                wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
111                _key = new wxStaticText (_panel, wxID_ANY, "", wxDefaultPosition, size);
112                s->Add (_key, 1, wxALIGN_CENTER_VERTICAL);
113                _edit_key = new wxButton (_panel, wxID_ANY, _("Edit..."));
114                s->Add (_edit_key);
115                grid->Add (s, wxGBPosition (r, 1));
116                ++r;
117         }
118         
119         add_label_to_grid_bag_sizer (grid, _panel, _("Standard"), true, wxGBPosition (r, 0));
120         _standard = new wxChoice (_panel, wxID_ANY);
121         grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
122         ++r;
123
124         _name->Bind              (wxEVT_COMMAND_TEXT_UPDATED,         boost::bind (&DCPPanel::name_changed, this));
125         _use_isdcf_name->Bind    (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::use_isdcf_name_toggled, this));
126         _edit_isdcf_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&DCPPanel::edit_isdcf_button_clicked, this));
127         _copy_isdcf_name_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&DCPPanel::copy_isdcf_name_button_clicked, this));
128         _dcp_content_type->Bind  (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::dcp_content_type_changed, this));
129         _signed->Bind            (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::signed_toggled, this));
130         _encrypted->Bind         (wxEVT_COMMAND_CHECKBOX_CLICKED,     boost::bind (&DCPPanel::encrypted_toggled, this));
131         _edit_key->Bind          (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&DCPPanel::edit_key_clicked, this));
132         _standard->Bind          (wxEVT_COMMAND_CHOICE_SELECTED,      boost::bind (&DCPPanel::standard_changed, this));
133
134         vector<DCPContentType const *> const ct = DCPContentType::all ();
135         for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
136                 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
137         }
138
139         _standard->Append (_("SMPTE"));
140         _standard->Append (_("Interop"));
141
142         Config::instance()->Changed.connect (boost::bind (&DCPPanel::config_changed, this));
143 }
144
145 void
146 DCPPanel::edit_key_clicked ()
147 {
148         KeyDialog* d = new KeyDialog (_panel, _film->key ());
149         if (d->ShowModal () == wxID_OK) {
150                 _film->set_key (d->key ());
151         }
152         d->Destroy ();
153 }
154
155 void
156 DCPPanel::name_changed ()
157 {
158         if (!_film) {
159                 return;
160         }
161
162         _film->set_name (string (_name->GetValue().mb_str()));
163 }
164
165 void
166 DCPPanel::j2k_bandwidth_changed ()
167 {
168         if (!_film) {
169                 return;
170         }
171         
172         _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
173 }
174
175 void
176 DCPPanel::signed_toggled ()
177 {
178         if (!_film) {
179                 return;
180         }
181
182         _film->set_signed (_signed->GetValue ());
183 }
184
185 void
186 DCPPanel::burn_subtitles_toggled ()
187 {
188         if (!_film) {
189                 return;
190         }
191
192         _film->set_burn_subtitles (_burn_subtitles->GetValue ());
193 }
194
195 void
196 DCPPanel::encrypted_toggled ()
197 {
198         if (!_film) {
199                 return;
200         }
201
202         _film->set_encrypted (_encrypted->GetValue ());
203 }
204                                
205 /** Called when the frame rate choice widget has been changed */
206 void
207 DCPPanel::frame_rate_choice_changed ()
208 {
209         if (!_film) {
210                 return;
211         }
212
213         _film->set_video_frame_rate (
214                 boost::lexical_cast<int> (
215                         wx_to_std (_frame_rate_choice->GetString (_frame_rate_choice->GetSelection ()))
216                         )
217                 );
218 }
219
220 /** Called when the frame rate spin widget has been changed */
221 void
222 DCPPanel::frame_rate_spin_changed ()
223 {
224         if (!_film) {
225                 return;
226         }
227
228         _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
229 }
230
231 void
232 DCPPanel::audio_channels_changed ()
233 {
234         if (!_film) {
235                 return;
236         }
237
238         _film->set_audio_channels ((_audio_channels->GetSelection () + 1) * 2);
239 }
240
241 void
242 DCPPanel::resolution_changed ()
243 {
244         if (!_film) {
245                 return;
246         }
247
248         _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
249 }
250
251 void
252 DCPPanel::standard_changed ()
253 {
254         if (!_film) {
255                 return;
256         }
257
258         _film->set_interop (_standard->GetSelection() == 1);
259 }
260
261 void
262 DCPPanel::film_changed (int p)
263 {
264         switch (p) {
265         case Film::NONE:
266                 break;
267         case Film::CONTAINER:
268                 setup_container ();
269                 break;
270         case Film::NAME:
271                 checked_set (_name, _film->name());
272                 setup_dcp_name ();
273                 break;
274         case Film::DCP_CONTENT_TYPE:
275                 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
276                 setup_dcp_name ();
277                 break;
278         case Film::BURN_SUBTITLES:
279                 checked_set (_burn_subtitles, _film->burn_subtitles ());
280                 break;
281         case Film::SIGNED:
282                 checked_set (_signed, _film->is_signed ());
283                 break;
284         case Film::ENCRYPTED:
285                 checked_set (_encrypted, _film->encrypted ());
286                 if (_film->encrypted ()) {
287                         _film->set_signed (true);
288                         _signed->Enable (false);
289                         _key->Enable (_generally_sensitive);
290                         _edit_key->Enable (_generally_sensitive);
291                 } else {
292                         _signed->Enable (_generally_sensitive);
293                         _key->Enable (false);
294                         _edit_key->Enable (false);
295                 }
296                 break;
297         case Film::KEY:
298                 checked_set (_key, _film->key().hex().substr (0, 8) + "...");
299                 break;
300         case Film::RESOLUTION:
301                 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
302                 setup_dcp_name ();
303                 break;
304         case Film::J2K_BANDWIDTH:
305                 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
306                 break;
307         case Film::USE_ISDCF_NAME:
308         {
309                 checked_set (_use_isdcf_name, _film->use_isdcf_name ());
310                 setup_dcp_name ();
311                 _edit_isdcf_button->Enable (_film->use_isdcf_name ());
312                 break;
313         }
314         case Film::ISDCF_METADATA:
315                 setup_dcp_name ();
316                 break;
317         case Film::VIDEO_FRAME_RATE:
318         {
319                 bool done = false;
320                 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
321                         if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
322                                 checked_set (_frame_rate_choice, i);
323                                 done = true;
324                                 break;
325                         }
326                 }
327
328                 if (!done) {
329                         checked_set (_frame_rate_choice, -1);
330                 }
331
332                 _frame_rate_spin->SetValue (_film->video_frame_rate ());
333
334                 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
335                 break;
336         }
337         case Film::AUDIO_CHANNELS:
338                 checked_set (_audio_channels, (_film->audio_channels () / 2) - 1);
339                 setup_dcp_name ();
340                 break;
341         case Film::THREE_D:
342                 checked_set (_three_d, _film->three_d ());
343                 setup_dcp_name ();
344                 break;
345         case Film::INTEROP:
346                 checked_set (_standard, _film->interop() ? 1 : 0);
347                 break;
348         default:
349                 break;
350         }
351 }
352
353 void
354 DCPPanel::film_content_changed (int property)
355 {
356         if (property == FFmpegContentProperty::AUDIO_STREAM ||
357             property == SubtitleContentProperty::USE_SUBTITLES ||
358             property == VideoContentProperty::VIDEO_SCALE) {
359                 setup_dcp_name ();
360         }
361 }
362
363
364 void
365 DCPPanel::setup_container ()
366 {
367         int n = 0;
368         vector<Ratio const *> ratios = Ratio::all ();
369         vector<Ratio const *>::iterator i = ratios.begin ();
370         while (i != ratios.end() && *i != _film->container ()) {
371                 ++i;
372                 ++n;
373         }
374         
375         if (i == ratios.end()) {
376                 checked_set (_container, -1);
377         } else {
378                 checked_set (_container, n);
379         }
380         
381         setup_dcp_name ();
382 }       
383
384 /** Called when the container widget has been changed */
385 void
386 DCPPanel::container_changed ()
387 {
388         if (!_film) {
389                 return;
390         }
391
392         int const n = _container->GetSelection ();
393         if (n >= 0) {
394                 vector<Ratio const *> ratios = Ratio::all ();
395                 DCPOMATIC_ASSERT (n < int (ratios.size()));
396                 _film->set_container (ratios[n]);
397         }
398 }
399
400 /** Called when the DCP content type widget has been changed */
401 void
402 DCPPanel::dcp_content_type_changed ()
403 {
404         if (!_film) {
405                 return;
406         }
407
408         int const n = _dcp_content_type->GetSelection ();
409         if (n != wxNOT_FOUND) {
410                 _film->set_dcp_content_type (DCPContentType::from_index (n));
411         }
412 }
413
414 void
415 DCPPanel::set_film (shared_ptr<Film> film)
416 {
417         _film = film;
418         
419         film_changed (Film::NAME);
420         film_changed (Film::USE_ISDCF_NAME);
421         film_changed (Film::CONTENT);
422         film_changed (Film::DCP_CONTENT_TYPE);
423         film_changed (Film::CONTAINER);
424         film_changed (Film::RESOLUTION);
425         film_changed (Film::SIGNED);
426         film_changed (Film::BURN_SUBTITLES);
427         film_changed (Film::ENCRYPTED);
428         film_changed (Film::KEY);
429         film_changed (Film::J2K_BANDWIDTH);
430         film_changed (Film::ISDCF_METADATA);
431         film_changed (Film::VIDEO_FRAME_RATE);
432         film_changed (Film::AUDIO_CHANNELS);
433         film_changed (Film::SEQUENCE_VIDEO);
434         film_changed (Film::THREE_D);
435         film_changed (Film::INTEROP);
436 }
437
438 void
439 DCPPanel::set_general_sensitivity (bool s)
440 {
441         _name->Enable (s);
442         _use_isdcf_name->Enable (s);
443         _edit_isdcf_button->Enable (s);
444         _dcp_content_type->Enable (s);
445         _copy_isdcf_name_button->Enable (s);
446
447         bool si = s;
448         if (_film && _film->encrypted ()) {
449                 si = false;
450         }
451         _burn_subtitles->Enable (s);
452         _signed->Enable (si);
453         
454         _encrypted->Enable (s);
455         _key->Enable (s && _film && _film->encrypted ());
456         _edit_key->Enable (s && _film && _film->encrypted ());
457         _frame_rate_choice->Enable (s);
458         _frame_rate_spin->Enable (s);
459         _audio_channels->Enable (s);
460         _j2k_bandwidth->Enable (s);
461         _container->Enable (s);
462         _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
463         _resolution->Enable (s);
464         _three_d->Enable (s);
465         _standard->Enable (s);
466 }
467
468 void
469 DCPPanel::use_isdcf_name_toggled ()
470 {
471         if (!_film) {
472                 return;
473         }
474
475         _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
476 }
477
478 void
479 DCPPanel::edit_isdcf_button_clicked ()
480 {
481         if (!_film) {
482                 return;
483         }
484
485         ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata ());
486         d->ShowModal ();
487         _film->set_isdcf_metadata (d->isdcf_metadata ());
488         d->Destroy ();
489 }
490
491 void
492 DCPPanel::setup_dcp_name ()
493 {
494         string s = _film->dcp_name (true);
495         if (s.length() > 28) {
496                 _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
497                 _dcp_name->SetToolTip (std_to_wx (s));
498         } else {
499                 _dcp_name->SetLabel (std_to_wx (s));
500         }
501 }
502
503 void
504 DCPPanel::best_frame_rate_clicked ()
505 {
506         if (!_film) {
507                 return;
508         }
509         
510         _film->set_video_frame_rate (_film->best_video_frame_rate ());
511 }
512
513 void
514 DCPPanel::three_d_changed ()
515 {
516         if (!_film) {
517                 return;
518         }
519
520         _film->set_three_d (_three_d->GetValue ());
521 }
522
523 void
524 DCPPanel::config_changed ()
525 {
526         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
527         setup_frame_rate_widget ();
528 }
529
530 void
531 DCPPanel::setup_frame_rate_widget ()
532 {
533         if (Config::instance()->allow_any_dcp_frame_rate ()) {
534                 _frame_rate_choice->Hide ();
535                 _frame_rate_spin->Show ();
536         } else {
537                 _frame_rate_choice->Show ();
538                 _frame_rate_spin->Hide ();
539         }
540
541         _frame_rate_sizer->Layout ();
542 }
543
544 wxPanel *
545 DCPPanel::make_video_panel ()
546 {
547         wxPanel* panel = new wxPanel (_notebook);
548         wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
549         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
550         sizer->Add (grid, 0, wxALL, 8);
551         panel->SetSizer (sizer);
552
553         int r = 0;
554         
555         add_label_to_grid_bag_sizer (grid, panel, _("Container"), true, wxGBPosition (r, 0));
556         _container = new wxChoice (panel, wxID_ANY);
557         grid->Add (_container, wxGBPosition (r, 1));
558         ++r;
559
560         {
561                 add_label_to_grid_bag_sizer (grid, panel, _("Frame Rate"), true, wxGBPosition (r, 0));
562                 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
563                 _frame_rate_choice = new wxChoice (panel, wxID_ANY);
564                 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
565                 _frame_rate_spin = new wxSpinCtrl (panel, wxID_ANY);
566                 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
567                 setup_frame_rate_widget ();
568                 _best_frame_rate = new wxButton (panel, wxID_ANY, _("Use best"));
569                 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
570                 grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
571         }
572         ++r;
573
574         _burn_subtitles = new wxCheckBox (panel, wxID_ANY, _("Burn subtitles into image"));
575         grid->Add (_burn_subtitles, wxGBPosition (r, 0), wxGBSpan (1, 2));
576         ++r;
577
578         _three_d = new wxCheckBox (panel, wxID_ANY, _("3D"));
579         grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
580         ++r;
581
582         add_label_to_grid_bag_sizer (grid, panel, _("Resolution"), true, wxGBPosition (r, 0));
583         _resolution = new wxChoice (panel, wxID_ANY);
584         grid->Add (_resolution, wxGBPosition (r, 1));
585         ++r;
586
587         {
588                 add_label_to_grid_bag_sizer (grid, panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
589                 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
590                 _j2k_bandwidth = new wxSpinCtrl (panel, wxID_ANY);
591                 s->Add (_j2k_bandwidth, 1);
592                 add_label_to_sizer (s, panel, _("Mbit/s"), false);
593                 grid->Add (s, wxGBPosition (r, 1));
594         }
595         ++r;
596
597         _container->Bind        (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::container_changed, this));
598         _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::frame_rate_choice_changed, this));
599         _frame_rate_spin->Bind  (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::frame_rate_spin_changed, this));
600         _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&DCPPanel::best_frame_rate_clicked, this));
601         _burn_subtitles->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::burn_subtitles_toggled, this));
602         _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
603         /* Also listen to wxEVT_COMMAND_TEXT_UPDATED so that typing numbers directly in is always noticed */
604         _j2k_bandwidth->Bind    (wxEVT_COMMAND_TEXT_UPDATED,          boost::bind (&DCPPanel::j2k_bandwidth_changed, this));
605         _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&DCPPanel::resolution_changed, this));
606         _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&DCPPanel::three_d_changed, this));
607
608         vector<Ratio const *> const ratio = Ratio::all ();
609         for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
610                 _container->Append (std_to_wx ((*i)->nickname ()));
611         }
612
613         list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
614         for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
615                 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
616         }
617
618         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
619         _frame_rate_spin->SetRange (1, 480);
620
621         _resolution->Append (_("2K"));
622         _resolution->Append (_("4K"));
623
624         return panel;
625 }
626
627 wxPanel *
628 DCPPanel::make_audio_panel ()
629 {
630         wxPanel* panel = new wxPanel (_notebook);
631         wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
632         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
633         sizer->Add (grid, 0, wxALL, 8);
634         panel->SetSizer (sizer);
635
636         int r = 0;
637         add_label_to_grid_bag_sizer (grid, panel, _("Channels"), true, wxGBPosition (r, 0));
638         _audio_channels = new wxChoice (panel, wxID_ANY);
639         for (int i = 2; i <= 12; i += 2) {
640                 _audio_channels->Append (wxString::Format ("%d", i));
641         }
642         grid->Add (_audio_channels, wxGBPosition (r, 1));
643         ++r;
644
645         _audio_channels->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::audio_channels_changed, this));
646
647         return panel;
648 }
649
650 void
651 DCPPanel::copy_isdcf_name_button_clicked ()
652 {
653         _film->set_name (_film->isdcf_name (false));
654         _film->set_use_isdcf_name (false);
655 }