root/OpenSceneGraph/trunk/include/osg/ImageStream @ 9827

Revision 9827, 3.3 kB (checked in by robert, 4 years ago)

Introduced osg::AudioStream? class to help manage audio streams coming in from movie reading plugins

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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_IMAGESTREAM
15#define OSG_IMAGESTREAM 1
16
17#include <osg/Image>
18#include <osg/AudioStream>
19
20namespace osg {
21
22/**
23  * Image Stream class.
24*/
25class OSG_EXPORT ImageStream : public Image
26{
27    public:
28        ImageStream();
29
30        /** Copy constructor using CopyOp to manage deep vs shallow copy. */
31        ImageStream(const ImageStream& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
32
33        virtual Object* cloneType() const { return new ImageStream(); }
34        virtual Object* clone(const CopyOp& copyop) const { return new ImageStream(*this,copyop); }
35        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImageStream*>(obj)!=0; }
36        virtual const char* libraryName() const { return "osg"; }
37        virtual const char* className() const { return "ImageStream"; }
38
39        /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
40        virtual int compare(const Image& rhs) const;
41
42        enum StreamStatus
43        {
44            INVALID,
45            PLAYING,
46            PAUSED,
47            REWINDING
48        };
49       
50        virtual void seek(double /*time*/) {}
51
52        virtual void play() { _status=PLAYING; }
53
54        virtual void pause() { _status=PAUSED; }
55
56        virtual void rewind() { _status=REWINDING; }
57       
58        virtual void quit(bool /*waitForThreadToExit*/ = true) {}
59
60        StreamStatus getStatus() { return _status; }
61       
62
63        enum LoopingMode
64        {
65            NO_LOOPING,
66            LOOPING
67        };
68       
69        void setLoopingMode(LoopingMode mode)
70        {
71            if (_loopingMode == mode) return;
72           
73            _loopingMode = mode;
74            applyLoopingMode();
75        }
76       
77        LoopingMode getLoopingMode() const { return _loopingMode; }
78
79
80        virtual double getLength() const { return 0.0; }
81       
82        virtual void setReferenceTime(double) {}
83        virtual double getReferenceTime() const { return 0.0; }
84               
85        virtual void setTimeMultiplier(double) {}
86        virtual double getTimeMultiplier() const { return 0.0; }
87       
88        virtual void setVolume(float) {}
89        virtual float getVolume() const { return 0.0f; }
90
91
92        typedef std::vector< osg::ref_ptr<osg::AudioStream> > AudioStreams;
93        void setAudioStreams(const AudioStreams& asl) { _audioStreams = asl; }
94        AudioStreams& getAudioStreams() { return _audioStreams; }
95        const AudioStreams& getAudioStreams() const { return _audioStreams; }
96       
97
98    protected:
99        virtual void applyLoopingMode() {}
100
101        virtual ~ImageStream() {}
102
103        StreamStatus    _status;
104        LoopingMode     _loopingMode;
105       
106        AudioStreams    _audioStreams;
107};
108
109} // namespace
110
111#endif
Note: See TracBrowser for help on using the browser.