X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fstream.cc;h=bfe7b5eb4b85054ad76def09d195714458ab7c6f;hb=be5dfa3ed0459392cc65d21f563f136b97a295ba;hp=9d10813f77a52f7aeea6085fa784d7479fbad0cf;hpb=60990830b23f295d218b6ae549654e5c67a7bdff;p=dcpomatic.git diff --git a/src/lib/stream.cc b/src/lib/stream.cc index 9d10813f7..bfe7b5eb4 100644 --- a/src/lib/stream.cc +++ b/src/lib/stream.cc @@ -20,43 +20,73 @@ #include #include "compose.hpp" #include "stream.h" +#include "ffmpeg_decoder.h" +#include "sndfile_decoder.h" -using namespace std; +#include "i18n.h" -AudioStream::AudioStream (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 >> _sample_rate >> _channel_layout; + n >> _id; - for (int i = 0; i < 2; ++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 (N_("%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 = SndfileStream::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); }