root/OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp @ 9826

Revision 9826, 2.6 kB (checked in by robert, 5 years ago)

Ported across from using boost pointers, and prepped for integration of audio interface into core OSG

RevLine 
[9816]1
2#ifndef HEADER_GUARD_OSGFFMPEG_FFMPEG_IMAGE_STREAM_H
3#define HEADER_GUARD_OSGFFMPEG_FFMPEG_IMAGE_STREAM_H
4
5#include <osg/ImageStream>
6
7#include <OpenThreads/Condition>
8#include <OpenThreads/Thread>
9
10#include "AudioSinkInterface.hpp"
11#include "FFmpegSampleFormat.hpp"
12
13
14
15#ifdef _WIN32
16    #if defined OSG_LIBRARY_STATIC
17    #define OSGFFMPEG_EXPORT_API
18    #elif defined OSG_LIBRARY || defined osgFFmpeg_EXPORTS
19    #define OSGFFMPEG_EXPORT_API  __declspec(dllexport)
20    #else
21    #define OSGFFMPEG_EXPORT_API  __declspec(dllimport)
22    #endif
23#else
24    #define OSGFFMPEG_EXPORT_API
25#endif
26
27
28
29namespace osgFFmpeg
30{
31
32    class FFmpegDecoder;
33    class FFmpegDecoderAudio;
34    class FFmpegDecoderVideo;
35
36    template <class T>
37    class MessageQueue;
38
39
40    class OSGFFMPEG_EXPORT_API FFmpegImageStream : public osg::ImageStream, public OpenThreads::Thread
41    {
42    public:
43
44        FFmpegImageStream();
45        FFmpegImageStream(const FFmpegImageStream & image, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY);
46
47        META_Object(osgFFmpeg, FFmpegImageStream);
48
49        bool open(const std::string & filename);
50
51        virtual void play();
52        virtual void pause();
53        virtual void rewind();
54        virtual void quit(bool waitForThreadToExit = true);
55
[9826]56        virtual void setAudioSink(osg::AudioSinkInterface* audio_sink);
57       
[9816]58        void fillAudioBuffer(void * const buffer, const size_t size);
59
60        double duration() const;
61
62        bool videoAlphaChannel() const;
63        double videoAspectRatio() const;
64        double videoFrameRate() const;
65
66        bool audioStream() const;
67        int audioFrequency() const;
68        int audioNbChannels() const;
69        FFmpegSampleFormat audioSampleFormat() const;
70
71    private:
72
73        enum Command
74        {
75            CMD_PLAY,
76            CMD_PAUSE,
77            CMD_STOP,
78            CMD_REWIND
79        };
80
81        typedef MessageQueue<Command> CommandQueue;
82        typedef OpenThreads::Mutex Mutex;
83        typedef OpenThreads::Condition Condition;
84
85        virtual ~FFmpegImageStream();
86        virtual void run();
87        virtual void applyLoopingMode();
88
89        bool handleCommand(Command cmd);
90
91        void cmdPlay();
92        void cmdPause();
93        void cmdRewind();
94
95        static void publishNewFrame(const FFmpegDecoderVideo &, void * user_data);
96
97        FFmpegDecoder *    m_decoder;
98        CommandQueue *    m_commands;
99
100        Mutex            m_mutex;
101        Condition        m_frame_published_cond;
102        bool            m_frame_published_flag;
103    };
104
105}
106
107
108
109#endif // HEADER_GUARD_OSGFFMPEG_FFMPEG_IMAGE_STREAM_H
Note: See TracBrowser for help on using the browser.