#include "film.h"
#include "config.h"
#include "compose.hpp"
+#include "dcp_decoder.h"
#include <dcp/dcp.h>
#include <dcp/exceptions.h>
+#include <dcp/reel_picture_asset.h>
+#include <dcp/reel.h>
#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
#include <iterator>
#include <iostream>
signal_changed (DCPContentProperty::REFERENCE_SUBTITLE);
}
+
+list<DCPTime>
+DCPContent::reel_split_points () const
+{
+ list<DCPTime> s;
+ DCPDecoder decoder (shared_from_this(), false);
+ DCPTime t = position();
+
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder.reels()) {
+ s.push_back (t);
+ t += DCPTime::from_frames (k->main_picture()->duration(), film->video_frame_rate());
+ }
+
+ return s;
+}
return boost::dynamic_pointer_cast<DCPContent> (Content::shared_from_this ());
}
+ boost::shared_ptr<const DCPContent> shared_from_this () const {
+ return boost::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
+ }
+
DCPTime full_length () const;
void examine (boost::shared_ptr<Job>);
std::string identifier () const;
void set_default_colour_conversion ();
+ std::list<DCPTime> reel_split_points () const;
/* SubtitleContent */
s << "[DCP " << t.get() << " " << t.seconds() << "s]";
return s;
}
+
+ostream &
+operator<< (ostream& s, DCPTimePeriod p)
+{
+ s << "[DCP " << p.from.get() << " " << p.from.seconds() << "s -> " << p.to.get() << " " << p.to.seconds() << "s]";
+ return s;
+}
ContentTime max (ContentTime a, ContentTime b);
std::ostream& operator<< (std::ostream& s, ContentTime t);
std::ostream& operator<< (std::ostream& s, DCPTime t);
+std::ostream& operator<< (std::ostream& s, DCPTimePeriod p);
#endif
case REELTYPE_SINGLE:
p.push_back (DCPTimePeriod (DCPTime (), len));
break;
- case REELTYPE_ONE_PER_VIDEO:
+ case REELTYPE_BY_VIDEO_CONTENT:
{
optional<DCPTime> last;
BOOST_FOREACH (shared_ptr<Content> c, content ()) {
shared_ptr<VideoContent> v = dynamic_pointer_cast<VideoContent> (c);
if (v) {
- if (last) {
- p.push_back (DCPTimePeriod (last.get(), v->position ()));
+ BOOST_FOREACH (DCPTime t, v->reel_split_points()) {
+ if (last) {
+ p.push_back (DCPTimePeriod (last.get(), t));
+ }
+ last = t;
}
- last = v->position ();
}
}
if (last) {
return p;
}
-
#include "dcp_subtitle_decoder.h"
#include "audio_processor.h"
#include "playlist.h"
+#include "referenced_reel_asset.h"
#include <dcp/reel.h>
#include <dcp/reel_sound_asset.h>
#include <dcp/reel_subtitle_asset.h>
_have_valid_pieces = false;
}
-list<shared_ptr<dcp::ReelAsset> >
+list<ReferencedReelAsset>
Player::get_reel_assets ()
{
- list<shared_ptr<dcp::ReelAsset> > a;
+ list<ReferencedReelAsset> a;
BOOST_FOREACH (shared_ptr<Content> i, _playlist->content ()) {
shared_ptr<DCPContent> j = dynamic_pointer_cast<DCPContent> (i);
if (!j) {
continue;
}
- /* XXX: hack hack hack */
DCPDecoder decoder (j, false);
- if (j->reference_video ()) {
- a.push_back (decoder.reels().front()->main_picture ());
- }
- if (j->reference_audio ()) {
- a.push_back (decoder.reels().front()->main_sound ());
- }
- if (j->reference_subtitle ()) {
- a.push_back (decoder.reels().front()->main_subtitle ());
+ int64_t offset = 0;
+ BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder.reels()) {
+ DCPTime const from = i->position() + DCPTime::from_frames (offset, _film->video_frame_rate());
+ if (j->reference_video ()) {
+ a.push_back (
+ ReferencedReelAsset (
+ k->main_picture (),
+ DCPTimePeriod (from, from + DCPTime::from_frames (k->main_picture()->duration(), _film->video_frame_rate()))
+ )
+ );
+ }
+
+ if (j->reference_audio ()) {
+ a.push_back (
+ ReferencedReelAsset (
+ k->main_sound (),
+ DCPTimePeriod (from, from + DCPTime::from_frames (k->main_sound()->duration(), _film->video_frame_rate()))
+ )
+ );
+ }
+
+ if (j->reference_subtitle ()) {
+ a.push_back (
+ ReferencedReelAsset (
+ k->main_subtitle (),
+ DCPTimePeriod (from, from + DCPTime::from_frames (k->main_subtitle()->duration(), _film->video_frame_rate()))
+ )
+ );
+ }
+
+ /* Assume that main picture duration is the length of the reel */
+ offset += k->main_picture()->duration ();
}
}
class Playlist;
class Font;
class AudioBuffers;
+class ReferencedReelAsset;
/** @class Player
* @brief A class which can `play' a Playlist.
boost::shared_ptr<AudioBuffers> get_audio (DCPTime time, DCPTime length, bool accurate);
PlayerSubtitles get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt);
std::list<boost::shared_ptr<Font> > get_subtitle_fonts ();
- std::list<boost::shared_ptr<dcp::ReelAsset> > get_reel_assets ();
+ std::list<ReferencedReelAsset> get_reel_assets ();
void set_video_container_size (dcp::Size);
void set_ignore_video ();
#include "job.h"
#include "writer.h"
#include "compose.hpp"
+#include "referenced_reel_asset.h"
#include "subtitle_content.h"
#include <boost/signals2.hpp>
#include <boost/foreach.hpp>
}
}
- /* XXX: we should be passing through details of positions, at least... */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> i, _player->get_reel_assets ()) {
+ BOOST_FOREACH (ReferencedReelAsset i, _player->get_reel_assets ()) {
_writer->write (i);
}
enum ReelType
{
REELTYPE_SINGLE,
- REELTYPE_ONE_PER_VIDEO,
+ REELTYPE_BY_VIDEO_CONTENT,
REELTYPE_BY_LENGTH
};
p.push_back (make_pair (_("Video size"), raw_convert<string> (video_size().width) + "x" + raw_convert<string> (video_size().height)));
p.push_back (make_pair (_("Video frame rate"), raw_convert<string> (video_frame_rate()) + " " + _("frames per second")));
}
+
+list<DCPTime>
+VideoContent::reel_split_points () const
+{
+ list<DCPTime> t;
+ t.push_back (position ());
+ return t;
+}
virtual void set_default_colour_conversion ();
+ /** @return points at which to split this content when
+ * REELTYPE_BY_VIDEO_CONTENT is in use.
+ */
+ virtual std::list<DCPTime> reel_split_points () const;
+
Frame video_length () const {
boost::mutex::scoped_lock lm (_mutex);
return _video_length;
#include "version.h"
#include "font.h"
#include "util.h"
+#include "referenced_reel_asset.h"
#include <dcp/mono_picture_asset.h>
#include <dcp/stereo_picture_asset.h>
#include <dcp/sound_asset.h>
reel_picture_asset.reset (new dcp::ReelStereoPictureAsset (stereo, 0));
}
} else {
- /* We don't have a picture asset of our own; maybe we need to reference one */
- /* XXX: this is all a hack */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
- shared_ptr<dcp::ReelPictureAsset> k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j);
- if (k) {
+ /* We don't have a picture asset of our own; hopefully we have one to reference */
+ BOOST_FOREACH (ReferencedReelAsset j, _reel_assets) {
+ shared_ptr<dcp::ReelPictureAsset> k = dynamic_pointer_cast<dcp::ReelPictureAsset> (j.asset);
+ if (k && j.period == i.period) {
reel_picture_asset = k;
}
}
/* We have made a sound asset of our own. Put it into the reel */
reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (i.sound_asset, 0)));
} else {
- /* We don't have a sound asset of our own; maybe we need to reference one */
- /* XXX: this is all a hack */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
- if (dynamic_pointer_cast<dcp::ReelSoundAsset> (j)) {
- reel->add (j);
+ /* We don't have a sound asset of our own; hopefully we have one to reference */
+ BOOST_FOREACH (ReferencedReelAsset j, _reel_assets) {
+ shared_ptr<dcp::ReelSoundAsset> k = dynamic_pointer_cast<dcp::ReelSoundAsset> (j.asset);
+ if (k && j.period == i.period) {
+ reel->add (k);
}
}
}
)
));
} else {
- /* We don't have a subtitle asset of our own; maybe we need to reference one */
- /* XXX: this is all a hack */
- BOOST_FOREACH (shared_ptr<dcp::ReelAsset> j, _reel_assets) {
- if (dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j)) {
- reel->add (j);
+ /* We don't have a subtitle asset of our own; hopefully we have one to reference */
+ BOOST_FOREACH (ReferencedReelAsset j, _reel_assets) {
+ shared_ptr<dcp::ReelSubtitleAsset> k = dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j.asset);
+ if (k && j.period == i.period) {
+ reel->add (k);
}
}
}
}
void
-Writer::write (shared_ptr<dcp::ReelAsset> asset)
+Writer::write (ReferencedReelAsset asset)
{
_reel_assets.push_back (asset);
}
class AudioBuffers;
class Job;
class Font;
+class ReferencedReelAsset;
namespace dcp {
class MonoPictureAsset;
void write (boost::shared_ptr<const AudioBuffers>);
void write (PlayerSubtitles subs);
void write (std::list<boost::shared_ptr<Font> > fonts);
- void write (boost::shared_ptr<dcp::ReelAsset> reel_asset);
+ void write (ReferencedReelAsset asset);
void finish ();
void set_encoder_threads (int threads);
*/
int _pushed_to_disk;
- std::list<boost::shared_ptr<dcp::ReelAsset> > _reel_assets;
+ std::list<ReferencedReelAsset> _reel_assets;
std::list<boost::shared_ptr<Font> > _fonts;
}
_reel_type->Append (_("Single reel"));
- _reel_type->Append (_("One per video content"));
+ _reel_type->Append (_("Split by video content"));
_reel_type->Append (_("Custom"));
_reel_length->SetRange (1, 64);
-Subproject commit 4af76b996ec91ea4db61f001a6f1b676907dc3a4
+Subproject commit ecadd276b6af06022a0cb2a35bd1330eaa025c11