X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fstream.cc;h=e5a2bbc2b92de72ec999ff22a7aa3d710a0420ac;hb=0d3f5aae5b99832b7c5d55f32f5bccb365caa3fd;hp=e40738990fab050e4de0963628b30ebc6e7afc8a;hpb=4dfce74792c3ea55ecf2479568f76d7e54b826e0;p=dcpomatic.git diff --git a/src/lib/stream.cc b/src/lib/stream.cc index e40738990..e5a2bbc2b 100644 --- a/src/lib/stream.cc +++ b/src/lib/stream.cc @@ -20,22 +20,73 @@ #include #include "compose.hpp" #include "stream.h" +#include "ffmpeg_decoder.h" +#include "external_audio_decoder.h" -using namespace std; +#include "i18n.h" -Stream::Stream (string t) +using std::string; +using std::stringstream; +using boost::shared_ptr; +using boost::optional; + +/** 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; - + n >> _id; + size_t const s = t.find (' '); if (s != string::npos) { - name = t.substr (s + 1); + _name = t.substr (s + 1); } } +/** @return A canonical string representation of this stream */ string -Stream::to_string () const +SubtitleStream::to_string () const +{ + return String::compose (N_("%1 %2"), _id, _name); +} + +/** 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) +{ + return shared_ptr (new SubtitleStream (t, v)); +} + +/** 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; +} + +/** 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); }