using boost::lexical_cast;
int const ContentProperty::START = 400;
+int const ContentProperty::LENGTH = 401;
Content::Content (shared_ptr<const Film> f, Time s)
: _film (f)
{
public:
static int const START;
+ static int const LENGTH;
};
class Content : public boost::enable_shared_from_this<Content>
take_from_video_decoder (decoder);
- signal_changed (VideoContentProperty::VIDEO_LENGTH);
+ signal_changed (ContentProperty::LENGTH);
signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
signal_changed (FFmpegContentProperty::AUDIO_STREAMS);
/* XXX */
return 48000;
}
+
+void
+Film::set_sequence_video (bool s)
+{
+ _playlist->set_sequence_video (s);
+}
void set_loop (int);
int loop () const;
+ void set_sequence_video (bool);
+
/** Identifiers for the parts of our state;
used for signalling changes.
*/
shared_ptr<ImageMagickDecoder> decoder (new ImageMagickDecoder (film, shared_from_this()));
- {
- boost::mutex::scoped_lock lm (_mutex);
- /* Initial length */
- _video_length = Config::instance()->default_still_length() * 24;
- }
-
+ set_video_length (Config::instance()->default_still_length() * 24);
take_from_video_decoder (decoder);
-
- signal_changed (VideoContentProperty::VIDEO_LENGTH);
}
shared_ptr<Content>
_video_length = len;
}
- signal_changed (VideoContentProperty::VIDEO_LENGTH);
+ signal_changed (ContentProperty::LENGTH);
}
Time
}
-struct ContentSorter
-{
- bool operator() (shared_ptr<Content> a, shared_ptr<Content> b)
- {
- return a->start() < b->start();
- }
-};
-
void
Player::setup_pieces ()
{
return;
}
- if (p == ContentProperty::START || p == VideoContentProperty::VIDEO_LENGTH) {
+ if (p == ContentProperty::START || p == ContentProperty::LENGTH) {
_have_valid_pieces = false;
}
}
-/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
-
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
Playlist::Playlist ()
: _loop (1)
+ , _sequence_video (true)
+ , _sequencing_video (false)
{
}
void
Playlist::content_changed (weak_ptr<Content> c, int p)
{
+ if (p == ContentProperty::LENGTH && _sequence_video && !_sequencing_video) {
+ cout << "sequencing.\n";
+ _sequencing_video = true;
+
+ ContentList cl = _content;
+ sort (cl.begin(), cl.end(), ContentSorter ());
+ Time last = 0;
+ for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) {
+ if (!dynamic_pointer_cast<VideoContent> (*i)) {
+ continue;
+ }
+
+ (*i)->set_start (last);
+ cout << (*i)->file() << " -> " << last << "\n";
+ last = (*i)->end ();
+ }
+
+ _sequencing_video = false;
+ }
+
ContentChanged (c, p);
}
reconnect ();
_loop = node->number_child<int> ("Loop");
+ _sequence_video = node->bool_child ("SequenceVideo");
}
/** @param node <Playlist> node */
}
node->add_child("Loop")->add_child_text(lexical_cast<string> (_loop));
+ node->add_child("SequenceVideo")->add_child_text(_sequence_video ? "1" : "0");
}
void
return end;
}
+
+void
+Playlist::set_sequence_video (bool s)
+{
+ _sequence_video = s;
+}
+
+bool
+ContentSorter::operator() (shared_ptr<Content> a, shared_ptr<Content> b)
+{
+ return a->start() < b->start();
+}
* are played simultaneously (i.e. they can be split up into multiple files for different channels)
*/
+struct ContentSorter
+{
+ bool operator() (boost::shared_ptr<Content> a, boost::shared_ptr<Content> b);
+};
+
class Playlist
{
public:
int best_dcp_frame_rate () const;
Time video_end () const;
+ void set_sequence_video (bool);
+
mutable boost::signals2::signal<void ()> Changed;
mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int)> ContentChanged;
ContentList _content;
int _loop;
+ bool _sequence_video;
+ bool _sequencing_video;
std::list<boost::signals2::connection> _content_connections;
};
#include "i18n.h"
-int const VideoContentProperty::VIDEO_LENGTH = 0;
-int const VideoContentProperty::VIDEO_SIZE = 1;
-int const VideoContentProperty::VIDEO_FRAME_RATE = 2;
-int const VideoContentProperty::VIDEO_CROP = 3;
+int const VideoContentProperty::VIDEO_SIZE = 0;
+int const VideoContentProperty::VIDEO_FRAME_RATE = 1;
+int const VideoContentProperty::VIDEO_CROP = 2;
using std::string;
using std::stringstream;
class VideoContentProperty
{
public:
- static int const VIDEO_LENGTH;
static int const VIDEO_SIZE;
static int const VIDEO_FRAME_RATE;
static int const VIDEO_CROP;
_audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
_audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
_subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
- _audio_mapping->Changed.connect (bind (&FilmEditor::audio_mapping_changed, this, _1));
+ _audio_mapping->Changed.connect (boost::bind (&FilmEditor::audio_mapping_changed, this, _1));
+ _start->Changed.connect (boost::bind (&FilmEditor::start_changed, this));
+ _length->Changed.connect (boost::bind (&FilmEditor::length_changed, this));
}
void
} else {
_start->set (0, 24);
}
-
+ } else if (property == ContentProperty::LENGTH) {
+ if (content) {
+ _length->set (content->length (), _film->dcp_video_frame_rate ());
+ } else {
+ _length->set (0, 24);
+ }
} else if (property == VideoContentProperty::VIDEO_CROP) {
checked_set (_left_crop, video_content ? video_content->crop().left : 0);
checked_set (_right_crop, video_content ? video_content->crop().right : 0);
film_changed (Film::DCP_VIDEO_FRAME_RATE);
film_content_changed (boost::shared_ptr<Content> (), ContentProperty::START);
+ film_content_changed (boost::shared_ptr<Content> (), ContentProperty::LENGTH);
film_content_changed (boost::shared_ptr<Content> (), VideoContentProperty::VIDEO_CROP);
film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_GAIN);
film_content_changed (boost::shared_ptr<Content> (), AudioContentProperty::AUDIO_DELAY);
_edit_dci_button->Enable (s);
_format->Enable (s);
_content->Enable (s);
- _content->Enable (s);
_left_crop->Enable (s);
_right_crop->Enable (s);
_top_crop->Enable (s);
setup_content_sensitivity ();
shared_ptr<Content> s = selected_content ();
film_content_changed (s, ContentProperty::START);
+ film_content_changed (s, ContentProperty::LENGTH);
film_content_changed (s, VideoContentProperty::VIDEO_CROP);
film_content_changed (s, AudioContentProperty::AUDIO_GAIN);
film_content_changed (s, AudioContentProperty::AUDIO_DELAY);
ac->set_audio_mapping (m);
}
+
+void
+FilmEditor::start_changed ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ c->set_start (_start->get (_film->dcp_video_frame_rate ()));
+}
+
+void
+FilmEditor::length_changed ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<ImageMagickContent> ic = dynamic_pointer_cast<ImageMagickContent> (c);
+ if (ic) {
+ ic->set_video_length (_length->get(_film->dcp_video_frame_rate()) * ic->video_frame_rate() / TIME_HZ);
+ }
+}
+
+void
+FilmEditor::set_selection (weak_ptr<Content> wc)
+{
+ Playlist::ContentList content = _film->content ();
+ for (size_t i = 0; i < content.size(); ++i) {
+ if (content[i] == wc.lock ()) {
+ _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+ } else {
+ _content->SetItemState (i, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
+ }
+ }
+}
FilmEditor (boost::shared_ptr<Film>, wxWindow *);
void set_film (boost::shared_ptr<Film>);
+ void set_selection (boost::weak_ptr<Content>);
boost::signals2::signal<void (std::string)> FileChanged;
void audio_stream_changed (wxCommandEvent &);
void subtitle_stream_changed (wxCommandEvent &);
void audio_mapping_changed (AudioMapping);
+ void start_changed ();
+ void length_changed ();
/* Handle changes to the model */
void film_changed (Film::Property);
void
FilmViewer::film_content_changed (weak_ptr<Content>, int p)
{
- if (p == VideoContentProperty::VIDEO_LENGTH) {
+ if (p == ContentProperty::LENGTH) {
/* Force an update to our frame */
wxScrollEvent ev;
slider_moved (ev);
#include "wx_util.h"
using std::string;
+using std::cout;
using boost::lexical_cast;
Timecode::Timecode (wxWindow* parent)
: wxPanel (parent)
+ , _in_set (false)
{
wxClientDC dc (parent);
wxSize size = dc.GetTextExtent (wxT ("9999"));
_frames->SetMaxLength (2);
sizer->Add (_frames);
+ _hours->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (Timecode::changed), 0, this);
+ _minutes->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (Timecode::changed), 0, this);
+ _seconds->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (Timecode::changed), 0, this);
+ _frames->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (Timecode::changed), 0, this);
+
SetSizerAndFit (sizer);
}
void
Timecode::set (Time t, int fps)
{
+ _in_set = true;
+
int const h = t / (3600 * TIME_HZ);
t -= h * 3600 * TIME_HZ;
int const m = t / (60 * TIME_HZ);
t -= s * TIME_HZ;
int const f = t * fps / TIME_HZ;
- _hours->SetValue (wxString::Format ("%02d", h));
- _minutes->SetValue (wxString::Format ("%02d", m));
- _seconds->SetValue (wxString::Format ("%02d", s));
- _frames->SetValue (wxString::Format ("%02d", f));
+ _hours->SetValue (wxString::Format (wxT ("%d"), h));
+ _minutes->SetValue (wxString::Format (wxT ("%d"), m));
+ _seconds->SetValue (wxString::Format (wxT ("%d"), s));
+ _frames->SetValue (wxString::Format (wxT ("%d"), f));
+
+ _in_set = false;
}
Time
Timecode::get (int fps) const
{
Time t = 0;
- t += lexical_cast<int> (wx_to_std (_hours->GetValue())) * 3600 * TIME_HZ;
- t += lexical_cast<int> (wx_to_std (_minutes->GetValue())) * 60 * TIME_HZ;
- t += lexical_cast<int> (wx_to_std (_seconds->GetValue())) * TIME_HZ;
- t += lexical_cast<int> (wx_to_std (_frames->GetValue())) * TIME_HZ / fps;
+ string const h = wx_to_std (_hours->GetValue ());
+ t += lexical_cast<int> (h.empty() ? "0" : h) * 3600 * TIME_HZ;
+ string const m = wx_to_std (_minutes->GetValue());
+ t += lexical_cast<int> (m.empty() ? "0" : m) * 60 * TIME_HZ;
+ string const s = wx_to_std (_seconds->GetValue());
+ t += lexical_cast<int> (s.empty() ? "0" : s) * TIME_HZ;
+ string const f = wx_to_std (_frames->GetValue());
+ t += lexical_cast<int> (f.empty() ? "0" : f) * TIME_HZ / fps;
return t;
}
+
+void
+Timecode::changed (wxCommandEvent &)
+{
+ if (_in_set) {
+ return;
+ }
+
+ Changed ();
+}
*/
+#include <boost/signals2.hpp>
#include <wx/wx.h>
#include "lib/types.h"
void set (Time, int);
Time get (int) const;
+ boost::signals2::signal<void ()> Changed;
+
private:
+ void changed (wxCommandEvent &);
+
wxTextCtrl* _hours;
wxTextCtrl* _minutes;
wxTextCtrl* _seconds;
wxTextCtrl* _frames;
+
+ bool _in_set;
};
#include <wx/graphics.h>
#include <boost/weak_ptr.hpp>
#include "film.h"
+#include "film_editor.h"
#include "timeline.h"
#include "wx_util.h"
-#include "playlist.h"
+#include "lib/playlist.h"
using std::list;
using std::cout;
void content_changed (int p)
{
- if (p == ContentProperty::START || p == VideoContentProperty::VIDEO_LENGTH) {
+ if (p == ContentProperty::START || p == ContentProperty::LENGTH) {
force_redraw ();
}
}
int _y;
};
-Timeline::Timeline (wxWindow* parent, shared_ptr<const Film> film)
+Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
+ , _film_editor (ed)
, _film (film)
, _tracks (0)
, _pixels_per_time_unit (0)
shared_ptr<ContentView> cv = dynamic_pointer_cast<ContentView> (*j);
if (cv) {
cv->set_selected (i == j);
+ if (i == j) {
+ _film_editor->set_selection (cv->content ());
+ }
}
}
shared_ptr<Content> c = _down_view->content().lock();
if (c) {
c->set_start (max (static_cast<Time> (0), _down_view_start + time_diff));
+
+ shared_ptr<Film> film = _film.lock ();
+ assert (film);
+ film->set_sequence_video (false);
}
}
}
class Film;
class View;
class ContentView;
+class FilmEditor;
class Timeline : public wxPanel
{
public:
- Timeline (wxWindow *, boost::shared_ptr<const Film>);
+ Timeline (wxWindow *, FilmEditor *, boost::shared_ptr<Film>);
boost::shared_ptr<const Film> film () const;
void resized (wxSizeEvent &);
void assign_tracks ();
- boost::weak_ptr<const Film> _film;
+ FilmEditor* _film_editor;
+ boost::weak_ptr<Film> _film;
std::list<boost::shared_ptr<View> > _views;
int _tracks;
double _pixels_per_time_unit;
#include <list>
#include <wx/graphics.h>
+#include "film_editor.h"
#include "timeline_dialog.h"
#include "wx_util.h"
#include "playlist.h"
using std::cout;
using boost::shared_ptr;
-TimelineDialog::TimelineDialog (wxWindow* parent, shared_ptr<const Film> film)
- : wxDialog (parent, wxID_ANY, _("Timeline"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
- , _timeline (this, film)
+TimelineDialog::TimelineDialog (FilmEditor* ed, shared_ptr<Film> film)
+ : wxDialog (ed, wxID_ANY, _("Timeline"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
+ , _timeline (this, ed, film)
{
wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
class TimelineDialog : public wxDialog
{
public:
- TimelineDialog (wxWindow *, boost::shared_ptr<const Film>);
+ TimelineDialog (FilmEditor *, boost::shared_ptr<Film>);
private:
Timeline _timeline;