Basics of allowing video parts of FFmpegContent to be disabled (#1355 and others).
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 0e65a6d6b272a67e2f9bdc37bb281f8114684d87..cbde534c30608e97cdd1c673754a95ae6c32bf8b 100644 (file)
@@ -59,7 +59,6 @@ extern "C" {
 
 #include "i18n.h"
 
-
 using std::cout;
 using std::string;
 using std::vector;
@@ -81,7 +80,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp
        , Decoder (film)
        , _have_current_subtitle (false)
 {
-       if (c->video) {
+       if (c->video && c->video->use()) {
                video.reset (new VideoDecoder (this, c));
                _pts_offset = pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->active_video_frame_rate(film));
                /* It doesn't matter what size or pixel format this is, it just needs to be black */
@@ -159,6 +158,12 @@ FFmpegDecoder::flush ()
 bool
 FFmpegDecoder::pass ()
 {
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       if (_ffmpeg_content->encrypted() && !_ffmpeg_content->kdm()) {
+               return true;
+       }
+#endif
+
        int r = av_read_frame (_format_context, &_packet);
 
        /* AVERROR_INVALIDDATA can apparently be returned sometimes even when av_read_frame
@@ -180,7 +185,7 @@ FFmpegDecoder::pass ()
        int const si = _packet.stream_index;
        shared_ptr<const FFmpegContent> fc = _ffmpeg_content;
 
-       if (_video_stream && si == _video_stream.get() && !video->ignore()) {
+       if (_video_stream && si == _video_stream.get() && video && !video->ignore()) {
                decode_video_packet ();
        } else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index(_format_context, si) && !only_text()->ignore()) {
                decode_subtitle_packet ();