openscenegraph
ImageStream
Go to the documentation of this file.
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// forward declare of osg::Texture
23class Texture;
24
25/**
26 * Image Stream class.
27*/
28class OSG_EXPORT ImageStream : public Image
29{
30 public:
31 ImageStream();
32
33 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
34 ImageStream(const ImageStream& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
35
36 virtual Object* cloneType() const { return new ImageStream(); }
37 virtual Object* clone(const CopyOp& copyop) const { return new ImageStream(*this,copyop); }
38 virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImageStream*>(obj)!=0; }
39 virtual const char* libraryName() const { return "osg"; }
40 virtual const char* className() const { return "ImageStream"; }
41
42 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
43 virtual int compare(const Image& rhs) const;
44
45 enum StreamStatus
46 {
47 INVALID,
48 PLAYING,
49 PAUSED,
50 REWINDING
51 };
52
53 virtual void seek(double /*time*/) {}
54
55 virtual void play() { _status=PLAYING; }
56
57 virtual void pause() { _status=PAUSED; }
58
59 virtual void rewind() { _status=REWINDING; }
60
61 virtual void quit(bool /*waitForThreadToExit*/ = true) {}
62
63 StreamStatus getStatus() const { return _status; }
64
65
66 enum LoopingMode
67 {
68 NO_LOOPING,
69 LOOPING
70 };
71
72 void setLoopingMode(LoopingMode mode)
73 {
74 if (_loopingMode == mode) return;
75
76 _loopingMode = mode;
77 applyLoopingMode();
78 }
79
80 LoopingMode getLoopingMode() const { return _loopingMode; }
81
82 virtual double getCreationTime() const { return HUGE_VAL; }
83 virtual double getLength() const { return 0.0; }
84 virtual double getFrameRate() const { return 0.0; }
85 virtual double getCurrentTime() const { return 0.0; }
86
87 virtual void setReferenceTime(double) {}
88 virtual double getReferenceTime() const { return 0.0; }
89
90 virtual void setTimeMultiplier(double) {}
91 virtual double getTimeMultiplier() const { return 0.0; }
92
93 virtual void setVolume(float) {}
94 virtual float getVolume() const { return 0.0f; }
95
96 /// set the balance of the audio: -1 = left, 0 = center, 1 = right
97 virtual float getAudioBalance() { return 0.0f; }
98 virtual void setAudioBalance(float /*b*/) {}
99
100 typedef std::vector< osg::ref_ptr<osg::AudioStream> > AudioStreams;
101 void setAudioStreams(const AudioStreams& asl) { _audioStreams = asl; }
102 AudioStreams& getAudioStreams() { return _audioStreams; }
103 const AudioStreams& getAudioStreams() const { return _audioStreams; }
104
105 /** create a suitable texture for this imagestream, return NULL, if not supported
106 * implement this method in subclasses to use special technologies like CoreVideo
107 * or similar.
108 */
109 virtual osg::Texture* createSuitableTexture() { return NULL; }
110
111 protected:
112 virtual void applyLoopingMode() {}
113
114 virtual ~ImageStream() {}
115
116 StreamStatus _status;
117 LoopingMode _loopingMode;
118
119 AudioStreams _audioStreams;
120};
121
122} // namespace
123
124#endif