From 58f53485bb112896a9446771acfa2abe0a528cec Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 20 Oct 2012 19:30:04 +0100 Subject: [PATCH] Try to clean up stream handling wrt audio channel counts. --- src/lib/ab_transcoder.cc | 2 +- src/lib/decoder.h | 11 +++---- src/lib/encoder.h | 2 +- src/lib/ffmpeg_decoder.cc | 51 ++++++++----------------------- src/lib/ffmpeg_decoder.h | 11 +++---- src/lib/film_state.cc | 42 ++++++++++++++------------ src/lib/film_state.h | 40 +++++++++++++----------- src/lib/imagemagick_encoder.h | 2 +- src/lib/j2k_still_encoder.h | 2 +- src/lib/j2k_wav_encoder.cc | 2 +- src/lib/j2k_wav_encoder.h | 2 +- src/lib/stream.cc | 33 ++++++++++++++++---- src/lib/stream.h | 57 ++++++++++++++++++++++++++++++----- src/lib/transcoder.cc | 2 +- src/wx/film_editor.cc | 53 ++++++++------------------------ src/wx/film_editor.h | 1 - test/metadata.ref | 2 -- test/test.cc | 13 ++++++++ 18 files changed, 174 insertions(+), 154 deletions(-) diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc index 54153ec76..08938a282 100644 --- a/src/lib/ab_transcoder.cc +++ b/src/lib/ab_transcoder.cc @@ -104,7 +104,7 @@ ABTranscoder::process_video (shared_ptr yuv, int frame, shared_ptrprocess_begin (_da->audio_channel_layout(), _da->audio_sample_format()); + _encoder->process_begin (_da->audio_channel_layout()); _da->process_begin (); _db->process_begin (); diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 85b256f5b..2285cf4f9 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -81,17 +81,14 @@ public: return _video_frame; } - virtual std::vector audio_streams () const { - return std::vector (); + virtual std::vector audio_streams () const { + return std::vector (); } - virtual std::vector subtitle_streams () const { - return std::vector (); + virtual std::vector subtitle_streams () const { + return std::vector (); } - virtual void set_audio_stream (Stream s) {} - virtual void set_subtitle_stream (Stream s) {} - /** Emitted when a video frame is ready. * First parameter is the frame. * Second parameter is its index within the content. diff --git a/src/lib/encoder.h b/src/lib/encoder.h index 3317d30d1..561e41901 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -55,7 +55,7 @@ public: Encoder (boost::shared_ptr s, boost::shared_ptr o, Log* l); /** Called to indicate that a processing run is about to begin */ - virtual void process_begin (int64_t audio_channel_layout, AVSampleFormat audio_sample_format) = 0; + virtual void process_begin (int64_t audio_channel_layout) = 0; /** Called with a frame of video. * @param i Video frame image. diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 4b0594add..d93b023c3 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -109,43 +109,30 @@ FFmpegDecoder::setup_general () /* Find video, audio and subtitle streams and choose the first of each */ for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { - if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + AVStream* s = _format_context->streams[i]; + if (s->codec->codec_type == AVMEDIA_TYPE_VIDEO) { _video_stream = i; - } else if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + } else if (s->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (_audio_stream == -1) { _audio_stream = i; } - _audio_streams.push_back (Stream (stream_name (_format_context->streams[i]), i)); - } else if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { + _audio_streams.push_back (AudioStream (stream_name (s), i, s->codec->channels)); + } else if (s->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (_subtitle_stream == -1) { _subtitle_stream = i; } - _subtitle_streams.push_back (Stream (stream_name (_format_context->streams[i]), i)); + _subtitle_streams.push_back (SubtitleStream (stream_name (s), i)); } } /* Now override audio and subtitle streams with those from the Film, if it has any */ - if (_fs->audio_stream() != -1) { - vector::iterator i = _audio_streams.begin (); - while (i != _audio_streams.end() && i->id != _fs->audio_stream()) { - ++i; - } - - if (i != _audio_streams.end()) { - _audio_stream = _fs->audio_stream (); - } + if (_fs->audio_stream_index() != -1) { + _audio_stream = _fs->audio_stream_decoder_id (); } - if (_fs->subtitle_stream() != -1) { - vector::iterator i = _subtitle_streams.begin (); - while (i != _subtitle_streams.end() && i->id != _fs->subtitle_stream()) { - ++i; - } - - if (i != _subtitle_streams.end()) { - _subtitle_stream = _fs->subtitle_stream (); - } + if (_fs->subtitle_stream_index() != -1) { + _subtitle_stream = _fs->subtitle_stream_decoder_id (); } if (_video_stream < 0) { @@ -394,32 +381,18 @@ FFmpegDecoder::has_subtitles () const return (_subtitle_stream != -1); } -vector +vector FFmpegDecoder::audio_streams () const { return _audio_streams; } -vector +vector FFmpegDecoder::subtitle_streams () const { return _subtitle_streams; } -void -FFmpegDecoder::set_audio_stream (int s) -{ - _audio_stream = s; - setup_audio (); -} - -void -FFmpegDecoder::set_subtitle_stream (int s) -{ - _subtitle_stream = s; - setup_subtitle (); -} - string FFmpegDecoder::stream_name (AVStream* s) const { diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 0d256b37e..339afbaef 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -67,11 +67,8 @@ public: bool has_subtitles () const; int bytes_per_audio_sample () const; - std::vector audio_streams () const; - std::vector subtitle_streams () const; - - void set_audio_stream (int id); - void set_subtitle_stream (int id); + std::vector audio_streams () const; + std::vector subtitle_streams () const; private: @@ -97,8 +94,8 @@ private: int _subtitle_stream; ///< may be < 0 if there is no subtitle AVFrame* _frame; - std::vector _audio_streams; - std::vector _subtitle_streams; + std::vector _audio_streams; + std::vector _subtitle_streams; AVCodecContext* _video_codec_context; AVCodec* _video_codec; diff --git a/src/lib/film_state.cc b/src/lib/film_state.cc index 46359677c..8dd8309a8 100644 --- a/src/lib/film_state.cc +++ b/src/lib/film_state.cc @@ -113,16 +113,15 @@ FilmState::write_metadata () const f << "width " << _size.width << "\n"; f << "height " << _size.height << "\n"; f << "length " << _length << "\n"; - f << "audio_channels " << _audio_channels << "\n"; f << "audio_sample_rate " << _audio_sample_rate << "\n"; f << "content_digest " << _content_digest << "\n"; f << "has_subtitles " << _has_subtitles << "\n"; - for (vector::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) { + for (vector::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) { f << "audio_stream " << i->to_string () << "\n"; } - for (vector::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) { + for (vector::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) { f << "subtitle_stream " << i->to_string () << "\n"; } @@ -219,8 +218,6 @@ FilmState::read_metadata () _size.height = atoi (v.c_str ()); } else if (k == "length") { _length = atof (v.c_str ()); - } else if (k == "audio_channels") { - _audio_channels = atoi (v.c_str ()); } else if (k == "audio_sample_rate") { _audio_sample_rate = atoi (v.c_str ()); } else if (k == "content_digest") { @@ -228,9 +225,9 @@ FilmState::read_metadata () } else if (k == "has_subtitles") { _has_subtitles = (v == "1"); } else if (k == "audio_stream") { - _audio_streams.push_back (Stream (v)); + _audio_streams.push_back (AudioStream (v)); } else if (k == "subtitle_stream") { - _subtitle_streams.push_back (Stream (v)); + _subtitle_streams.push_back (SubtitleStream (v)); } else if (k == "frames_per_second") { _frames_per_second = atof (v.c_str ()); } @@ -424,7 +421,7 @@ FilmState::dci_name () const d << "_"; } - switch (_audio_channels) { + switch (_audio_streams[_audio_stream].channels()) { case 1: d << "10_"; break; @@ -531,13 +528,12 @@ FilmState::set_content (string c) set_size (d->native_size ()); set_length (d->length_in_frames ()); set_frames_per_second (d->frames_per_second ()); - set_audio_channels (d->audio_channels ()); set_audio_sample_rate (d->audio_sample_rate ()); set_has_subtitles (d->has_subtitles ()); set_audio_streams (d->audio_streams ()); set_subtitle_streams (d->subtitle_streams ()); - set_audio_stream (audio_streams().empty() ? -1 : audio_streams().front().id); - set_subtitle_stream (subtitle_streams().empty() ? -1 : subtitle_streams().front().id); + set_audio_stream (audio_streams().empty() ? -1 : 0); + set_subtitle_stream (subtitle_streams().empty() ? -1 : 0); set_content_digest (md5_digest (content_path ())); _content = c; @@ -770,13 +766,6 @@ FilmState::set_length (int l) signal_changed (LENGTH); } -void -FilmState::set_audio_channels (int c) -{ - _audio_channels = c; - signal_changed (AUDIO_CHANNELS); -} - void FilmState::set_audio_sample_rate (int r) { @@ -799,14 +788,14 @@ FilmState::set_has_subtitles (bool s) } void -FilmState::set_audio_streams (vector s) +FilmState::set_audio_streams (vector s) { _audio_streams = s; _dirty = true; } void -FilmState::set_subtitle_streams (vector s) +FilmState::set_subtitle_streams (vector s) { _subtitle_streams = s; _dirty = true; @@ -831,3 +820,16 @@ FilmState::state_copy () const { return shared_ptr (new FilmState (*this)); } + +int +FilmState::audio_channels () const +{ + if (_audio_stream == -1) { + return 0; + } + + return _audio_streams[_audio_stream].channels (); +} + + + diff --git a/src/lib/film_state.h b/src/lib/film_state.h index 40908693f..46374a17d 100644 --- a/src/lib/film_state.h +++ b/src/lib/film_state.h @@ -70,7 +70,6 @@ public: , _subtitle_offset (0) , _subtitle_scale (1) , _length (0) - , _audio_channels (0) , _audio_sample_rate (0) , _has_subtitles (false) , _frames_per_second (0) @@ -106,6 +105,8 @@ public: return _dirty; } + int audio_channels () const; + enum Property { NONE, NAME, @@ -131,7 +132,6 @@ public: THUMBS, SIZE, LENGTH, - AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, HAS_SUBTITLES, AUDIO_STREAMS, @@ -190,10 +190,15 @@ public: return _dcp_ab; } - int audio_stream () const { + int audio_stream_index () const { return _audio_stream; } + int audio_stream_decoder_id () const { + assert (_audio_stream < int (_audio_streams.size())); + return _audio_streams[_audio_stream].id (); + } + float audio_gain () const { return _audio_gain; } @@ -206,10 +211,15 @@ public: return _still_duration; } - int subtitle_stream () const { + int subtitle_stream_index () const { return _subtitle_stream; } + int subtitle_stream_decoder_id () const { + assert (_subtitle_stream < int (_subtitle_streams.size())); + return _subtitle_streams[_subtitle_stream].id (); + } + bool with_subtitles () const { return _with_subtitles; } @@ -262,10 +272,6 @@ public: return _length; } - int audio_channels () const { - return _audio_channels; - } - int audio_sample_rate () const { return _audio_sample_rate; } @@ -278,11 +284,11 @@ public: return _has_subtitles; } - std::vector audio_streams () const { + std::vector audio_streams () const { return _audio_streams; } - std::vector subtitle_streams () const { + std::vector subtitle_streams () const { return _subtitle_streams; } @@ -331,8 +337,8 @@ public: void set_audio_sample_rate (int); void set_content_digest (std::string); void set_has_subtitles (bool); - void set_audio_streams (std::vector); - void set_subtitle_streams (std::vector); + void set_audio_streams (std::vector); + void set_subtitle_streams (std::vector); void set_frames_per_second (float); /** Emitted when some property has changed */ @@ -375,7 +381,7 @@ private: has the specified filters and post-processing. */ bool _dcp_ab; - /** The decoder's stream ID to use for audio, or -1 if there is none */ + /** An index into our _audio_streams vector for the stream to use for audio, or -1 if there is none */ int _audio_stream; /** Gain to apply to audio in dB */ float _audio_gain; @@ -383,7 +389,7 @@ private: int _audio_delay; /** Duration to make still-sourced films (in seconds) */ int _still_duration; - /** The decoder's stream ID to use for subtitles, or -1 if there are none */ + /** An index into our _subtitle_streams vector for the stream to use for subtitles, or -1 if there is none */ int _subtitle_stream; /** True if subtitles should be shown for this film */ bool _with_subtitles; @@ -411,8 +417,6 @@ private: Size _size; /** Length of the source in frames */ int _length; - /** Number of audio channels */ - int _audio_channels; /** Sample rate of the source audio, in Hz */ int _audio_sample_rate; /** MD5 digest of our content file */ @@ -420,9 +424,9 @@ private: /** true if the source has subtitles */ bool _has_subtitles; /** the audio streams that the source has */ - std::vector _audio_streams; + std::vector _audio_streams; /** the subtitle streams that the source has */ - std::vector _subtitle_streams; + std::vector _subtitle_streams; /** Frames per second of the source */ float _frames_per_second; diff --git a/src/lib/imagemagick_encoder.h b/src/lib/imagemagick_encoder.h index 06f1723b1..29767ed03 100644 --- a/src/lib/imagemagick_encoder.h +++ b/src/lib/imagemagick_encoder.h @@ -36,7 +36,7 @@ class ImageMagickEncoder : public Encoder public: ImageMagickEncoder (boost::shared_ptr s, boost::shared_ptr o, Log* l); - void process_begin (int64_t audio_channel_layout, AVSampleFormat audio_sample_format) {} + void process_begin (int64_t audio_channel_layout) {} void process_video (boost::shared_ptr, int, boost::shared_ptr); void process_audio (boost::shared_ptr) {} void process_end () {} diff --git a/src/lib/j2k_still_encoder.h b/src/lib/j2k_still_encoder.h index 7e7719321..928afe372 100644 --- a/src/lib/j2k_still_encoder.h +++ b/src/lib/j2k_still_encoder.h @@ -36,7 +36,7 @@ class J2KStillEncoder : public Encoder public: J2KStillEncoder (boost::shared_ptr, boost::shared_ptr, Log *); - void process_begin (int64_t audio_channel_layout, AVSampleFormat audio_sample_format) {} + void process_begin (int64_t audio_channel_layout) {} void process_video (boost::shared_ptr, int, boost::shared_ptr); void process_audio (boost::shared_ptr) {} void process_end () {} diff --git a/src/lib/j2k_wav_encoder.cc b/src/lib/j2k_wav_encoder.cc index a83c283d7..8747bb7ad 100644 --- a/src/lib/j2k_wav_encoder.cc +++ b/src/lib/j2k_wav_encoder.cc @@ -216,7 +216,7 @@ J2KWAVEncoder::encoder_thread (ServerDescription* server) } void -J2KWAVEncoder::process_begin (int64_t audio_channel_layout, AVSampleFormat audio_sample_format) +J2KWAVEncoder::process_begin (int64_t audio_channel_layout) { if (_fs->audio_sample_rate() != _fs->target_sample_rate()) { #ifdef HAVE_SWRESAMPLE diff --git a/src/lib/j2k_wav_encoder.h b/src/lib/j2k_wav_encoder.h index 2c18a5730..6733221de 100644 --- a/src/lib/j2k_wav_encoder.h +++ b/src/lib/j2k_wav_encoder.h @@ -50,7 +50,7 @@ public: J2KWAVEncoder (boost::shared_ptr, boost::shared_ptr, Log *); ~J2KWAVEncoder (); - void process_begin (int64_t audio_channel_layout, AVSampleFormat audio_sample_format); + void process_begin (int64_t audio_channel_layout); void process_video (boost::shared_ptr, int, boost::shared_ptr); void process_audio (boost::shared_ptr); void process_end (); diff --git a/src/lib/stream.cc b/src/lib/stream.cc index e40738990..d1c2b5a9e 100644 --- a/src/lib/stream.cc +++ b/src/lib/stream.cc @@ -23,19 +23,40 @@ using namespace std; -Stream::Stream (string t) +AudioStream::AudioStream (string t) { stringstream n (t); - n >> id; - + n >> _id >> _channels; + + for (int i = 0; i < 2; ++i) { + size_t const s = t.find (' '); + if (s != string::npos) { + t = t.substr (s + 1); + } + } + + _name = t; +} + +string +AudioStream::to_string () const +{ + return String::compose ("%1 %2 %3", _id, _channels, _name); +} + +SubtitleStream::SubtitleStream (string t) +{ + stringstream n (t); + n >> _id; + size_t const s = t.find (' '); if (s != string::npos) { - name = t.substr (s + 1); + _name = t.substr (s + 1); } } string -Stream::to_string () const +SubtitleStream::to_string () const { - return String::compose ("%1 %2", id, name); + return String::compose ("%1 %2", _id, _name); } diff --git a/src/lib/stream.h b/src/lib/stream.h index 764c03d79..2db63c620 100644 --- a/src/lib/stream.h +++ b/src/lib/stream.h @@ -20,20 +20,63 @@ #ifndef DVDOMATIC_STREAM_H #define DVDOMATIC_STREAM_H -struct Stream +class Stream { public: - Stream (std::string t); + Stream () + : _id (-1) + {} Stream (std::string n, int i) - : name (n) - , id (i) + : _name (n) + , _id (i) {} - std::string to_string () const; + virtual std::string to_string () const = 0; - std::string name; - int id; + std::string name () const { + return _name; + } + + int id () const { + return _id; + } + +protected: + std::string _name; + int _id; +}; + +struct AudioStream : public Stream +{ +public: + AudioStream (std::string t); + + AudioStream (std::string n, int i, int c) + : Stream (n, i) + , _channels (c) + {} + + std::string to_string () const; + + int channels () const { + return _channels; + } + +private: + int _channels; +}; + +class SubtitleStream : public Stream +{ +public: + SubtitleStream (std::string t); + + SubtitleStream (std::string n, int i) + : Stream (n, i) + {} + + std::string to_string () const; }; #endif diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index b74d09174..a809e55d2 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -57,7 +57,7 @@ Transcoder::Transcoder (shared_ptr s, shared_ptr void Transcoder::go () { - _encoder->process_begin (_decoder->audio_channel_layout(), _decoder->audio_sample_format()); + _encoder->process_begin (_decoder->audio_channel_layout()); try { _decoder->go (); } catch (...) { diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 7ed3a14c7..36f3bc898 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -467,8 +467,6 @@ FilmEditor::film_changed (FilmState::Property p) _frames_per_second->SetLabel (std_to_wx (s.str ())); break; } - case FilmState::AUDIO_CHANNELS: - _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); case FilmState::AUDIO_SAMPLE_RATE: if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) { _audio->SetLabel (wxT ("")); @@ -546,10 +544,11 @@ FilmEditor::film_changed (FilmState::Property p) _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); break; case FilmState::AUDIO_STREAM: - set_selected_stream (_film->audio_streams(), _film->audio_stream(), _audio_stream); + _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); + _audio_stream->SetSelection (_film->audio_stream_index ()); break; case FilmState::SUBTITLE_STREAM: - set_selected_stream (_film->subtitle_streams(), _film->subtitle_stream(), _subtitle_stream); + _subtitle_stream->SetSelection (_film->subtitle_stream_index ()); break; } } @@ -621,7 +620,6 @@ FilmEditor::set_film (Film* f) film_changed (FilmState::SIZE); film_changed (FilmState::LENGTH); film_changed (FilmState::FRAMES_PER_SECOND); - film_changed (FilmState::AUDIO_CHANNELS); film_changed (FilmState::AUDIO_SAMPLE_RATE); film_changed (FilmState::SCALER); film_changed (FilmState::AUDIO_GAIN); @@ -885,33 +883,18 @@ void FilmEditor::setup_streams () { _audio_stream->Clear (); - vector s = _film->audio_streams (); - for (vector::iterator i = s.begin(); i != s.end(); ++i) { - _audio_stream->Append (std_to_wx (i->name)); + vector a = _film->audio_streams (); + for (vector::iterator i = a.begin(); i != a.end(); ++i) { + _audio_stream->Append (std_to_wx (i->name())); } - set_selected_stream (_film->audio_streams(), _film->audio_stream(), _audio_stream); + _audio_stream->SetSelection (_film->audio_stream_index ()); _subtitle_stream->Clear (); - s = _film->subtitle_streams (); - for (vector::iterator i = s.begin(); i != s.end(); ++i) { - _subtitle_stream->Append (std_to_wx (i->name)); - } - set_selected_stream (_film->subtitle_streams(), _film->subtitle_stream(), _subtitle_stream); -} - -void -FilmEditor::set_selected_stream (vector const & streams, int id, wxComboBox* combo) const -{ - if (id == -1) { - return; - } - - size_t n = 0; - while (n < streams.size() && streams[n].id != id) { - ++n; + vector s = _film->subtitle_streams (); + for (vector::iterator i = s.begin(); i != s.end(); ++i) { + _subtitle_stream->Append (std_to_wx (i->name())); } - assert (n < streams.size()); - combo->SetSelection (n); + _subtitle_stream->SetSelection (_film->subtitle_stream_index ()); } void @@ -922,12 +905,7 @@ FilmEditor::audio_stream_changed (wxCommandEvent &) } _ignore_changes = Film::AUDIO_STREAM; - int const n = _audio_stream->GetSelection (); - if (n >= 0) { - vector s = _film->audio_streams (); - assert (n < int (s.size ())); - _film->set_audio_stream (s[n].id); - } + _film->set_audio_stream (_audio_stream->GetSelection ()); _ignore_changes = Film::NONE; } @@ -939,11 +917,6 @@ FilmEditor::subtitle_stream_changed (wxCommandEvent &) } _ignore_changes = Film::SUBTITLE_STREAM; - int const n = _subtitle_stream->GetSelection (); - if (n >= 0) { - vector s = _film->subtitle_streams (); - assert (n < int (s.size ())); - _film->set_subtitle_stream (s[n].id); - } + _film->set_subtitle_stream (_subtitle_stream->GetSelection ()); _ignore_changes = Film::NONE; } diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index b50bfd1f9..2439b01dd 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -79,7 +79,6 @@ private: void setup_formats (); void setup_subtitle_button (); void setup_streams (); - void set_selected_stream (std::vector const & streams, int id, wxComboBox* combo) const; wxControl* video_control (wxControl *); wxControl* still_control (wxControl *); diff --git a/test/metadata.ref b/test/metadata.ref index 67053bd58..652867ce0 100644 --- a/test/metadata.ref +++ b/test/metadata.ref @@ -31,9 +31,7 @@ package_type width 0 height 0 length 0 -audio_channels 0 audio_sample_rate 0 -audio_sample_format Unknown content_digest has_subtitles 0 frames_per_second 0 diff --git a/test/test.cc b/test/test.cc index 7ca6d0cd3..468e6c1fd 100644 --- a/test/test.cc +++ b/test/test.cc @@ -501,3 +501,16 @@ BOOST_AUTO_TEST_CASE (job_manager_test) BOOST_CHECK_EQUAL (a->finished_in_error(), true); BOOST_CHECK_EQUAL (b->running(), false); } + +BOOST_AUTO_TEST_CASE (stream_test) +{ + AudioStream a ("4 9 hello there world"); + BOOST_CHECK_EQUAL (a.id(), 4); + BOOST_CHECK_EQUAL (a.channels(), 9); + BOOST_CHECK_EQUAL (a.name(), "hello there world"); + BOOST_CHECK_EQUAL (a.to_string(), "4 9 hello there world"); + + SubtitleStream s ("5 a b c"); + BOOST_CHECK_EQUAL (s.id(), 5); + BOOST_CHECK_EQUAL (s.name(), "a b c"); +} -- 2.30.2