using std::min;
using std::make_pair;
using boost::shared_ptr;
+using boost::weak_ptr;
using boost::optional;
using boost::scoped_array;
int const Encoder::_history_size = 25;
/** @param f Film that we are encoding */
-Encoder::Encoder (shared_ptr<const Film> f, shared_ptr<Job> j)
+Encoder::Encoder (shared_ptr<const Film> f, weak_ptr<Job> j)
: _film (f)
, _job (j)
, _video_frames_out (0)
class Encoder : public boost::noncopyable
{
public:
- Encoder (boost::shared_ptr<const Film> f, boost::shared_ptr<Job>);
+ Encoder (boost::shared_ptr<const Film> f, boost::weak_ptr<Job>);
virtual ~Encoder ();
/** Called to indicate that a processing run is about to begin */
/** Film that we are encoding */
boost::shared_ptr<const Film> _film;
- boost::shared_ptr<Job> _job;
+ boost::weak_ptr<Job> _job;
/** Mutex for _time_history and _last_frame */
mutable boost::mutex _state_mutex;
}
if (_packet.stream_index != _video_stream) {
+ av_free_packet (&_packet);
continue;
}
if (fc) {
shared_ptr<FFmpegDecoder> fd (new FFmpegDecoder (_film, fc, _video, _audio));
- fd->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3, _4, 0));
- fd->Audio.connect (bind (&Player::process_audio, this, piece, _1, _2));
- fd->Subtitle.connect (bind (&Player::process_subtitle, this, piece, _1, _2, _3, _4));
+ fd->Video.connect (bind (&Player::process_video, this, weak_ptr<Piece> (piece), _1, _2, _3, _4, 0));
+ fd->Audio.connect (bind (&Player::process_audio, this, weak_ptr<Piece> (piece), _1, _2));
+ fd->Subtitle.connect (bind (&Player::process_subtitle, this, weak_ptr<Piece> (piece), _1, _2, _3, _4));
fd->seek (fc->time_to_content_video_frames (fc->trim_start ()), true);
piece->decoder = fd;
if (!id) {
id.reset (new StillImageDecoder (_film, ic));
- id->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3, _4, 0));
+ id->Video.connect (bind (&Player::process_video, this, weak_ptr<Piece> (piece), _1, _2, _3, _4, 0));
}
piece->decoder = id;
if (!md) {
md.reset (new MovingImageDecoder (_film, mc));
- md->Video.connect (bind (&Player::process_video, this, piece, _1, _2, _3, _4, 0));
+ md->Video.connect (bind (&Player::process_video, this, weak_ptr<Piece> (piece), _1, _2, _3, _4, 0));
}
piece->decoder = md;
shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i);
if (sc) {
shared_ptr<AudioDecoder> sd (new SndfileDecoder (_film, sc));
- sd->Audio.connect (bind (&Player::process_audio, this, piece, _1, _2));
+ sd->Audio.connect (bind (&Player::process_audio, this, weak_ptr<Piece> (piece), _1, _2));
piece->decoder = sd;
}
/** Construct a transcoder using a Decoder that we create and a supplied Encoder.
* @param f Film that we are transcoding.
- * @param j Job that we are running under, or 0.
* @param e Encoder to use.
*/
Transcoder::Transcoder (shared_ptr<const Film> f, shared_ptr<Job> j)
- : _job (j)
- , _player (f->make_player ())
+ : _player (f->make_player ())
, _encoder (new Encoder (f, j))
, _finishing (false)
{
#include "encoder.h"
class Film;
-class Job;
class Encoder;
class VideoFilter;
class Player;
class Transcoder : public boost::noncopyable
{
public:
- Transcoder (
- boost::shared_ptr<const Film> f,
- boost::shared_ptr<Job> j
- );
+ Transcoder (boost::shared_ptr<const Film>, boost::shared_ptr<Job>);
void go ();
}
private:
- /** A Job that is running this Transcoder, or 0 */
- boost::shared_ptr<Job> _job;
boost::shared_ptr<Player> _player;
boost::shared_ptr<Encoder> _encoder;
bool _finishing;
using std::list;
using std::cout;
using boost::shared_ptr;
+using boost::weak_ptr;
int const Writer::_maximum_frames_in_memory = 8;
-Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
+Writer::Writer (shared_ptr<const Film> f, weak_ptr<Job> j)
: _film (f)
, _job (j)
, _first_nonexistant_frame (0)
/* Remove any old DCP */
boost::filesystem::remove_all (_film->dir (_film->dcp_name ()));
- _job->sub (_("Checking existing image data"));
+ shared_ptr<Job> job = _job.lock ();
+
+ job->sub (_("Checking existing image data"));
check_existing_picture_mxf ();
/* Create our picture asset in a subdirectory, named according to those
_thread = new boost::thread (boost::bind (&Writer::thread, this));
- _job->sub (_("Encoding image data"));
+ job->sub (_("Encoding image data"));
}
void
_last_written_eyes = qi.eyes;
if (_film->length()) {
- _job->set_progress (
+ shared_ptr<Job> job = _job.lock ();
+ assert (job);
+ job->set_progress (
float (_full_written + _fake_written + _repeat_written) / _film->time_to_video_frames (_film->length())
);
}
)
));
- _job->sub (_("Computing image digest"));
- _picture_asset->compute_digest (boost::bind (&Job::set_progress, _job.get(), _1, false));
+ shared_ptr<Job> job = _job.lock ();
+ assert (job);
+
+ job->sub (_("Computing image digest"));
+ _picture_asset->compute_digest (boost::bind (&Job::set_progress, job.get(), _1, false));
- _job->sub (_("Computing audio digest"));
- _sound_asset->compute_digest (boost::bind (&Job::set_progress, _job.get(), _1, false));
+ job->sub (_("Computing audio digest"));
+ _sound_asset->compute_digest (boost::bind (&Job::set_progress, job.get(), _1, false));
libdcp::XMLMetadata meta = Config::instance()->dcp_metadata ();
meta.set_issue_date_now ();
while (1) {
- _job->set_progress (float (_first_nonexistant_frame) / N);
+ shared_ptr<Job> job = _job.lock ();
+ assert (job);
+
+ job->set_progress (float (_first_nonexistant_frame) / N);
if (_film->three_d ()) {
if (!check_existing_picture_mxf_frame (mxf, _first_nonexistant_frame, EYES_LEFT)) {
class Writer : public ExceptionStore, public boost::noncopyable
{
public:
- Writer (boost::shared_ptr<const Film>, boost::shared_ptr<Job>);
+ Writer (boost::shared_ptr<const Film>, boost::weak_ptr<Job>);
bool can_fake_write (int) const;
/** our Film */
boost::shared_ptr<const Film> _film;
- boost::shared_ptr<Job> _job;
+ boost::weak_ptr<Job> _job;
/** the first frame index that does not already exist in our MXF */
int _first_nonexistant_frame;