| [9827] | 1 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield |
|---|
| 2 | * |
|---|
| 3 | * This library is open source and may be redistributed and/or modified under |
|---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
|---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
|---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
|---|
| 7 | * |
|---|
| 8 | * This library is distributed in the hope that it will be useful, |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | * OpenSceneGraph Public License for more details. |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | #ifndef OSG_AUDIOSTREAM |
|---|
| 15 | #define OSG_AUDIOSTREAM 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/Image> |
|---|
| 18 | |
|---|
| 19 | namespace osg { |
|---|
| 20 | |
|---|
| [9847] | 21 | /** Pure virtual AudioSink bass class that is used to connect the audio system with AudioStreams. */ |
|---|
| 22 | class OSG_EXPORT AudioSink : public osg::Object |
|---|
| [9827] | 23 | { |
|---|
| 24 | public: |
|---|
| 25 | |
|---|
| [9847] | 26 | AudioSink(); |
|---|
| [9827] | 27 | |
|---|
| 28 | virtual void startPlaying() = 0; |
|---|
| 29 | virtual bool playing() const = 0; |
|---|
| 30 | |
|---|
| 31 | virtual double getDelay() const { return _delay; } |
|---|
| 32 | virtual void setDelay(const double delay) { _delay = delay; } |
|---|
| 33 | |
|---|
| 34 | virtual const char * libraryName() const { return "osgFFmpeg"; } |
|---|
| 35 | virtual const char * className() const { return "AudioSinkInterface"; } |
|---|
| 36 | |
|---|
| 37 | private: |
|---|
| 38 | |
|---|
| [9847] | 39 | virtual AudioSink * cloneType() const { return 0; } |
|---|
| 40 | virtual AudioSink * clone(const osg::CopyOp &) const { return 0; } |
|---|
| [9827] | 41 | |
|---|
| 42 | double _delay; |
|---|
| 43 | }; |
|---|
| 44 | |
|---|
| 45 | /** Pure virtual AudioStream base class. Subclasses provide mechanism for reading/generating audio data*/ |
|---|
| 46 | class OSG_EXPORT AudioStream : public osg::Object |
|---|
| 47 | { |
|---|
| 48 | public: |
|---|
| 49 | AudioStream(); |
|---|
| 50 | |
|---|
| 51 | /** Copy constructor using CopyOp to manage deep vs shallow copy. */ |
|---|
| 52 | AudioStream(const AudioStream& audio,const CopyOp& copyop=CopyOp::SHALLOW_COPY); |
|---|
| 53 | |
|---|
| 54 | virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const AudioStream*>(obj)!=0; } |
|---|
| 55 | virtual const char* libraryName() const { return "osg"; } |
|---|
| 56 | virtual const char* className() const { return "AudioStream"; } |
|---|
| 57 | |
|---|
| [9847] | 58 | virtual void setAudioSink(osg::AudioSink* audio_sink) = 0; |
|---|
| [9827] | 59 | |
|---|
| 60 | virtual void consumeAudioBuffer(void * const buffer, const size_t size) = 0; |
|---|
| 61 | |
|---|
| 62 | virtual int audioFrequency() const = 0; |
|---|
| 63 | virtual int audioNbChannels() const = 0; |
|---|
| 64 | |
|---|
| 65 | enum SampleFormat |
|---|
| 66 | { |
|---|
| 67 | SAMPLE_FORMAT_U8, |
|---|
| 68 | SAMPLE_FORMAT_S16, |
|---|
| 69 | SAMPLE_FORMAT_S24, |
|---|
| 70 | SAMPLE_FORMAT_S32, |
|---|
| 71 | SAMPLE_FORMAT_F32 |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | virtual SampleFormat audioSampleFormat() const = 0; |
|---|
| 75 | }; |
|---|
| 76 | |
|---|
| 77 | } // namespace |
|---|
| 78 | |
|---|
| 79 | #endif |
|---|