diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-11-17 22:06:12 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-11-17 22:06:12 +0000 |
| commit | cafa76a2b52449ce3c9eecfd0ea53b7318814951 (patch) | |
| tree | 81fe66f74256a54eb50f398790f2eea010bb3113 /src/lib/stream.cc | |
| parent | 40532d61ea4909b3f8b12dd7024de217dbdfec6d (diff) | |
Another attempt to do external audio moderately nicely.
Diffstat (limited to 'src/lib/stream.cc')
| -rw-r--r-- | src/lib/stream.cc | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/src/lib/stream.cc b/src/lib/stream.cc index 5bc184eb9..372077cd8 100644 --- a/src/lib/stream.cc +++ b/src/lib/stream.cc @@ -20,55 +20,52 @@ #include <sstream> #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, optional<int> version) +SubtitleStream::SubtitleStream (string t, boost::optional<int>) { stringstream n (t); - - int name_index = 3; - if (!version) { - name_index = 2; - int channels; - n >> _id >> channels; - _channel_layout = av_get_default_channel_layout (channels); - _sample_rate = 0; - } else { - /* Current (marked version 1) */ - n >> _id >> _sample_rate >> _channel_layout; - } + n >> _id; - for (int i = 0; i < name_index; ++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; } 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) +shared_ptr<SubtitleStream> +SubtitleStream::create (string t, optional<int> v) { - stringstream n (t); - n >> _id; + return shared_ptr<SubtitleStream> (new SubtitleStream (t, v)); +} - size_t const s = t.find (' '); - if (s != string::npos) { - _name = t.substr (s + 1); +shared_ptr<AudioStream> +audio_stream_factory (string t, optional<int> v) +{ + shared_ptr<AudioStream> s; + + s = FFmpegAudioStream::create (t, v); + if (!s) { + s = ExternalAudioStream::create (t, v); } + + return s; } -string -SubtitleStream::to_string () const +shared_ptr<SubtitleStream> +subtitle_stream_factory (string t, optional<int> v) { - return String::compose ("%1 %2", _id, _name); + return SubtitleStream::create (t, v); } |
