using boost::shared_ptr;
/** @param f Film to compare.
- * @param o Decode options.
*/
-ABTranscodeJob::ABTranscodeJob (shared_ptr<Film> f, DecodeOptions o)
+ABTranscodeJob::ABTranscodeJob (shared_ptr<Film> f)
: Job (f)
- , _decode_opt (o)
{
_film_b.reset (new Film (*_film));
_film_b->set_scaler (Config::instance()->reference_scaler ());
{
try {
/* _film_b is the one with reference filters */
- ABTranscoder w (_film_b, _film, _decode_opt, shared_from_this ());
+ ABTranscoder w (_film_b, _film, shared_from_this ());
w.go ();
set_progress (1);
set_state (FINISHED_OK);
#include <boost/shared_ptr.hpp>
#include "job.h"
-#include "options.h"
class Film;
{
public:
ABTranscodeJob (
- boost::shared_ptr<Film> f,
- DecodeOptions o
+ boost::shared_ptr<Film> f
);
std::string name () const;
private:
/** Copy of our Film using the reference filters and scaler */
boost::shared_ptr<Film> _film_b;
- DecodeOptions _decode_opt;
};
#include "film.h"
#include "encoder.h"
#include "job.h"
-#include "options.h"
#include "image.h"
#include "playlist.h"
#include "matcher.h"
* @param e Encoder to use.
*/
-ABTranscoder::ABTranscoder (shared_ptr<Film> a, shared_ptr<Film> b, DecodeOptions o, shared_ptr<Job> j)
+ABTranscoder::ABTranscoder (shared_ptr<Film> a, shared_ptr<Film> b, shared_ptr<Job> j)
: _film_a (a)
, _film_b (b)
, _playlist_a (_film_a->playlist ())
ABTranscoder (
boost::shared_ptr<Film> a,
boost::shared_ptr<Film> b,
- DecodeOptions o,
boost::shared_ptr<Job> j
);
#include "analyse_audio_job.h"
#include "compose.hpp"
#include "film.h"
-#include "options.h"
#include "playlist.h"
#include "i18n.h"
using boost::optional;
using boost::shared_ptr;
-AudioDecoder::AudioDecoder (shared_ptr<const Film> f, shared_ptr<AudioContent> c, DecodeOptions o)
- : Decoder (f, o)
+AudioDecoder::AudioDecoder (shared_ptr<const Film> f, shared_ptr<AudioContent> c)
+ : Decoder (f)
{
}
class AudioDecoder : public AudioSource, public virtual Decoder
{
public:
- AudioDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>, DecodeOptions);
+ AudioDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>);
};
#endif
#include "dcp_video_frame.h"
#include "lut.h"
#include "config.h"
-#include "options.h"
#include "exceptions.h"
#include "server.h"
#include "util.h"
#include <iostream>
#include "film.h"
-#include "options.h"
#include "exceptions.h"
#include "util.h"
#include "decoder.h"
/** @param f Film.
* @param o Decode options.
*/
-Decoder::Decoder (shared_ptr<const Film> f, DecodeOptions o)
+Decoder::Decoder (shared_ptr<const Film> f)
: _film (f)
- , _opt (o)
{
_film_connection = f->Changed.connect (bind (&Decoder::film_changed, this, _1));
}
#include "video_source.h"
#include "audio_source.h"
#include "film.h"
-#include "options.h"
class Image;
class Log;
class Decoder
{
public:
- Decoder (boost::shared_ptr<const Film>, DecodeOptions);
+ Decoder (boost::shared_ptr<const Film>);
virtual ~Decoder () {}
virtual bool pass () = 0;
protected:
boost::shared_ptr<const Film> _film;
- /** our decode options */
- DecodeOptions _opt;
private:
virtual void film_changed (Film::Property) {}
Decoders
decoder_factory (
- shared_ptr<Film> f, DecodeOptions o
+ shared_ptr<Film> f
)
{
return Decoders ();
* @brief A method to create appropriate decoders for some content.
*/
-#include "options.h"
-
class Film;
class VideoDecoder;
class AudioDecoder;
};
extern Decoders decoder_factory (
- boost::shared_ptr<Film>, DecodeOptions
+ boost::shared_ptr<Film>
);
#endif
#include <libdcp/picture_asset.h>
#include "encoder.h"
#include "util.h"
-#include "options.h"
#include "film.h"
#include "log.h"
#include "exceptions.h"
#include <boost/filesystem.hpp>
#include "examine_content_job.h"
-#include "options.h"
#include "log.h"
#include "content.h"
#include "ffmpeg_content.h"
#include "ffmpeg_decoder.h"
-#include "options.h"
#include "compose.hpp"
#include "job.h"
#include "util.h"
job->set_progress_unknown ();
- DecodeOptions o;
- o.decode_audio = false;
- shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), o));
+ shared_ptr<FFmpegDecoder> decoder (new FFmpegDecoder (film, shared_from_this (), true, false, false, true));
ContentVideoFrame video_length = 0;
if (quick) {
#include "transcoder.h"
#include "job.h"
#include "filter.h"
-#include "options.h"
#include "exceptions.h"
#include "image.h"
#include "util.h"
using boost::dynamic_pointer_cast;
using libdcp::Size;
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<FFmpegContent> c, DecodeOptions o)
- : Decoder (f, o)
- , VideoDecoder (f, c, o)
- , AudioDecoder (f, c, o)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<FFmpegContent> c, bool video, bool audio, bool subtitles, bool video_sync)
+ : Decoder (f)
+ , VideoDecoder (f, c)
+ , AudioDecoder (f, c)
, _ffmpeg_content (c)
, _format_context (0)
, _video_stream (-1)
, _audio_codec (0)
, _subtitle_codec_context (0)
, _subtitle_codec (0)
+ , _decode_video (video)
+ , _decode_audio (audio)
+ , _decode_subtitles (subtitles)
+ , _video_sync (video_sync)
{
setup_general ();
setup_video ();
setup_audio ();
setup_subtitle ();
- if (!o.video_sync) {
+ if (!video_sync) {
_first_video = 0;
}
}
int frame_finished;
- if (_opt.decode_video) {
+ if (_decode_video) {
while (avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet) >= 0 && frame_finished) {
filter_and_emit_video (_frame);
}
}
- if (_ffmpeg_content->audio_stream() && _opt.decode_audio) {
+ if (_ffmpeg_content->audio_stream() && _decode_audio) {
decode_audio_packet ();
}
avcodec_get_frame_defaults (_frame);
- if (_packet.stream_index == _video_stream && _opt.decode_video) {
+ if (_packet.stream_index == _video_stream && _decode_video) {
int frame_finished;
int const r = avcodec_decode_video2 (_video_codec_context, _frame, &frame_finished, &_packet);
_film->log()->log (String::compose (N_("Used only %1 bytes of %2 in packet"), r, _packet.size));
}
- if (_opt.video_sync) {
+ if (_video_sync) {
out_with_sync ();
} else {
filter_and_emit_video (_frame);
}
}
- } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _opt.decode_audio) {
+ } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _decode_audio) {
decode_audio_packet ();
- } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _opt.decode_subtitles && _first_video) {
+ } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && _decode_subtitles && _first_video) {
int got_subtitle;
AVSubtitle sub;
was before this packet. Until then audio is thrown away.
*/
- if ((_first_video && _first_video.get() <= source_pts_seconds) || !_opt.decode_video) {
+ if ((_first_video && _first_video.get() <= source_pts_seconds) || !_decode_video) {
- if (!_first_audio && _opt.decode_video) {
+ if (!_first_audio && _decode_video) {
_first_audio = source_pts_seconds;
/* This is our first audio frame, and if we've arrived here we must have had our
class FFmpegDecoder : public VideoDecoder, public AudioDecoder
{
public:
- FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>, DecodeOptions);
+ FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>, bool video, bool audio, bool subtitles, bool video_sync);
~FFmpegDecoder ();
float frames_per_second () const;
std::vector<FFmpegSubtitleStream> _subtitle_streams;
std::vector<FFmpegAudioStream> _audio_streams;
+
+ bool _decode_video;
+ bool _decode_audio;
+ bool _decode_subtitles;
+ bool _video_sync;
};
#include "transcode_job.h"
#include "scp_dcp_job.h"
#include "log.h"
-#include "options.h"
#include "exceptions.h"
#include "examine_content_job.h"
#include "scaler.h"
throw MissingSettingError (_("name"));
}
- DecodeOptions od;
- od.decode_subtitles = with_subtitles ();
-
shared_ptr<Job> r;
if (dcp_ab()) {
- r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this(), od)));
+ r = JobManager::instance()->add (shared_ptr<Job> (new ABTranscodeJob (shared_from_this())));
} else {
- r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this(), od)));
+ r = JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this())));
}
}
using boost::shared_ptr;
using libdcp::Size;
-ImageMagickDecoder::ImageMagickDecoder (
- shared_ptr<const Film> f, shared_ptr<ImageMagickContent> c, DecodeOptions o)
- : Decoder (f, o)
- , VideoDecoder (f, c, o)
+ImageMagickDecoder::ImageMagickDecoder (shared_ptr<const Film> f, shared_ptr<ImageMagickContent> c)
+ : Decoder (f)
+ , VideoDecoder (f, c)
, _imagemagick_content (c)
, _position (0)
{
class ImageMagickDecoder : public VideoDecoder
{
public:
- ImageMagickDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<ImageMagickContent>, DecodeOptions);
+ ImageMagickDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<ImageMagickContent>);
float frames_per_second () const {
/* We don't know */
+++ /dev/null
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef DVDOMATIC_OPTIONS_H
-#define DVDOMATIC_OPTIONS_H
-
-/** @file src/options.h
- * @brief Options for a decoding operation.
- */
-
-class DecodeOptions
-{
-public:
- DecodeOptions ()
- : decode_video (true)
- , decode_audio (true)
- , decode_subtitles (false)
- , video_sync (true)
- {}
-
- bool decode_video;
- bool decode_audio;
- bool decode_subtitles;
- bool video_sync;
-};
-
-#endif
using boost::dynamic_pointer_cast;
Playlist::Playlist (shared_ptr<const Film> f, list<shared_ptr<Content> > c)
- : _video_from (VIDEO_NONE)
+ : _film (f)
+ , _video_from (VIDEO_NONE)
, _audio_from (AUDIO_NONE)
+ , _have_setup_decoders (false)
, _ffmpeg_decoder_done (false)
+ , _video_sync (true)
{
for (list<shared_ptr<Content> >::const_iterator i = c.begin(); i != c.end(); ++i) {
shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i);
_audio_from = AUDIO_SNDFILE;
}
}
-
- if (_video_from == VIDEO_FFMPEG || _audio_from == AUDIO_FFMPEG) {
- DecodeOptions o;
- /* XXX: decodeoptions */
- _ffmpeg_decoder.reset (new FFmpegDecoder (f, _ffmpeg, o));
- }
-
- if (_video_from == VIDEO_FFMPEG) {
- _ffmpeg_decoder->connect_video (shared_from_this ());
- }
-
- if (_audio_from == AUDIO_FFMPEG) {
- _ffmpeg_decoder->connect_audio (shared_from_this ());
- }
-
- if (_video_from == VIDEO_IMAGEMAGICK) {
- for (list<shared_ptr<ImageMagickContent> >::iterator i = _imagemagick.begin(); i != _imagemagick.end(); ++i) {
- DecodeOptions o;
- /* XXX: decodeoptions */
- shared_ptr<ImageMagickDecoder> d (new ImageMagickDecoder (f, *i, o));
- _imagemagick_decoders.push_back (d);
- d->connect_video (shared_from_this ());
- }
-
- _imagemagick_decoder = _imagemagick_decoders.begin ();
- }
-
- if (_audio_from == AUDIO_SNDFILE) {
- for (list<shared_ptr<SndfileContent> >::iterator i = _sndfile.begin(); i != _sndfile.end(); ++i) {
- DecodeOptions o;
- /* XXX: decodeoptions */
- shared_ptr<SndfileDecoder> d (new SndfileDecoder (f, *i, o));
- _sndfile_decoders.push_back (d);
- d->connect_audio (shared_from_this ());
- }
- }
}
ContentAudioFrame
return libdcp::Size ();
}
+ContentVideoFrame
+Playlist::video_length () const
+{
+ switch (_video_from) {
+ case VIDEO_NONE:
+ return 0;
+ case VIDEO_FFMPEG:
+ return _ffmpeg->video_length ();
+ case VIDEO_IMAGEMAGICK:
+ {
+ ContentVideoFrame l = 0;
+ for (list<shared_ptr<ImageMagickContent> >::const_iterator i = _imagemagick.begin(); i != _imagemagick.end(); ++i) {
+ l += (*i)->video_length ();
+ }
+ return l;
+ }
+ }
+
+ return 0;
+}
+
bool
Playlist::has_audio () const
{
_video_from = VIDEO_NONE;
}
+void
+Playlist::disable_audio ()
+{
+ _audio_from = AUDIO_NONE;
+}
+
+void
+Playlist::disable_subtitles ()
+{
+ /* XXX */
+}
+
bool
Playlist::pass ()
{
+ if (!_have_setup_decoders) {
+ setup_decoders ();
+ _have_setup_decoders = true;
+ }
+
bool done = true;
if (_video_from == VIDEO_FFMPEG || _audio_from == AUDIO_FFMPEG) {
Audio (b);
}
+bool
+Playlist::seek (double t)
+{
+ bool r = false;
+
+ switch (_video_from) {
+ case VIDEO_NONE:
+ break;
+ case VIDEO_FFMPEG:
+ if (_ffmpeg_decoder->seek (t)) {
+ r = true;
+ }
+ break;
+ case VIDEO_IMAGEMAGICK:
+ if ((*_imagemagick_decoder)->seek (t)) {
+ r = true;
+ }
+ break;
+ }
+
+ /* XXX: don't seek audio because we don't need to... */
+
+ return r;
+}
+
+bool
+Playlist::seek_to_last ()
+{
+ bool r = false;
+
+ switch (_video_from) {
+ case VIDEO_NONE:
+ break;
+ case VIDEO_FFMPEG:
+ if (_ffmpeg_decoder->seek_to_last ()) {
+ r = true;
+ }
+ break;
+ case VIDEO_IMAGEMAGICK:
+ if ((*_imagemagick_decoder)->seek_to_last ()) {
+ r = true;
+ }
+ break;
+ }
+
+ /* XXX: don't seek audio because we don't need to... */
+
+ return r;
+}
+
+void
+Playlist::setup_decoders ()
+{
+ if (_video_from == VIDEO_FFMPEG || _audio_from == AUDIO_FFMPEG) {
+ _ffmpeg_decoder.reset (
+ new FFmpegDecoder (
+ _film, _ffmpeg, _video_from == VIDEO_FFMPEG, _audio_from == AUDIO_FFMPEG, _film->with_subtitles(), _video_sync
+ )
+ );
+ }
+
+ if (_video_from == VIDEO_FFMPEG) {
+ _ffmpeg_decoder->connect_video (shared_from_this ());
+ }
+
+ if (_audio_from == AUDIO_FFMPEG) {
+ _ffmpeg_decoder->connect_audio (shared_from_this ());
+ }
+
+ if (_video_from == VIDEO_IMAGEMAGICK) {
+ for (list<shared_ptr<ImageMagickContent> >::iterator i = _imagemagick.begin(); i != _imagemagick.end(); ++i) {
+ shared_ptr<ImageMagickDecoder> d (new ImageMagickDecoder (_film, *i));
+ _imagemagick_decoders.push_back (d);
+ d->connect_video (shared_from_this ());
+ }
+
+ _imagemagick_decoder = _imagemagick_decoders.begin ();
+ }
+
+ if (_audio_from == AUDIO_SNDFILE) {
+ for (list<shared_ptr<SndfileContent> >::iterator i = _sndfile.begin(); i != _sndfile.end(); ++i) {
+ shared_ptr<SndfileDecoder> d (new SndfileDecoder (_film, *i));
+ _sndfile_decoders.push_back (d);
+ d->connect_audio (shared_from_this ());
+ }
+ }
+}
+
+void
+Playlist::disable_video_sync ()
+{
+ _video_sync = false;
+}
float video_frame_rate () const;
libdcp::Size video_size () const;
+ ContentVideoFrame video_length () const;
void disable_video ();
+ void disable_audio ();
+ void disable_subtitles ();
+ void disable_video_sync ();
bool pass ();
void set_progress (boost::shared_ptr<Job>);
+ bool seek (double);
+ bool seek_to_last ();
private:
void process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s);
void process_audio (boost::shared_ptr<AudioBuffers>);
+ void setup_decoders ();
+ boost::shared_ptr<const Film> _film;
+
enum {
VIDEO_NONE,
VIDEO_FFMPEG,
std::list<boost::shared_ptr<ImageMagickContent> > _imagemagick;
std::list<boost::shared_ptr<SndfileContent> > _sndfile;
+ bool _have_setup_decoders;
boost::shared_ptr<FFmpegDecoder> _ffmpeg_decoder;
bool _ffmpeg_decoder_done;
std::list<boost::shared_ptr<ImageMagickDecoder> > _imagemagick_decoders;
std::list<boost::shared_ptr<ImageMagickDecoder> >::iterator _imagemagick_decoder;
std::list<boost::shared_ptr<SndfileDecoder> > _sndfile_decoders;
+
+ bool _video_sync;
};
/* XXX */
-SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<SndfileContent> c, DecodeOptions o)
- : Decoder (f, o)
- , AudioDecoder (f, c, o)
+SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<SndfileContent> c)
+ : Decoder (f)
+ , AudioDecoder (f, c)
{
sf_count_t frames;
SNDFILE* sf = open_file (frames);
class SndfileDecoder : public AudioDecoder
{
public:
- SndfileDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<SndfileContent>, DecodeOptions);
+ SndfileDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<SndfileContent>);
bool pass ();
using boost::shared_ptr;
/** @param s Film to use.
- * @param o Decode options.
*/
-TranscodeJob::TranscodeJob (shared_ptr<Film> f, DecodeOptions o)
+TranscodeJob::TranscodeJob (shared_ptr<Film> f)
: Job (f)
- , _decode_opt (o)
{
}
_film->log()->log (N_("Transcode job starting"));
_film->log()->log (String::compose (N_("Audio delay is %1ms"), _film->audio_delay()));
- Transcoder w (_film, _decode_opt, shared_from_this ());
+ Transcoder w (_film, shared_from_this ());
w.go ();
set_progress (1);
set_state (FINISHED_OK);
#include <boost/shared_ptr.hpp>
#include "job.h"
-#include "options.h"
class Encoder;
class TranscodeJob : public Job
{
public:
- TranscodeJob (boost::shared_ptr<Film> f, DecodeOptions od);
+ TranscodeJob (boost::shared_ptr<Film> f);
std::string name () const;
void run ();
protected:
int remaining_time () const;
-
-private:
- DecodeOptions _decode_opt;
};
#include "film.h"
#include "matcher.h"
#include "delay_line.h"
-#include "options.h"
#include "gain.h"
#include "video_decoder.h"
#include "audio_decoder.h"
/** Construct a transcoder using a Decoder that we create and a supplied Encoder.
* @param f Film that we are transcoding.
- * @param o Decode options.
* @param j Job that we are running under, or 0.
* @param e Encoder to use.
*/
-Transcoder::Transcoder (shared_ptr<Film> f, DecodeOptions o, shared_ptr<Job> j)
+Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<Job> j)
: _job (j)
, _playlist (f->playlist ())
, _encoder (new Encoder (f, _playlist))
*/
/** @file src/transcoder.h
- * @brief A class which takes a Film and some Options, then uses those to transcode the film.
*
* A decoder is selected according to the content type, and the encoder can be specified
* as a parameter to the constructor.
class Playlist;
/** @class Transcoder
- * @brief A class which takes a Film and some Options, then uses those to transcode the film.
*
* A decoder is selected according to the content type, and the encoder can be specified
* as a parameter to the constructor.
public:
Transcoder (
boost::shared_ptr<Film> f,
- DecodeOptions o,
boost::shared_ptr<Job> j
);
#include "film.h"
#include "image.h"
#include "log.h"
-#include "options.h"
#include "job.h"
#include "i18n.h"
using boost::shared_ptr;
using boost::optional;
-VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<VideoContent> c, DecodeOptions o)
- : Decoder (f, o)
+VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<VideoContent> c)
+ : Decoder (f)
, _video_frame (0)
, _last_source_time (0)
{
class VideoDecoder : public VideoSource, public virtual Decoder
{
public:
- VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<VideoContent>, DecodeOptions);
+ VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<VideoContent>);
/** @return video frames per second, or 0 if unknown */
virtual float frames_per_second () const = 0;
#include "scaler.h"
#include "server.h"
#include "dcp_video_frame.h"
-#include "options.h"
#include "decoder.h"
#include "exceptions.h"
#include "scaler.h"
server = new ServerDescription (server_host, 1);
shared_ptr<Film> film (new Film (film_dir, true));
- DecodeOptions opt;
- opt.decode_audio = false;
- opt.decode_subtitles = true;
- opt.video_sync = true;
+ /* XXX */
+// opt.decode_audio = false;
+// opt.decode_subtitles = true;
+// opt.video_sync = true;
- Decoders decoders = decoder_factory (film, opt);
+ Decoders decoders = decoder_factory (film);
try {
decoders.video->Video.connect (boost::bind (process_video, _1, _2, _3));
bool done = false;
s->Add (_content, 1, wxEXPAND | wxTOP | wxBOTTOM, 6);
_content->InsertColumn (0, "");
+ _content->SetColumnWidth (0, 512);
wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
_content_add = new wxButton (_content_panel, wxID_ANY, _("Add..."));
#include "lib/format.h"
#include "lib/util.h"
#include "lib/job_manager.h"
-#include "lib/options.h"
#include "lib/subtitle.h"
#include "lib/image.h"
#include "lib/scaler.h"
#include "lib/exceptions.h"
#include "lib/examine_content_job.h"
#include "lib/filter.h"
+#include "lib/playlist.h"
#include "film_viewer.h"
#include "wx_util.h"
#include "video_decoder.h"
break;
case Film::CONTENT:
{
- DecodeOptions o;
- o.decode_audio = false;
- o.decode_subtitles = true;
- o.video_sync = false;
-
- try {
- _decoders = decoder_factory (_film, o);
- } catch (StringError& e) {
- error_dialog (this, wxString::Format (_("Could not open content file (%s)"), std_to_wx(e.what()).data()));
- return;
- }
-
- if (_decoders.video == 0) {
- break;
- }
- _decoders.video->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
- _decoders.video->OutputChanged.connect (boost::bind (&FilmViewer::decoder_changed, this));
-// _decoders.video->set_subtitle_stream (_film->subtitle_stream());
+ _playlist = _film->playlist ();
+ _playlist->disable_audio ();
+ _playlist->disable_subtitles ();
+ _playlist->disable_video_sync ();
+
+ _playlist->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
+// _playlist->OutputChanged.connect (boost::bind (&FilmViewer::decoder_changed, this));
calculate_sizes ();
get_frame ();
_panel->Refresh ();
update_from_raw ();
break;
case Film::SUBTITLE_STREAM:
- if (_decoders.video) {
+// if (_decoders.video) {
// _decoders.video->set_subtitle_stream (_film->subtitle_stream ());
- }
+// }
break;
default:
break;
void
FilmViewer::decoder_changed ()
{
- if (_decoders.video == 0 || _decoders.video->seek_to_last ()) {
+ if (!_playlist == 0 || _playlist->seek_to_last ()) {
return;
}
void
FilmViewer::timer (wxTimerEvent &)
{
- if (!_film || !_decoders.video) {
+ if (!_playlist) {
return;
}
get_frame ();
-// if (_film->length()) {
-// int const new_slider_position = 4096 * _decoders.video->last_source_time() / (_film->length().get() / _film->source_frame_rate());
+// if (_playlist->video_length()) {
+// int const new_slider_position = 4096 * _playlist->last_source_time() / (_film->length().get() / _film->source_frame_rate());
// if (new_slider_position != _slider->GetValue()) {
// _slider->SetValue (new_slider_position);
// }
void
FilmViewer::slider_moved (wxScrollEvent &)
{
-// if (!_film || !_film->length() || !_decoders.video) {
-// return;
-// }
+ if (!_film || !_playlist) {
+ return;
+ }
-// if (_decoders.video->seek (_slider->GetValue() * _film->length().get() / (4096 * _film->source_frame_rate()))) {
-// return;
-// }
+ if (_playlist->seek (_slider->GetValue() * _playlist->video_length() / (4096 * _playlist->video_frame_rate()))) {
+ return;
+ }
get_frame ();
_panel->Refresh ();
void
FilmViewer::calculate_sizes ()
{
- if (!_film) {
+ if (!_film || !_playlist) {
return;
}
of our _display_frame.
*/
_display_frame_x = 0;
-// if (format) {
-// _display_frame_x = static_cast<float> (format->dcp_padding (_film)) * _out_size.width / format->dcp_size().width;
-// }
+ if (format) {
+ _display_frame_x = static_cast<float> (format->dcp_padding (_playlist)) * _out_size.width / format->dcp_size().width;
+ }
_film_size = _out_size;
_film_size.width -= _display_frame_x * 2;
/* Clear our raw frame in case we don't get a new one */
_raw_frame.reset ();
- if (_decoders.video == 0) {
+ if (!_playlist) {
_display_frame.reset ();
return;
}
try {
_got_frame = false;
while (!_got_frame) {
- if (_decoders.video->pass ()) {
+ if (_playlist->pass ()) {
/* We didn't get a frame before the decoder gave up,
so clear our display frame.
*/
void active_jobs_changed (bool);
boost::shared_ptr<Film> _film;
+ boost::shared_ptr<Playlist> _playlist;
wxSizer* _v_sizer;
wxPanel* _panel;
wxToggleButton* _play_button;
wxTimer _timer;
- Decoders _decoders;
boost::shared_ptr<Image> _raw_frame;
boost::shared_ptr<Subtitle> _raw_sub;
boost::shared_ptr<Image> _display_frame;