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 <memory>
24 #include <cassert>
25 #include <cstdint> // For C99 int types
26 
27 #include "LiveSound.h"
28 #include "StreamingSoundData.h"
29 #include "sound_handler.h"
30 
31 // Forward declarations
32 namespace gnash {
33  namespace sound {
34  class StreamingSoundData;
35  }
36  namespace media {
37  class MediaHandler;
38  }
39 }
40 
41 namespace gnash {
42 namespace sound {
43 
45 //
48 class StreamingSound : public LiveSound
49 {
50 public:
51 
53  //
60 
61  // See dox in sound_handler.h (InputStream)
62  virtual bool eof() const;
63 
65  //
68 
69  size_t currentBlock() const {
70  return _currentBlock;
71  }
72 
73 private:
74 
76  //
79  virtual bool moreData();
80 
82  virtual bool decodingCompleted() const {
83  return _positionInBlock == 0 &&
84  _currentBlock >= _soundDef.blockCount();
85  }
86 
88  //
90  void decodeNextBlock();
91 
92  // The current block of sound.
93  size_t _currentBlock;
94 
95  // The position within the current block.
96  size_t _positionInBlock;
97 
99  //
103  StreamingSoundData& _soundDef;
104 };
105 
106 
107 } // gnash.sound namespace
108 } // namespace gnash
109 
110 #endif
sound_handler.h
gnash::sound::StreamingSound::currentBlock
size_t currentBlock() const
Definition: StreamingSound.h:69
AudioDecoder.h
LiveSound.h
gnash::sound::StreamingSoundData::getBlock
const SimpleBuffer & getBlock(size_t index) const
Definition: StreamingSoundData.h:78
StreamingSound.h
StreamingSoundData.h
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::sound::StreamingSound::StreamingSound
StreamingSound(StreamingSoundData &def, media::MediaHandler &mh, sound_handler::StreamBlockId blockId)
Create an embedded sound instance.
Definition: StreamingSound.cpp:51
gnash::sound::LiveSound
Instance of a defined sound (LiveSoundData)
Definition: LiveSound.h:47
gnash::media::MediaHandler
The MediaHandler class acts as a factory to provide parser and decoders.
Definition: MediaHandler.h:70
gnash::media::AudioDecoder::decode
virtual std::uint8_t * decode(const std::uint8_t *input, std::uint32_t inputSize, std::uint32_t &outputSize, std::uint32_t &decodedData)
Decodes a frame and returns a pointer to the data.
Definition: AudioDecoder.h:88
gnash::sound::LiveSound::appendDecodedData
void appendDecodedData(std::uint8_t *data, unsigned int size)
Definition: LiveSound.h:99
gnash::sound::adjustVolume
void adjustVolume(T *start, T *end, float volume)
Volume adjustment.
Definition: SoundUtils.h:39
gnash::sound::StreamingSoundData::volume
int volume
Definition: StreamingSoundData.h:160
gnash::SimpleBuffer::size
size_t size() const
Return size of the buffer.
Definition: SimpleBuffer.h:75
gnash::SimpleBuffer::data
std::uint8_t * data()
Get a pointer to start of data. May be NULL if size==0.
Definition: SimpleBuffer.h:81
gnash::sound::StreamingSound::~StreamingSound
~StreamingSound()
Unregister self from the associated StreamingSoundData.
Definition: StreamingSound.cpp:122
SoundUtils.h
gnash::sound::LiveSound::decodedSamplesAhead
unsigned int decodedSamplesAhead() const
Definition: LiveSound.h:106
gnash::sound::LiveSound::decoder
media::AudioDecoder & decoder() const
Definition: LiveSound.h:95
log.h
gnash::sound::swfToOutSamples
size_t swfToOutSamples(const media::SoundInfo &sinfo, size_t swfSamples, const size_t outRate=44100)
Convert SWF-specified number of samples to output number of samples.
Definition: SoundUtils.h:55
gnash::sound::sound_handler::StreamBlockId
unsigned long StreamBlockId
Identifier of a streaming sound block.
Definition: sound_handler.h:97
gnash::sound::StreamingSoundData::blockCount
size_t blockCount() const
Definition: StreamingSoundData.h:90
gnash::sound::StreamingSoundData::eraseActiveSound
Instances::iterator eraseActiveSound(Instances::iterator i)
Drop an active sound (by iterator)
Definition: StreamingSoundData.cpp:70
gnash::sound::StreamingSound
Instance of a defined sound (StreamingSoundData)
Definition: StreamingSound.h:49
data
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
gnash::sound::StreamingSound::eof
virtual bool eof() const
True if there is no more data ever.
Definition: StreamingSound.cpp:116
gnash::SimpleBuffer
A simple buffer of bytes.
Definition: SimpleBuffer.h:38
gnash::sound::StreamingSoundData
Definition of an embedded sound.
Definition: StreamingSoundData.h:48