2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/transcoder.cc
21 * @brief A class which takes a FilmState and some Options, then uses those to transcode a Film.
23 * A decoder is selected according to the content type, and the encoder can be specified
24 * as a parameter to the constructor.
28 #include <sigc++/signal.h>
29 #include "transcoder.h"
31 #include "decoder_factory.h"
34 using namespace boost;
36 /** Construct a transcoder using a Decoder that we create and a supplied Encoder.
37 * @param s FilmState of Film that we are transcoding.
39 * @param j Job that we are running under, or 0.
40 * @param l Log that we can write to.
41 * @param e Encoder to use.
43 Transcoder::Transcoder (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Job* j, Log* l, shared_ptr<Encoder> e)
46 , _decoder (decoder_factory (s, o, j, l))
50 _decoder->Video.connect (sigc::mem_fun (*e, &Encoder::process_video));
51 _decoder->Audio.connect (sigc::mem_fun (*e, &Encoder::process_audio));
54 /** Run the decoder, passing its output to the encoder, until the decoder
55 * has no more data to present.
60 _encoder->process_begin (_decoder->audio_channel_layout(), _decoder->audio_sample_format());
64 /* process_end() is important as the decoder may have worker
65 threads that need to be cleaned up.
67 _encoder->process_end ();
71 _encoder->process_end ();