X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ftranscoder.cc;h=f4637a05cf1c0f983d9a26bff6edca680b6f5d39;hb=01791aac0b11e9f296cd31a7803e287203bd8355;hp=8c02b76337b258b904d478eb4b1ebaeccd4cbadf;hpb=bd8fa9a370f1739952c83107352baa08c79d095e;p=dcpomatic.git diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index 8c02b7633..f4637a05c 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -25,47 +25,49 @@ */ #include -#include +#include #include "transcoder.h" #include "encoder.h" -#include "decoder_factory.h" +#include "film.h" +#include "video_decoder.h" +#include "audio_decoder.h" +#include "player.h" +#include "job.h" -using namespace std; -using namespace boost; +using std::string; +using boost::shared_ptr; +using boost::dynamic_pointer_cast; /** Construct a transcoder using a Decoder that we create and a supplied Encoder. * @param f Film that we are transcoding. - * @param o Options. * @param j Job that we are running under, or 0. * @param e Encoder to use. */ -Transcoder::Transcoder (shared_ptr f, shared_ptr o, Job* j, shared_ptr e) +Transcoder::Transcoder (shared_ptr f, shared_ptr j) : _job (j) - , _encoder (e) - , _decoder (decoder_factory (f, o, j)) + , _player (f->player ()) + , _encoder (new Encoder (f, j)) { - assert (_encoder); - - _decoder->Video.connect (sigc::mem_fun (*e, &Encoder::process_video)); - _decoder->Audio.connect (sigc::mem_fun (*e, &Encoder::process_audio)); + _player->connect_video (_encoder); + _player->connect_audio (_encoder); } -/** Run the decoder, passing its output to the encoder, until the decoder - * has no more data to present. - */ void Transcoder::go () { - _encoder->process_begin (_decoder->audio_channel_layout()); - try { - _decoder->go (); - } catch (...) { - /* process_end() is important as the decoder may have worker - threads that need to be cleaned up. - */ - _encoder->process_end (); - throw; - } - + _encoder->process_begin (); + while (!_player->pass ()) {} _encoder->process_end (); } + +float +Transcoder::current_encoding_rate () const +{ + return _encoder->current_encoding_rate (); +} + +int +Transcoder::video_frames_out () const +{ + return _encoder->video_frames_out (); +}