summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-03 00:27:09 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-03 00:27:09 +0100
commit9c3e4462d32c726a6c257b0a40e642ab23d9526a (patch)
treecedc2faa6de6264177ea5c465bb26c3330413148 /src/lib
parent7ebb57db2013c9e929d44d0e547ab1f27c59cc7f (diff)
Make subs work again (sort of).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffmpeg_decoder.cc2
-rw-r--r--src/lib/film.cc24
-rw-r--r--src/lib/film.h6
-rw-r--r--src/lib/playlist.cc57
-rw-r--r--src/lib/playlist.h6
5 files changed, 91 insertions, 4 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index ced9b95e9..3a185bd6a 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -122,7 +122,7 @@ FFmpegDecoder::setup_general ()
throw DecodeError (_("could not find stream information"));
}
- /* Find video, audio and subtitle streams and choose the first of each */
+ /* Find video, audio and subtitle streams */
for (uint32_t i = 0; i < _format_context->nb_streams; ++i) {
AVStream* s = _format_context->streams[i];
diff --git a/src/lib/film.cc b/src/lib/film.cc
index f71180157..091b35d47 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -1161,6 +1161,30 @@ Film::video_length () const
return _playlist->video_length ();
}
+vector<FFmpegSubtitleStream>
+Film::ffmpeg_subtitle_streams () const
+{
+ return _playlist->ffmpeg_subtitle_streams ();
+}
+
+boost::optional<FFmpegSubtitleStream>
+Film::ffmpeg_subtitle_stream () const
+{
+ return _playlist->ffmpeg_subtitle_stream ();
+}
+
+vector<FFmpegAudioStream>
+Film::ffmpeg_audio_streams () const
+{
+ return _playlist->ffmpeg_audio_streams ();
+}
+
+boost::optional<FFmpegAudioStream>
+Film::ffmpeg_audio_stream () const
+{
+ return _playlist->ffmpeg_audio_stream ();
+}
+
void
Film::content_changed (int p)
{
diff --git a/src/lib/film.h b/src/lib/film.h
index 63a86bc43..e71fe2606 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -39,6 +39,7 @@ extern "C" {
#include "util.h"
#include "dci_metadata.h"
#include "types.h"
+#include "ffmpeg_content.h"
class Format;
class Job;
@@ -114,6 +115,11 @@ public:
libdcp::Size video_size () const;
ContentVideoFrame video_length () const;
+ std::vector<FFmpegSubtitleStream> ffmpeg_subtitle_streams () const;
+ boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const;
+ std::vector<FFmpegAudioStream> ffmpeg_audio_streams () const;
+ boost::optional<FFmpegAudioStream> ffmpeg_audio_stream () const;
+
/** Identifiers for the parts of our state;
used for signalling changes.
*/
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 3822420da..0c29650b6 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -28,6 +28,7 @@
using std::list;
using std::cout;
+using std::vector;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
@@ -47,7 +48,7 @@ Playlist::setup (ContentList content)
_ffmpeg.reset ();
_imagemagick.clear ();
_sndfile.clear ();
-
+
for (ContentList::const_iterator i = content.begin(); i != content.end(); ++i) {
shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i);
if (fc) {
@@ -206,6 +207,46 @@ Playlist::has_audio () const
return _audio_from != AUDIO_NONE;
}
+vector<FFmpegSubtitleStream>
+Playlist::ffmpeg_subtitle_streams () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return vector<FFmpegSubtitleStream> ();
+ }
+
+ return _ffmpeg->subtitle_streams ();
+}
+
+boost::optional<FFmpegSubtitleStream>
+Playlist::ffmpeg_subtitle_stream () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return boost::none;
+ }
+
+ return _ffmpeg->subtitle_stream ();
+}
+
+vector<FFmpegAudioStream>
+Playlist::ffmpeg_audio_streams () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return vector<FFmpegAudioStream> ();
+ }
+
+ return _ffmpeg->audio_streams ();
+}
+
+boost::optional<FFmpegAudioStream>
+Playlist::ffmpeg_audio_stream () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return boost::none;
+ }
+
+ return _ffmpeg->audio_stream ();
+}
+
Player::Player (boost::shared_ptr<const Film> f, boost::shared_ptr<const Playlist> p)
: _film (f)
, _playlist (p)
@@ -296,13 +337,18 @@ Player::process_audio (shared_ptr<AudioBuffers> b)
bool
Player::seek (double t)
{
+ if (!_have_setup_decoders) {
+ setup_decoders ();
+ _have_setup_decoders = true;
+ }
+
bool r = false;
switch (_playlist->video_from()) {
case Playlist::VIDEO_NONE:
break;
case Playlist::VIDEO_FFMPEG:
- if (_ffmpeg_decoder->seek (t)) {
+ if (!_ffmpeg_decoder || _ffmpeg_decoder->seek (t)) {
r = true;
}
break;
@@ -334,13 +380,18 @@ Player::seek (double t)
bool
Player::seek_to_last ()
{
+ if (!_have_setup_decoders) {
+ setup_decoders ();
+ _have_setup_decoders = true;
+ }
+
bool r = false;
switch (_playlist->video_from ()) {
case Playlist::VIDEO_NONE:
break;
case Playlist::VIDEO_FFMPEG:
- if (_ffmpeg_decoder->seek_to_last ()) {
+ if (!_ffmpeg_decoder || _ffmpeg_decoder->seek_to_last ()) {
r = true;
}
break;
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 403fb58d4..c461151d4 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -24,6 +24,7 @@
#include "audio_source.h"
#include "video_sink.h"
#include "audio_sink.h"
+#include "ffmpeg_content.h"
class Content;
class FFmpegContent;
@@ -52,6 +53,11 @@ public:
libdcp::Size video_size () const;
ContentVideoFrame video_length () const;
+ std::vector<FFmpegSubtitleStream> ffmpeg_subtitle_streams () const;
+ boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const;
+ std::vector<FFmpegAudioStream> ffmpeg_audio_streams () const;
+ boost::optional<FFmpegAudioStream> ffmpeg_audio_stream () const;
+
enum VideoFrom {
VIDEO_NONE,
VIDEO_FFMPEG,