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 "external_audio_decoder.h"
27 using std::stringstream;
28 using boost::shared_ptr;
29 using boost::optional;
31 /** Construct a SubtitleStream from a value returned from to_string().
32 * @param t String returned from to_string().
33 * @param v State file version.
35 SubtitleStream::SubtitleStream (string t, boost::optional<int>)
40 size_t const s = t.find (' ');
41 if (s != string::npos) {
42 _name = t.substr (s + 1);
46 /** @return A canonical string representation of this stream */
48 SubtitleStream::to_string () const
50 return String::compose ("%1 %2", _id, _name);
53 /** Create a SubtitleStream from a value returned from to_string().
54 * @param t String returned from to_string().
55 * @param v State file version.
57 shared_ptr<SubtitleStream>
58 SubtitleStream::create (string t, optional<int> v)
60 return shared_ptr<SubtitleStream> (new SubtitleStream (t, v));
63 /** Create an AudioStream from a string returned from to_string().
64 * @param t String returned from to_string().
65 * @param v State file version.
66 * @return AudioStream, or 0.
68 shared_ptr<AudioStream>
69 audio_stream_factory (string t, optional<int> v)
71 shared_ptr<AudioStream> s;
73 s = FFmpegAudioStream::create (t, v);
75 s = ExternalAudioStream::create (t, v);
81 /** Create a SubtitleStream from a string returned from to_string().
82 * @param t String returned from to_string().
83 * @param v State file version.
84 * @return SubtitleStream, or 0.
86 shared_ptr<SubtitleStream>
87 subtitle_stream_factory (string t, optional<int> v)
89 return SubtitleStream::create (t, v);