2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "compose.hpp"
23 #include "ffmpeg_decoder.h"
24 #include "sndfile_decoder.h"
29 using std::stringstream;
30 using boost::shared_ptr;
31 using boost::optional;
33 /** Construct a SubtitleStream from a value returned from to_string().
34 * @param t String returned from to_string().
35 * @param v State file version.
37 SubtitleStream::SubtitleStream (string t, boost::optional<int>)
42 size_t const s = t.find (' ');
43 if (s != string::npos) {
44 _name = t.substr (s + 1);
48 /** @return A canonical string representation of this stream */
50 SubtitleStream::to_string () const
52 return String::compose (N_("%1 %2"), _id, _name);
55 /** Create a SubtitleStream from a value returned from to_string().
56 * @param t String returned from to_string().
57 * @param v State file version.
59 shared_ptr<SubtitleStream>
60 SubtitleStream::create (string t, optional<int> v)
62 return shared_ptr<SubtitleStream> (new SubtitleStream (t, v));
65 /** Create an AudioStream from a string returned from to_string().
66 * @param t String returned from to_string().
67 * @param v State file version.
68 * @return AudioStream, or 0.
70 shared_ptr<AudioStream>
71 audio_stream_factory (string t, optional<int> v)
73 shared_ptr<AudioStream> s;
75 s = FFmpegAudioStream::create (t, v);
77 s = SndfileStream::create (t, v);
83 /** Create a SubtitleStream from a string returned from to_string().
84 * @param t String returned from to_string().
85 * @param v State file version.
86 * @return SubtitleStream, or 0.
88 shared_ptr<SubtitleStream>
89 subtitle_stream_factory (string t, optional<int> v)
91 return SubtitleStream::create (t, v);