ImageStream 3.9 KB

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