Gnash  0.8.10
StreamingSound.h
Go to the documentation of this file.
00001 // StreamingSound.h - instance of an embedded sound, for gnash
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef SOUND_STREAMINGSOUND_H
00021 #define SOUND_STREAMINGSOUND_H
00022 
00023 #include <boost/scoped_ptr.hpp>
00024 #include <cassert>
00025 #include <boost/cstdint.hpp> // For C99 int types
00026 
00027 #include "LiveSound.h" 
00028 #include "AudioDecoder.h" 
00029 #include "SoundEnvelope.h"
00030 #include "SimpleBuffer.h" 
00031 #include "StreamingSoundData.h" 
00032 #include "sound_handler.h" 
00033 
00034 // Forward declarations
00035 namespace gnash {
00036     namespace sound {
00037         class StreamingSoundData;
00038     }
00039     namespace media {
00040         class MediaHandler;
00041     }
00042 }
00043 
00044 namespace gnash {
00045 namespace sound {
00046 
00048 //
00051 class StreamingSound : public LiveSound
00052 {
00053 public:
00054 
00056     //
00061     StreamingSound(StreamingSoundData& def, media::MediaHandler& mh,
00062             sound_handler::StreamBlockId blockId);
00063 
00064     // See dox in sound_handler.h (InputStream)
00065     virtual bool eof() const;
00066 
00068     //
00070     ~StreamingSound();
00071 
00072     size_t currentBlock() const {
00073         return _currentBlock;
00074     }
00075 
00076 private:
00077 
00079     //
00082     virtual bool moreData();
00083 
00085     virtual bool decodingCompleted() const {
00086         return _positionInBlock == 0 && 
00087             _currentBlock >= _soundDef.blockCount();
00088     }
00089 
00091     //
00093     void decodeNextBlock();
00094 
00095     // The current block of sound.
00096     size_t _currentBlock;
00097 
00098     // The position within the current block.
00099     size_t _positionInBlock;
00100 
00102     //
00106     StreamingSoundData& _soundDef;
00107 };
00108 
00109 
00110 } // gnash.sound namespace 
00111 } // namespace gnash
00112 
00113 #endif