Partial hacks to use of libdcp 1.0.
[dcpomatic.git] / src / lib / player.cc
index cb6d519842c5c6cfce1ac92d5f1fe83f74a04e0c..a8ba7cc536b5012cedab2d6f065f972578894a4c 100644 (file)
@@ -270,7 +270,7 @@ Player::emit_video (weak_ptr<Piece> weak_piece, shared_ptr<DecodedVideo> video)
        FrameRateChange frc (content->video_frame_rate(), _film->video_frame_rate());
 
        float const ratio = content->ratio() ? content->ratio()->ratio() : content->video_size_after_crop().ratio();
-       libdcp::Size image_size = fit_ratio_within (ratio, _video_container_size);
+       dcp::Size image_size = fit_ratio_within (ratio, _video_container_size);
        if (_approximate_size) {
                image_size.width &= ~3;
                image_size.height &= ~3;
@@ -346,12 +346,12 @@ Player::emit_audio (weak_ptr<Piece> weak_piece, shared_ptr<DecodedAudio> audio)
        AudioMapping map = content->audio_mapping ();
        for (int i = 0; i < map.content_channels(); ++i) {
                for (int j = 0; j < _film->audio_channels(); ++j) {
-                       if (map.get (i, static_cast<libdcp::Channel> (j)) > 0) {
+                       if (map.get (i, static_cast<dcp::Channel> (j)) > 0) {
                                dcp_mapped->accumulate_channel (
                                        audio->data.get(),
                                        i,
-                                       static_cast<libdcp::Channel> (j),
-                                       map.get (i, static_cast<libdcp::Channel> (j))
+                                       static_cast<dcp::Channel> (j),
+                                       map.get (i, static_cast<dcp::Channel> (j))
                                        );
                        }
                }
@@ -450,6 +450,10 @@ Player::setup_pieces ()
 
        for (ContentList::iterator i = content.begin(); i != content.end(); ++i) {
 
+               if (!(*i)->paths_valid ()) {
+                       continue;
+               }
+               
                shared_ptr<Decoder> decoder;
                optional<FrameRateChange> frc;
 
@@ -547,7 +551,11 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent)
                _have_valid_pieces = false;
                Changed (frequent);
 
-       } else if (property == SubtitleContentProperty::SUBTITLE_OFFSET || property == SubtitleContentProperty::SUBTITLE_SCALE) {
+       } else if (
+               property == SubtitleContentProperty::SUBTITLE_X_OFFSET ||
+               property == SubtitleContentProperty::SUBTITLE_Y_OFFSET ||
+               property == SubtitleContentProperty::SUBTITLE_SCALE
+               ) {
 
                update_subtitle_from_image ();
                update_subtitle_from_text ();
@@ -562,6 +570,7 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent)
 
        } else if (property == ContentProperty::PATH) {
 
+               _have_valid_pieces = false;
                Changed (frequent);
        }
 }
@@ -574,7 +583,7 @@ Player::playlist_changed ()
 }
 
 void
-Player::set_video_container_size (libdcp::Size s)
+Player::set_video_container_size (dcp::Size s)
 {
        _video_container_size = s;
 
@@ -649,9 +658,10 @@ Player::update_subtitle_from_image ()
        assert (sc);
 
        dcpomatic::Rect<double> in_rect = _image_subtitle.subtitle->rect;
-       libdcp::Size scaled_size;
+       dcp::Size scaled_size;
 
-       in_rect.y += sc->subtitle_offset ();
+       in_rect.x += sc->subtitle_x_offset ();
+       in_rect.y += sc->subtitle_y_offset ();
 
        /* We will scale the subtitle up to fit _video_container_size, and also by the additional subtitle_scale */
        scaled_size.width = in_rect.width * _video_container_size.width * sc->subtitle_scale ();
@@ -679,8 +689,8 @@ Player::update_subtitle_from_image ()
                true
                );
        
-       _out_subtitle.from = _image_subtitle.subtitle->dcp_time;
-       _out_subtitle.to = _image_subtitle.subtitle->dcp_time_to;
+       _out_subtitle.from = _image_subtitle.subtitle->dcp_time + piece->content->position ();
+       _out_subtitle.to = _image_subtitle.subtitle->dcp_time_to + piece->content->position ();
 }
 
 /** Re-emit the last frame that was emitted, using current settings for crop, ratio, scaler and subtitles.
@@ -721,8 +731,8 @@ Player::set_approximate_size ()
 PlayerImage::PlayerImage (
        shared_ptr<const Image> in,
        Crop crop,
-       libdcp::Size inter_size,
-       libdcp::Size out_size,
+       dcp::Size inter_size,
+       dcp::Size out_size,
        Scaler const * scaler
        )
        : _in (in)