Basic grunt-work, untested and unfinished, but it compiles.
[dcpomatic.git] / src / lib / audio_decoder_stream.h
1 /*
2     Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_AUDIO_DECODER_STREAM_H
22 #define DCPOMATIC_AUDIO_DECODER_STREAM_H
23
24 #include "audio_stream.h"
25 #include "content_audio.h"
26 #include "dcpomatic_time.h"
27 #include <boost/shared_ptr.hpp>
28
29 class AudioContent;
30 class AudioDecoder;
31 class Resampler;
32 class Log;
33 class Decoder;
34
35 class AudioDecoderStream
36 {
37 public:
38         AudioDecoderStream (boost::shared_ptr<const AudioContent>, AudioStreamPtr, Decoder* decoder, AudioDecoder* audio_decoder, boost::shared_ptr<Log> log);
39
40         void audio (boost::shared_ptr<const AudioBuffers>, ContentTime);
41         void flush ();
42         void set_fast ();
43
44         boost::optional<ContentTime> position () const;
45
46 private:
47
48         void reset_decoded ();
49         void add (boost::shared_ptr<const AudioBuffers>);
50
51         boost::shared_ptr<const AudioContent> _content;
52         AudioStreamPtr _stream;
53         Decoder* _decoder;
54         AudioDecoder* _audio_decoder;
55         boost::shared_ptr<Log> _log;
56         boost::shared_ptr<Resampler> _resampler;
57         boost::optional<Frame> _position;
58         /** Currently-available decoded audio data */
59         ContentAudio _decoded;
60         /** The time of an accurate seek after which we have not yet received any actual
61             data at the seek time.
62         */
63         boost::optional<ContentTime> _seek_reference;
64 };
65
66 #endif