Changeset 9847
- Timestamp:
- 03/03/09 17:51:01 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 2 added
- 12 modified
-
CMakeLists.txt (modified) (1 diff)
-
examples/osgmovie/CMakeLists.txt (modified) (1 diff)
-
examples/osgmovie/osgmovie.cpp (modified) (3 diffs)
-
include/osg/AudioStream (modified) (3 diffs)
-
src/osg/AudioStream.cpp (modified) (1 diff)
-
src/osgPlugins/CMakeLists.txt (modified) (1 diff)
-
src/osgPlugins/ffmpeg/CMakeLists.txt (modified) (2 diffs)
-
src/osgPlugins/ffmpeg/FFmpegAudioStream.cpp (added)
-
src/osgPlugins/ffmpeg/FFmpegAudioStream.hpp (added)
-
src/osgPlugins/ffmpeg/FFmpegDecoder.hpp (modified) (1 diff)
-
src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp (modified) (1 diff)
-
src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp (modified) (2 diffs)
-
src/osgPlugins/ffmpeg/FFmpegImageStream.cpp (modified) (5 diffs)
-
src/osgPlugins/ffmpeg/FFmpegImageStream.hpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/CMakeLists.txt
r9817 r9847 311 311 FIND_PACKAGE(LibVNCServer) 312 312 FIND_PACKAGE(OurDCMTK) 313 FIND_PACKAGE(OpenAL) 313 314 FIND_PACKAGE(XUL) 314 315 FIND_PACKAGE(FFmpeg) -
OpenSceneGraph/trunk/examples/osgmovie/CMakeLists.txt
r7025 r9847 1 #this file is automatically generated 2 1 # INCLUDE_DIRECTORIES( ${OPENAL_INCLUDE_DIR} ) 3 2 4 3 SET(TARGET_SRC osgmovie.cpp ) 5 4 SET(TARGET_ADDED_LIBRARIES osgGA ) 5 6 # SET(TARGET_EXTERNAL_LIBRARIES ${OPENAL_LIBRARY} alut) 7 6 8 #### end var setup ### 7 9 SETUP_EXAMPLE(osgmovie) -
OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
r9705 r9847 321 321 } 322 322 323 class CustomAudioSink : public osg::AudioSink 324 { 325 public: 326 327 CustomAudioSink(osg::AudioStream* audioStream): 328 _playing(false), 329 _audioStream(audioStream) {} 330 331 virtual void startPlaying() 332 { 333 _playing = true; 334 osg::notify(osg::NOTICE)<<"CustomAudioSink()::startPlaying()"<<std::endl; 335 336 osg::notify(osg::NOTICE)<<" audioFrequency()="<<_audioStream->audioFrequency()<<std::endl; 337 osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<std::endl; 338 osg::notify(osg::NOTICE)<<" audioSampleFormat()="<<_audioStream->audioSampleFormat()<<std::endl; 339 340 } 341 virtual bool playing() const { return _playing; } 342 343 bool _playing; 344 osg::observer_ptr<osg::AudioStream> _audioStream; 345 }; 346 323 347 int main(int argc, char** argv) 324 348 { … … 426 450 427 451 bool xyPlane = fullscreen; 452 453 bool useOpenALAudio = false; 454 while(arguments.read("--OpenAL")) { useOpenALAudio = true; } 428 455 429 456 for(int i=1;i<arguments.argc();++i) … … 433 460 osg::Image* image = osgDB::readImageFile(arguments[i]); 434 461 osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image); 435 if (imagestream) imagestream->play(); 462 if (imagestream) 463 { 464 osg::ImageStream::AudioStreams& audioStreams = imagestream->getAudioStreams(); 465 if (useOpenALAudio && !audioStreams.empty()) 466 { 467 osg::AudioStream* audioStream = audioStreams[0].get(); 468 osg::notify(osg::NOTICE)<<"AudioStream read ["<<audioStream->getName()<<"]"<<std::endl; 469 audioStream->setAudioSink(new CustomAudioSink(audioStream)); 470 } 471 472 473 imagestream->play(); 474 } 436 475 437 476 if (image) -
OpenSceneGraph/trunk/include/osg/AudioStream
r9827 r9847 19 19 namespace osg { 20 20 21 /** Pure virtual AudioSink Interfacebass class that is used to connect the audio system with AudioStreams. */22 class OSG_EXPORT AudioSink Interface: public osg::Object21 /** Pure virtual AudioSink bass class that is used to connect the audio system with AudioStreams. */ 22 class OSG_EXPORT AudioSink : public osg::Object 23 23 { 24 24 public: 25 25 26 AudioSink Interface();26 AudioSink(); 27 27 28 28 virtual void startPlaying() = 0; … … 37 37 private: 38 38 39 virtual AudioSink Interface* cloneType() const { return 0; }40 virtual AudioSink Interface* clone(const osg::CopyOp &) const { return 0; }39 virtual AudioSink * cloneType() const { return 0; } 40 virtual AudioSink * clone(const osg::CopyOp &) const { return 0; } 41 41 42 42 double _delay; … … 56 56 virtual const char* className() const { return "AudioStream"; } 57 57 58 virtual void setAudioSink(osg::AudioSink Interface* audio_sink) = 0;58 virtual void setAudioSink(osg::AudioSink* audio_sink) = 0; 59 59 60 60 virtual void consumeAudioBuffer(void * const buffer, const size_t size) = 0; -
OpenSceneGraph/trunk/src/osg/AudioStream.cpp
r9827 r9847 16 16 using namespace osg; 17 17 18 AudioSink Interface::AudioSinkInterface() :18 AudioSink::AudioSink() : 19 19 _delay(0.0) 20 20 { -
OpenSceneGraph/trunk/src/osgPlugins/CMakeLists.txt
r9817 r9847 201 201 ENDIF(FFMPEG_FOUND) 202 202 203 IF(OPENAL_FOUND) 204 ADD_SUBDIRECTORY(OpenAL) 205 ENDIF(OPENAL_FOUND) 206 203 207 IF(QUICKTIME_FOUND) 204 208 ADD_SUBDIRECTORY(quicktime) -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/CMakeLists.txt
r9842 r9847 20 20 FFmpegDecoderVideo.cpp 21 21 FFmpegImageStream.cpp 22 FFmpegAudioStream.cpp 22 23 ReaderWriterFFmpeg.cpp 23 24 ) … … 31 32 FFmpegHeaders.hpp 32 33 FFmpegPacket.hpp 34 FFmpegImageStream.hpp 35 FFmpegAudioStream.hpp 33 36 MessageQueue.hpp 34 37 ) -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoder.hpp
r9826 r9847 57 57 58 58 59 class FFmpegDecoder 59 class FFmpegDecoder : public osg::Referenced 60 60 { 61 61 public: -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
r9827 r9847 107 107 108 108 109 void FFmpegDecoderAudio::setAudioSink(osg::ref_ptr<osg::AudioSink Interface> audio_sink)109 void FFmpegDecoderAudio::setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink) 110 110 { 111 111 // The FFmpegDecoderAudio object takes the responsability of destroying the audio_sink. 112 osg::notify(osg::NOTICE)<<"Assigning "<<audio_sink<<std::endl; 112 113 m_audio_sink = audio_sink; 113 114 } -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp
r9827 r9847 32 32 virtual void run(); 33 33 34 void setAudioSink(osg::ref_ptr<osg::AudioSink Interface> audio_sink);34 void setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink); 35 35 void fillBuffer(void * buffer, size_t size); 36 36 … … 43 43 44 44 //typedef boost::shared_ptr<AVFrame> FramePtr; 45 typedef osg::ref_ptr<osg::AudioSink Interface> SinkPtr;45 typedef osg::ref_ptr<osg::AudioSink> SinkPtr; 46 46 typedef std::vector<uint8_t> Buffer; 47 47 -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp
r9827 r9847 1 1 2 2 #include "FFmpegImageStream.hpp" 3 #include "FFmpegAudioStream.hpp" 3 4 4 5 #include <OpenThreads/ScopedLock> 5 6 #include <osg/Notify> 6 7 #include "FFmpegDecoder.hpp"8 #include "MessageQueue.hpp"9 7 10 8 #include <memory> … … 45 43 46 44 delete m_commands; 47 delete m_decoder;48 45 } 49 46 … … 64 61 m_decoder->video_decoder().setUserData(this); 65 62 m_decoder->video_decoder().setPublishCallback(publishNewFrame); 63 64 if (m_decoder->audio_decoder().validContext()) 65 { 66 osg::notify(osg::NOTICE)<<"Attaching FFmpegAudioStream"<<std::endl; 67 68 getAudioStreams().push_back(new FFmpegAudioStream(m_decoder.get())); 69 } 66 70 67 71 _status = PAUSED; … … 121 125 122 126 123 124 void FFmpegImageStream::setAudioSink(osg::AudioSinkInterface* audio_sink)125 {126 m_decoder->audio_decoder().setAudioSink(audio_sink);127 }128 129 130 void FFmpegImageStream::consumeAudioBuffer(void * const buffer, const size_t size)131 {132 m_decoder->audio_decoder().fillBuffer(buffer, size);133 }134 135 136 137 127 double FFmpegImageStream::duration() const 138 128 { … … 160 150 return m_decoder->video_decoder().frameRate(); 161 151 } 162 163 164 165 bool FFmpegImageStream::audioStream() const166 {167 return m_decoder->audio_decoder().validContext();168 }169 170 171 172 int FFmpegImageStream::audioFrequency() const173 {174 return m_decoder->audio_decoder().frequency();175 }176 177 178 179 int FFmpegImageStream::audioNbChannels() const180 {181 return m_decoder->audio_decoder().nbChannels();182 }183 184 185 186 osg::AudioStream::SampleFormat FFmpegImageStream::audioSampleFormat() const187 {188 return m_decoder->audio_decoder().sampleFormat();189 }190 191 152 192 153 -
OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp
r9843 r9847 8 8 #include <OpenThreads/Thread> 9 9 10 #include "FFmpegDecoder.hpp" 11 #include "MessageQueue.hpp" 12 10 13 namespace osgFFmpeg 11 14 { 12 15 13 class FFmpegDecoder;14 class FFmpegDecoderAudio;15 class FFmpegDecoderVideo;16 17 16 template <class T> 18 17 class MessageQueue; 19 20 18 21 19 class FFmpegImageStream : public osg::ImageStream, public OpenThreads::Thread … … 34 32 virtual void rewind(); 35 33 virtual void quit(bool waitForThreadToExit = true); 36 37 virtual void setAudioSink(osg::AudioSinkInterface* audio_sink);38 39 void consumeAudioBuffer(void * const buffer, const size_t size);40 41 bool audioStream() const;42 int audioFrequency() const;43 int audioNbChannels() const;44 osg::AudioStream::SampleFormat audioSampleFormat() const;45 34 46 35 double duration() const; … … 77 66 static void publishNewFrame(const FFmpegDecoderVideo &, void * user_data); 78 67 79 FFmpegDecoder *m_decoder;68 osg::ref_ptr<FFmpegDecoder> m_decoder; 80 69 CommandQueue * m_commands; 81 70
