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

Revision 10851, 2.0 kB (checked in by robert, 5 years ago)

From Julen Garcia,"I've been lately working also with the ffmpeg plugin and I implemented pause(), seek() and getReferenceTime(). I think that I have solved the internal clock issues (maybe not in the most elegant way :?"

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
[9847]10#include "FFmpegDecoder.hpp"
11#include "MessageQueue.hpp"
12
[9816]13namespace osgFFmpeg
14{
15
16    template <class T>
17    class MessageQueue;
18
[9843]19    class FFmpegImageStream : public osg::ImageStream, public OpenThreads::Thread
[9816]20    {
21    public:
22
23        FFmpegImageStream();
24        FFmpegImageStream(const FFmpegImageStream & image, const osg::CopyOp & copyop = osg::CopyOp::SHALLOW_COPY);
25
26        META_Object(osgFFmpeg, FFmpegImageStream);
27
28        bool open(const std::string & filename);
29
30        virtual void play();
31        virtual void pause();
32        virtual void rewind();
[10809]33        virtual void seek(double time);
[9816]34        virtual void quit(bool waitForThreadToExit = true);
35
[9910]36        virtual double getLength() const;
[10851]37        virtual double getReferenceTime () const;
[9910]38        virtual double getFrameRate() const;
[9816]39
[9910]40        virtual bool isImageTranslucent() const;
[9816]41
42    private:
43
44        enum Command
45        {
46            CMD_PLAY,
47            CMD_PAUSE,
48            CMD_STOP,
[10809]49            CMD_REWIND,
50            CMD_SEEK
[9816]51        };
52
53        typedef MessageQueue<Command> CommandQueue;
54        typedef OpenThreads::Mutex Mutex;
55        typedef OpenThreads::Condition Condition;
56
57        virtual ~FFmpegImageStream();
58        virtual void run();
59        virtual void applyLoopingMode();
60
61        bool handleCommand(Command cmd);
62
63        void cmdPlay();
64        void cmdPause();
65        void cmdRewind();
[10809]66        void cmdSeek(double time);
[9816]67
68        static void publishNewFrame(const FFmpegDecoderVideo &, void * user_data);
69
[9847]70        osg::ref_ptr<FFmpegDecoder>    m_decoder;
[9816]71        CommandQueue *    m_commands;
72
73        Mutex            m_mutex;
74        Condition        m_frame_published_cond;
[10851]75        bool             m_frame_published_flag;
[10809]76        double           m_seek_time;
[9816]77    };
78
79}
80
81
82
83#endif // HEADER_GUARD_OSGFFMPEG_FFMPEG_IMAGE_STREAM_H
Note: See TracBrowser for help on using the browser.