get_readers ();
}
-void
+bool
DCPDecoder::pass ()
{
if (_reel == _reels.end () || !_dcp_content->can_be_played ()) {
- return;
+ return true;
}
double const vfr = _dcp_content->active_video_frame_rate ();
_next = ContentTime ();
}
}
+
+ return false;
}
void
void set_decode_referenced ();
- void pass ();
+ bool pass ();
void seek (ContentTime t, bool accurate);
private:
}
}
-void
+bool
DCPSubtitleDecoder::pass ()
{
if (_next == _subtitles.end ()) {
- return;
+ return true;
}
/* Gather all subtitles with the same time period that are next
}
subtitle->emit_text (p, s);
+ return false;
}
ContentTimePeriod
public:
DCPSubtitleDecoder (boost::shared_ptr<const DCPSubtitleContent>, boost::shared_ptr<Log> log);
- void pass ();
+ bool pass ();
void seek (ContentTime time, bool accurate);
private:
boost::shared_ptr<AudioDecoder> audio;
boost::shared_ptr<SubtitleDecoder> subtitle;
- virtual void pass () = 0;
+ /** @return true if there is no more data to come from this decoder */
+ virtual bool pass () = 0;
virtual void seek (ContentTime time, bool accurate) = 0;
ContentTime position () const;
}
}
-void
+bool
FFmpegDecoder::pass ()
{
int r = av_read_frame (_format_context, &_packet);
}
flush ();
- return;
+ return true;
}
int const si = _packet.stream_index;
}
av_packet_unref (&_packet);
+ return false;
}
/** @param data pointer to array of pointers to buffers.
public:
FFmpegDecoder (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Log>);
- void pass ();
+ bool pass ();
void seek (ContentTime time, bool);
private:
video.reset (new VideoDecoder (this, c, log));
}
-void
+bool
ImageDecoder::pass ()
{
if (_frame_video_position >= _image_content->video->length()) {
- return;
+ return true;
}
if (!_image_content->still() || !_image) {
video->emit (_image, _frame_video_position);
++_frame_video_position;
- return;
+ return false;
}
void
return _image_content;
}
- void pass ();
+ bool pass ();
void seek (ContentTime, bool);
private:
}
}
-void
+bool
TextSubtitleDecoder::pass ()
{
if (_next >= _subtitles.size ()) {
- return;
+ return true;
}
ContentTimePeriod const p = content_time_period (_subtitles[_next]);
subtitle->emit_text (p, _subtitles[_next]);
++_next;
- return;
+ return false;
}
ContentTimePeriod
TextSubtitleDecoder (boost::shared_ptr<const TextSubtitleContent>, boost::shared_ptr<Log> log);
void seek (ContentTime time, bool accurate);
- void pass ();
+ bool pass ();
private:
ContentTimePeriod content_time_period (sub::Subtitle s) const;
}
}
-void
+bool
VideoMXFDecoder::pass ()
{
double const vfr = _content->active_video_frame_rate ();
int64_t const frame = _next.frames_round (vfr);
if (frame >= _content->video->length()) {
- return;
+ return true;
}
if (_mono_reader) {
}
_next += ContentTime::from_frames (1, vfr);
+ return false;
}
void
public:
VideoMXFDecoder (boost::shared_ptr<const VideoMXFContent>, boost::shared_ptr<Log> log);
- void pass ();
+ bool pass ();
void seek (ContentTime t, bool accurate);
private:
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include "lib/text_subtitle_decoder.h"
#include "lib/content_subtitle.h"
+#include "lib/video_decoder.h"
+#include "lib/audio_decoder.h"
#include "lib/film.h"
#include "lib/text_subtitle_content.h"
#include "subtitle_view.h"
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
-#if 0
- XXX
-
- list<ContentTextSubtitle> subs = decoder->subtitle->get_text (ContentTimePeriod (ContentTime(), ContentTime::max ()), true, true);
- FrameRateChange const frc = film->active_frame_rate_change (position);
- int n = 0;
- for (list<ContentTextSubtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
- for (list<dcp::SubtitleString>::const_iterator j = i->subs.begin(); j != i->subs.end(); ++j) {
- wxListItem list_item;
- list_item.SetId (n);
- _list->InsertItem (list_item);
- ContentTimePeriod const p = i->period ();
- _list->SetItem (n, 0, std_to_wx (p.from.timecode (frc.source)));
- _list->SetItem (n, 1, std_to_wx (p.to.timecode (frc.source)));
- _list->SetItem (n, 2, std_to_wx (j->text ()));
- ++n;
- }
+ if (decoder->video) {
+ decoder->video->set_ignore ();
+ }
+ if (decoder->audio) {
+ decoder->audio->set_ignore ();
}
-#endif
+ _subs = 0;
+ _frc = film->active_frame_rate_change (position);
+ decoder->subtitle->TextData.connect (bind (&SubtitleView::data, this, _1));
+ while (!decoder->pass ()) {}
SetSizerAndFit (sizer);
}
+
+void
+SubtitleView::data (ContentTextSubtitle cts)
+{
+ for (list<dcp::SubtitleString>::const_iterator i = cts.subs.begin(); i != cts.subs.end(); ++i) {
+ wxListItem list_item;
+ list_item.SetId (_subs);
+ _list->InsertItem (list_item);
+ ContentTimePeriod const p = cts.period ();
+ _list->SetItem (_subs, 0, std_to_wx (p.from.timecode (_frc->source)));
+ _list->SetItem (_subs, 1, std_to_wx (p.to.timecode (_frc->source)));
+ _list->SetItem (_subs, 2, std_to_wx (i->text ()));
+ ++_subs;
+ }
+}
*/
+#include "lib/content_subtitle.h"
#include <boost/shared_ptr.hpp>
#include <wx/wx.h>
#include <wx/listctrl.h>
SubtitleView (wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Decoder>, DCPTime position);
private:
+ void data (ContentTextSubtitle cts);
+
wxListCtrl* _list;
+ int _subs;
+ boost::optional<FrameRateChange> _frc;
};