cc636b0bfb0d5bd40965935aa31296ad114cdcc7
[dcpomatic.git] / src / lib / dcp_content.cc
1 /*
2     Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "dcp_content.h"
22 #include "video_content.h"
23 #include "audio_content.h"
24 #include "dcp_examiner.h"
25 #include "job.h"
26 #include "film.h"
27 #include "config.h"
28 #include "overlaps.h"
29 #include "compose.hpp"
30 #include "dcp_decoder.h"
31 #include "log.h"
32 #include "text_content.h"
33 #include <dcp/dcp.h>
34 #include <dcp/raw_convert.h>
35 #include <dcp/exceptions.h>
36 #include <dcp/reel_picture_asset.h>
37 #include <dcp/reel.h>
38 #include <libxml++/libxml++.h>
39 #include <boost/foreach.hpp>
40 #include <iterator>
41 #include <iostream>
42
43 #include "i18n.h"
44
45 using std::string;
46 using std::cout;
47 using std::distance;
48 using std::pair;
49 using std::vector;
50 using std::list;
51 using boost::shared_ptr;
52 using boost::scoped_ptr;
53 using boost::optional;
54 using boost::function;
55 using boost::dynamic_pointer_cast;
56 using dcp::raw_convert;
57
58 int const DCPContentProperty::NEEDS_ASSETS       = 600;
59 int const DCPContentProperty::NEEDS_KDM          = 601;
60 int const DCPContentProperty::REFERENCE_VIDEO    = 602;
61 int const DCPContentProperty::REFERENCE_AUDIO    = 603;
62 int const DCPContentProperty::REFERENCE_TEXT     = 604;
63 int const DCPContentProperty::NAME               = 605;
64 int const DCPContentProperty::TEXTS              = 606;
65 int const DCPContentProperty::CPL                = 607;
66
67 #define LOG_GENERAL(...) this->film()->log()->log(String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL);
68
69 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
70         : Content (film)
71         , _encrypted (false)
72         , _needs_assets (false)
73         , _kdm_valid (false)
74         , _reference_video (false)
75         , _reference_audio (false)
76         , _three_d (false)
77 {
78         LOG_GENERAL ("Creating DCP content from %1", p.string());
79
80         read_directory (p);
81         set_default_colour_conversion ();
82
83         for (int i = 0; i < TEXT_COUNT; ++i) {
84                 _reference_text[i] = false;
85         }
86 }
87
88 DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
89         : Content (film, node)
90 {
91         video = VideoContent::from_xml (this, node, version);
92         audio = AudioContent::from_xml (this, node, version);
93         text = TextContent::from_xml (this, node, version);
94
95         for (int i = 0; i < TEXT_COUNT; ++i) {
96                 _reference_text[i] = false;
97         }
98
99         if (video && audio) {
100                 audio->set_stream (
101                         AudioStreamPtr (
102                                 new AudioStream (
103                                         node->number_child<int> ("AudioFrameRate"),
104                                         /* AudioLength was not present in some old metadata versions */
105                                         node->optional_number_child<Frame>("AudioLength").get_value_or (
106                                                 video->length() * node->number_child<int>("AudioFrameRate") / video_frame_rate().get()
107                                                 ),
108                                         AudioMapping (node->node_child ("AudioMapping"), version)
109                                         )
110                                 )
111                         );
112         }
113
114         _name = node->string_child ("Name");
115         _encrypted = node->bool_child ("Encrypted");
116         _needs_assets = node->optional_bool_child("NeedsAssets").get_value_or (false);
117         if (node->optional_node_child ("KDM")) {
118                 _kdm = dcp::EncryptedKDM (node->string_child ("KDM"));
119         }
120         _kdm_valid = node->bool_child ("KDMValid");
121         _reference_video = node->optional_bool_child ("ReferenceVideo").get_value_or (false);
122         _reference_audio = node->optional_bool_child ("ReferenceAudio").get_value_or (false);
123         if (version >= 37) {
124                 _reference_text[TEXT_OPEN_SUBTITLE] = node->optional_bool_child("ReferenceOpenSubtitle").get_value_or(false);
125                 _reference_text[TEXT_CLOSED_CAPTION] = node->optional_bool_child("ReferenceClosedCaption").get_value_or(false);
126         } else {
127                 _reference_text[TEXT_OPEN_SUBTITLE] = node->optional_bool_child("ReferenceSubtitle").get_value_or(false);
128                 _reference_text[TEXT_CLOSED_CAPTION] = false;
129         }
130         if (node->optional_string_child("Standard")) {
131                 string const s = node->optional_string_child("Standard").get();
132                 if (s == "Interop") {
133                         _standard = dcp::INTEROP;
134                 } else if (s == "SMPTE") {
135                         _standard = dcp::SMPTE;
136                 } else {
137                         DCPOMATIC_ASSERT (false);
138                 }
139         }
140         _three_d = node->optional_bool_child("ThreeD").get_value_or (false);
141
142         optional<string> ck = node->optional_string_child("ContentKind");
143         if (ck) {
144                 _content_kind = dcp::content_kind_from_string (*ck);
145         }
146         _cpl = node->optional_string_child("CPL");
147         BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("ReelLength")) {
148                 _reel_lengths.push_back (raw_convert<int64_t> (i->content ()));
149         }
150 }
151
152 void
153 DCPContent::read_directory (boost::filesystem::path p)
154 {
155         LOG_GENERAL ("DCPContent::read_directory reads %1", p.string());
156         for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
157                 if (boost::filesystem::is_regular_file (i->path())) {
158                         LOG_GENERAL ("Inside there's regular file %1", i->path().string());
159                         add_path (i->path());
160                 } else if (boost::filesystem::is_directory (i->path ())) {
161                         LOG_GENERAL ("Inside there's directory %1", i->path().string());
162                         read_directory (i->path());
163                 }
164         }
165
166         bool have_assetmap = false;
167         BOOST_FOREACH (boost::filesystem::path i, paths()) {
168                 if (i.filename() == "ASSETMAP" || i.filename() == "ASSETMAP.xml") {
169                         have_assetmap = true;
170                 }
171         }
172
173         if (!have_assetmap) {
174                 throw DCPError ("No ASSETMAP or ASSETMAP.xml file found: is this a DCP?");
175         }
176 }
177
178 void
179 DCPContent::examine (shared_ptr<Job> job)
180 {
181         bool const needed_assets = needs_assets ();
182         bool const needed_kdm = needs_kdm ();
183         string const old_name = name ();
184         int const old_texts = text.size ();
185
186         ChangeSignaller<Content> cc_texts (this, DCPContentProperty::TEXTS);
187         ChangeSignaller<Content> cc_assets (this, DCPContentProperty::NEEDS_ASSETS);
188         ChangeSignaller<Content> cc_kdm (this, DCPContentProperty::NEEDS_KDM);
189         ChangeSignaller<Content> cc_name (this, DCPContentProperty::NAME);
190         ChangeSignaller<Content> cc_streams (this, AudioContentProperty::STREAMS);
191
192         if (job) {
193                 job->set_progress_unknown ();
194         }
195         Content::examine (job);
196
197         shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
198
199         if (examiner->has_video()) {
200                 {
201                         boost::mutex::scoped_lock lm (_mutex);
202                         video.reset (new VideoContent (this));
203                 }
204                 video->take_from_examiner (examiner);
205                 set_default_colour_conversion ();
206         }
207
208         if (examiner->has_audio()) {
209                 ChangeSignaller<Content> cc (this, AudioContentProperty::STREAMS);
210                 {
211                         boost::mutex::scoped_lock lm (_mutex);
212                         audio.reset (new AudioContent (this));
213                 }
214                 AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels()));
215                 audio->set_stream (as);
216                 AudioMapping m = as->mapping ();
217                 film()->make_audio_mapping_default (m);
218                 as->set_mapping (m);
219         }
220
221         int texts = 0;
222         {
223                 boost::mutex::scoped_lock lm (_mutex);
224                 _name = examiner->name ();
225                 for (int i = 0; i < TEXT_COUNT; ++i) {
226                         if (examiner->has_text(static_cast<TextType>(i))) {
227                                 text.push_back (shared_ptr<TextContent>(new TextContent(this, static_cast<TextType>(i), static_cast<TextType>(i))));
228                         }
229                 }
230                 texts = text.size ();
231                 _encrypted = examiner->encrypted ();
232                 _needs_assets = examiner->needs_assets ();
233                 _kdm_valid = examiner->kdm_valid ();
234                 _standard = examiner->standard ();
235                 _three_d = examiner->three_d ();
236                 _content_kind = examiner->content_kind ();
237                 _cpl = examiner->cpl ();
238                 _reel_lengths = examiner->reel_lengths ();
239         }
240
241         if (old_texts == texts) {
242                 cc_texts.abort ();
243         }
244
245         if (needed_assets == needs_assets()) {
246                 cc_assets.abort ();
247         }
248
249         if (needed_kdm == needs_kdm()) {
250                 cc_kdm.abort ();
251         }
252
253         if (old_name == name()) {
254                 cc_name.abort ();
255         }
256
257         if (video) {
258                 video->set_frame_type (_three_d ? VIDEO_FRAME_TYPE_3D : VIDEO_FRAME_TYPE_2D);
259         }
260 }
261
262 string
263 DCPContent::summary () const
264 {
265         boost::mutex::scoped_lock lm (_mutex);
266         return String::compose (_("%1 [DCP]"), _name);
267 }
268
269 string
270 DCPContent::technical_summary () const
271 {
272         string s = Content::technical_summary() + " - ";
273         if (video) {
274                 s += video->technical_summary() + " - ";
275         }
276         if (audio) {
277                 s += audio->technical_summary() + " - ";
278         }
279         return s;
280 }
281
282 void
283 DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const
284 {
285         node->add_child("Type")->add_child_text ("DCP");
286
287         Content::as_xml (node, with_paths);
288
289         if (video) {
290                 video->as_xml (node);
291         }
292
293         if (audio) {
294                 audio->as_xml (node);
295                 node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio->stream()->frame_rate()));
296                 node->add_child("AudioLength")->add_child_text (raw_convert<string> (audio->stream()->length()));
297                 audio->stream()->mapping().as_xml (node->add_child("AudioMapping"));
298         }
299
300         BOOST_FOREACH (shared_ptr<TextContent> i, text) {
301                 i->as_xml (node);
302         }
303
304         boost::mutex::scoped_lock lm (_mutex);
305         node->add_child("Name")->add_child_text (_name);
306         node->add_child("Encrypted")->add_child_text (_encrypted ? "1" : "0");
307         node->add_child("NeedsAssets")->add_child_text (_needs_assets ? "1" : "0");
308         if (_kdm) {
309                 node->add_child("KDM")->add_child_text (_kdm->as_xml ());
310         }
311         node->add_child("KDMValid")->add_child_text (_kdm_valid ? "1" : "0");
312         node->add_child("ReferenceVideo")->add_child_text (_reference_video ? "1" : "0");
313         node->add_child("ReferenceAudio")->add_child_text (_reference_audio ? "1" : "0");
314         node->add_child("ReferenceOpenSubtitle")->add_child_text(_reference_text[TEXT_OPEN_SUBTITLE] ? "1" : "0");
315         node->add_child("ReferenceClosedCaption")->add_child_text(_reference_text[TEXT_CLOSED_CAPTION] ? "1" : "0");
316         if (_standard) {
317                 switch (_standard.get ()) {
318                 case dcp::INTEROP:
319                         node->add_child("Standard")->add_child_text ("Interop");
320                         break;
321                 case dcp::SMPTE:
322                         node->add_child("Standard")->add_child_text ("SMPTE");
323                         break;
324                 default:
325                         DCPOMATIC_ASSERT (false);
326                 }
327         }
328         node->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0");
329         if (_content_kind) {
330                 node->add_child("ContentKind")->add_child_text(dcp::content_kind_to_string(*_content_kind));
331         }
332         if (_cpl) {
333                 node->add_child("CPL")->add_child_text (_cpl.get ());
334         }
335         BOOST_FOREACH (int64_t i, _reel_lengths) {
336                 node->add_child("ReelLength")->add_child_text (raw_convert<string> (i));
337         }
338 }
339
340 DCPTime
341 DCPContent::full_length () const
342 {
343         if (!video) {
344                 return DCPTime();
345         }
346         FrameRateChange const frc (active_video_frame_rate (), film()->video_frame_rate ());
347         return DCPTime::from_frames (llrint (video->length () * frc.factor ()), film()->video_frame_rate ());
348 }
349
350 string
351 DCPContent::identifier () const
352 {
353         string s = Content::identifier() + "_";
354
355         if (video) {
356                 s += video->identifier() + "_";
357         }
358
359         BOOST_FOREACH (shared_ptr<TextContent> i, text) {
360                 s += i->identifier () + " ";
361         }
362
363         s += string (_reference_video ? "1" : "0");
364         for (int i = 0; i < TEXT_COUNT; ++i) {
365                 s += string (_reference_text[i] ? "1" : "0");
366         }
367         return s;
368 }
369
370 void
371 DCPContent::add_kdm (dcp::EncryptedKDM k)
372 {
373         _kdm = k;
374 }
375
376 void
377 DCPContent::add_ov (boost::filesystem::path ov)
378 {
379         read_directory (ov);
380 }
381
382 bool
383 DCPContent::can_be_played () const
384 {
385         return !needs_kdm() && !needs_assets();
386 }
387
388 bool
389 DCPContent::needs_kdm () const
390 {
391         boost::mutex::scoped_lock lm (_mutex);
392         return _encrypted && !_kdm_valid;
393 }
394
395 bool
396 DCPContent::needs_assets () const
397 {
398         boost::mutex::scoped_lock lm (_mutex);
399         return _needs_assets;
400 }
401
402 vector<boost::filesystem::path>
403 DCPContent::directories () const
404 {
405         return dcp::DCP::directories_from_files (paths());
406 }
407
408 void
409 DCPContent::add_properties (list<UserProperty>& p) const
410 {
411         Content::add_properties (p);
412         if (video) {
413                 video->add_properties (p);
414         }
415         if (audio) {
416                 audio->add_properties (p);
417         }
418 }
419
420 void
421 DCPContent::set_default_colour_conversion ()
422 {
423         /* Default to no colour conversion for DCPs */
424         if (video) {
425                 video->unset_colour_conversion ();
426         }
427 }
428
429 void
430 DCPContent::set_reference_video (bool r)
431 {
432         ChangeSignaller<Content> cc (this, DCPContentProperty::REFERENCE_VIDEO);
433
434         {
435                 boost::mutex::scoped_lock lm (_mutex);
436                 _reference_video = r;
437         }
438 }
439
440 void
441 DCPContent::set_reference_audio (bool r)
442 {
443         ChangeSignaller<Content> cc (this, DCPContentProperty::REFERENCE_AUDIO);
444
445         {
446                 boost::mutex::scoped_lock lm (_mutex);
447                 _reference_audio = r;
448         }
449 }
450
451 void
452 DCPContent::set_reference_text (TextType type, bool r)
453 {
454         ChangeSignaller<Content> cc (this, DCPContentProperty::REFERENCE_TEXT);
455
456         {
457                 boost::mutex::scoped_lock lm (_mutex);
458                 _reference_text[type] = r;
459         }
460 }
461
462 list<DCPTimePeriod>
463 DCPContent::reels () const
464 {
465         list<int64_t> reel_lengths = _reel_lengths;
466         if (reel_lengths.empty ()) {
467                 /* Old metadata with no reel lengths; get them here instead */
468                 try {
469                         scoped_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this()));
470                         reel_lengths = examiner->reel_lengths ();
471                 } catch (...) {
472                         /* Could not examine the DCP; guess reels */
473                         reel_lengths.push_back (length_after_trim().frames_round (film()->video_frame_rate ()));
474                 }
475         }
476
477         list<DCPTimePeriod> p;
478
479         /* This content's frame rate must be the same as the output DCP rate, so we can
480            convert `directly' from ContentTime to DCPTime.
481         */
482
483         /* The starting point of this content on the timeline */
484         DCPTime pos = position() - DCPTime (trim_start().get());
485
486         BOOST_FOREACH (int64_t i, reel_lengths) {
487                 /* This reel runs from `pos' to `to' */
488                 DCPTime const to = pos + DCPTime::from_frames (i, film()->video_frame_rate());
489                 if (to > position()) {
490                         p.push_back (DCPTimePeriod (max(position(), pos), min(end(), to)));
491                         if (to > end()) {
492                                 break;
493                         }
494                 }
495                 pos = to;
496         }
497
498         return p;
499 }
500
501 list<DCPTime>
502 DCPContent::reel_split_points () const
503 {
504         list<DCPTime> s;
505         BOOST_FOREACH (DCPTimePeriod i, reels()) {
506                 s.push_back (i.from);
507         }
508         return s;
509 }
510
511 bool
512 DCPContent::can_reference (function<bool (shared_ptr<const Content>)> part, string overlapping, string& why_not) const
513 {
514         /* We must be using the same standard as the film */
515         if (_standard) {
516                 if (_standard.get() == dcp::INTEROP && !film()->interop()) {
517                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
518                         why_not = _("it is Interop and the film is set to SMPTE.");
519                         return false;
520                 } else if (_standard.get() == dcp::SMPTE && film()->interop()) {
521                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
522                         why_not = _("it is SMPTE and the film is set to Interop.");
523                         return false;
524                 }
525         }
526
527         /* And the same frame rate */
528         if (!video_frame_rate() || (lrint(video_frame_rate().get()) != film()->video_frame_rate())) {
529                 /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
530                 why_not = _("it has a different frame rate to the film.");
531                 return false;
532         }
533
534         list<DCPTimePeriod> const fr = film()->reels ();
535
536         list<DCPTimePeriod> reel_list;
537         try {
538                 reel_list = reels ();
539         } catch (dcp::DCPReadError) {
540                 /* We couldn't read the DCP; it's probably missing */
541                 return false;
542         } catch (dcp::KDMDecryptionError) {
543                 /* We have an incorrect KDM */
544                 return false;
545         }
546
547         /* fr must contain reels().  It can also contain other reels, but it must at
548            least contain reels().
549         */
550         BOOST_FOREACH (DCPTimePeriod i, reel_list) {
551                 if (find (fr.begin(), fr.end(), i) == fr.end ()) {
552                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
553                         why_not = _("its reel lengths differ from those in the film; set the reel mode to 'split by video content'.");
554                         return false;
555                 }
556         }
557
558         ContentList a = overlaps (film()->content(), part, position(), end());
559         if (a.size() != 1 || a.front().get() != this) {
560                 why_not = overlapping;
561                 return false;
562         }
563
564         return true;
565 }
566
567 static
568 bool check_video (shared_ptr<const Content> c)
569 {
570         return static_cast<bool>(c->video);
571 }
572
573 bool
574 DCPContent::can_reference_video (string& why_not) const
575 {
576         if (!video) {
577                 why_not = _("There is no video in this DCP");
578                 return false;
579         }
580
581         Resolution video_res = RESOLUTION_2K;
582         if (video->size().width > 2048 || video->size().height > 1080) {
583                 video_res = RESOLUTION_4K;
584         }
585
586         if (film()->resolution() != video_res) {
587                 if (video_res == RESOLUTION_4K) {
588                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
589                         why_not = _("it is 4K and the film is 2K.");
590                 } else {
591                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
592                         why_not = _("it is 2K and the film is 4K.");
593                 }
594                 return false;
595         } else if (film()->frame_size() != video->size()) {
596                 /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
597                 why_not = _("its video frame size differs from the film's.");
598                 return false;
599         }
600
601         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
602         return can_reference (bind (&check_video, _1), _("it overlaps other video content; remove the other content."), why_not);
603 }
604
605 static
606 bool check_audio (shared_ptr<const Content> c)
607 {
608         return static_cast<bool>(c->audio);
609 }
610
611 bool
612 DCPContent::can_reference_audio (string& why_not) const
613 {
614         shared_ptr<DCPDecoder> decoder;
615         try {
616                 decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false));
617         } catch (dcp::DCPReadError) {
618                 /* We couldn't read the DCP, so it's probably missing */
619                 return false;
620         } catch (DCPError) {
621                 /* We couldn't read the DCP, so it's probably missing */
622                 return false;
623         } catch (dcp::KDMDecryptionError) {
624                 /* We have an incorrect KDM */
625                 return false;
626         }
627
628         BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder->reels()) {
629                 if (!i->main_sound()) {
630                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
631                         why_not = _("it does not have sound in all its reels.");
632                         return false;
633                 }
634         }
635
636         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
637         return can_reference (bind (&check_audio, _1), _("it overlaps other audio content; remove the other content."), why_not);
638 }
639
640 static
641 bool check_text (shared_ptr<const Content> c)
642 {
643         return !c->text.empty();
644 }
645
646 bool
647 DCPContent::can_reference_text (TextType type, string& why_not) const
648 {
649         shared_ptr<DCPDecoder> decoder;
650         try {
651                 decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false));
652         } catch (dcp::DCPReadError) {
653                 /* We couldn't read the DCP, so it's probably missing */
654                 return false;
655         } catch (dcp::KDMDecryptionError) {
656                 /* We have an incorrect KDM */
657                 return false;
658         }
659
660         BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder->reels()) {
661                 if (type == TEXT_OPEN_SUBTITLE && !i->main_subtitle()) {
662                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
663                         why_not = _("it does not have open subtitles in all its reels.");
664                         return false;
665                 }
666                 if (type == TEXT_CLOSED_CAPTION && i->closed_captions().empty()) {
667                         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
668                         why_not = _("it does not have closed captions in all its reels.");
669                         return false;
670                 }
671         }
672
673         /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
674         return can_reference (bind (&check_text, _1), _("it overlaps other text content; remove the other content."), why_not);
675 }
676
677 void
678 DCPContent::take_settings_from (shared_ptr<const Content> c)
679 {
680         shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (c);
681         if (!dc) {
682                 return;
683         }
684
685         _reference_video = dc->_reference_video;
686         _reference_audio = dc->_reference_audio;
687         for (int i = 0; i < TEXT_COUNT; ++i) {
688                 _reference_text[i] = dc->_reference_text[i];
689         }
690 }
691
692 void
693 DCPContent::set_cpl (string id)
694 {
695         ChangeSignaller<Content> cc (this, DCPContentProperty::CPL);
696
697         {
698                 boost::mutex::scoped_lock lm (_mutex);
699                 _cpl = id;
700         }
701 }
702
703 bool
704 DCPContent::kdm_timing_window_valid () const
705 {
706         if (!_kdm) {
707                 return true;
708         }
709
710         dcp::LocalTime now;
711         return _kdm->not_valid_before() < now && now < _kdm->not_valid_after();
712 }