X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fstream.cc;h=4f12f41b9b7e73fa7ab49b50b1dccdcdad0ec53e;hb=7561918187d51eadcd59904a71c1eda30cc6ab31;hp=fd7eccfbf2bfe69bec7272632a7d1f9b7ff36fca;hpb=70447e72a5595fa03eb0a82b5e93247fcc5cad2b;p=dcpomatic.git diff --git a/src/lib/stream.cc b/src/lib/stream.cc index fd7eccfbf..4f12f41b9 100644 --- a/src/lib/stream.cc +++ b/src/lib/stream.cc @@ -20,43 +20,71 @@ #include #include "compose.hpp" #include "stream.h" +#include "ffmpeg_decoder.h" +#include "external_audio_decoder.h" -using namespace std; +using std::string; +using std::stringstream; +using boost::shared_ptr; +using boost::optional; -AudioStream::AudioStream (string t) +/** Construct a SubtitleStream from a value returned from to_string(). + * @param t String returned from to_string(). + * @param v State file version. + */ +SubtitleStream::SubtitleStream (string t, boost::optional) { stringstream n (t); - n >> _id >> _sample_rate >> _channel_layout; + n >> _id; - for (int i = 0; i < 3; ++i) { - size_t const s = t.find (' '); - if (s != string::npos) { - t = t.substr (s + 1); - } + size_t const s = t.find (' '); + if (s != string::npos) { + _name = t.substr (s + 1); } - - _name = t; } +/** @return A canonical string representation of this stream */ string -AudioStream::to_string () const +SubtitleStream::to_string () const { - return String::compose ("%1 %2 %3 %4", _id, _sample_rate, _channel_layout, _name); + return String::compose ("%1 %2", _id, _name); } -SubtitleStream::SubtitleStream (string t) +/** Create a SubtitleStream from a value returned from to_string(). + * @param t String returned from to_string(). + * @param v State file version. + */ +shared_ptr +SubtitleStream::create (string t, optional v) { - stringstream n (t); - n >> _id; + return shared_ptr (new SubtitleStream (t, v)); +} - size_t const s = t.find (' '); - if (s != string::npos) { - _name = t.substr (s + 1); +/** Create an AudioStream from a string returned from to_string(). + * @param t String returned from to_string(). + * @param v State file version. + * @return AudioStream, or 0. + */ +shared_ptr +audio_stream_factory (string t, optional v) +{ + shared_ptr s; + + s = FFmpegAudioStream::create (t, v); + if (!s) { + s = ExternalAudioStream::create (t, v); } + + return s; } -string -SubtitleStream::to_string () const +/** Create a SubtitleStream from a string returned from to_string(). + * @param t String returned from to_string(). + * @param v State file version. + * @return SubtitleStream, or 0. + */ +shared_ptr +subtitle_stream_factory (string t, optional v) { - return String::compose ("%1 %2", _id, _name); + return SubtitleStream::create (t, v); }