Gnash  0.8.11dev
StreamingSound.h
Go to the documentation of this file.
1 // StreamingSound.h - instance of an embedded sound, for gnash
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
5 //
6 // This program 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 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program 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 this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef SOUND_STREAMINGSOUND_H
21 #define SOUND_STREAMINGSOUND_H
22 
23 #include <boost/scoped_ptr.hpp>
24 #include <cassert>
25 #include <boost/cstdint.hpp> // For C99 int types
26 
27 #include "LiveSound.h"
28 #include "AudioDecoder.h"
29 #include "SoundEnvelope.h"
30 #include "SimpleBuffer.h"
31 #include "StreamingSoundData.h"
32 #include "sound_handler.h"
33 
34 // Forward declarations
35 namespace gnash {
36  namespace sound {
37  class StreamingSoundData;
38  }
39  namespace media {
40  class MediaHandler;
41  }
42 }
43 
44 namespace gnash {
45 namespace sound {
46 
48 //
51 class StreamingSound : public LiveSound
52 {
53 public:
54 
56  //
63 
64  // See dox in sound_handler.h (InputStream)
65  virtual bool eof() const;
66 
68  //
71 
72  size_t currentBlock() const {
73  return _currentBlock;
74  }
75 
76 private:
77 
79  //
82  virtual bool moreData();
83 
85  virtual bool decodingCompleted() const {
86  return _positionInBlock == 0 &&
87  _currentBlock >= _soundDef.blockCount();
88  }
89 
91  //
93  void decodeNextBlock();
94 
95  // The current block of sound.
96  size_t _currentBlock;
97 
98  // The position within the current block.
99  size_t _positionInBlock;
100 
102  //
106  StreamingSoundData& _soundDef;
107 };
108 
109 
110 } // gnash.sound namespace
111 } // namespace gnash
112 
113 #endif