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

Revision 10809, 1.9 kB (checked in by robert, 4 years ago)

From Rafa Gaitan, "Current ffmpeg plugin didn't support pause and seek, I have added this
functionality and I also modified osgmovie example to support "seek"."

Note from Robert Osfield, changes osgmovie to use '>' for the seek as '+' was already used in a separate submission that had been merged.

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;
37        virtual double getFrameRate() const;
[9816]38
[9910]39        virtual bool isImageTranslucent() const;
[9816]40
41    private:
42
43        enum Command
44        {
45            CMD_PLAY,
46            CMD_PAUSE,
47            CMD_STOP,
[10809]48            CMD_REWIND,
49            CMD_SEEK
[9816]50        };
51
52        typedef MessageQueue<Command> CommandQueue;
53        typedef OpenThreads::Mutex Mutex;
54        typedef OpenThreads::Condition Condition;
55
56        virtual ~FFmpegImageStream();
57        virtual void run();
58        virtual void applyLoopingMode();
59
60        bool handleCommand(Command cmd);
61
62        void cmdPlay();
63        void cmdPause();
64        void cmdRewind();
[10809]65        void cmdSeek(double time);
[9816]66
67        static void publishNewFrame(const FFmpegDecoderVideo &, void * user_data);
68
[9847]69        osg::ref_ptr<FFmpegDecoder>    m_decoder;
[9816]70        CommandQueue *    m_commands;
71
72        Mutex            m_mutex;
73        Condition        m_frame_published_cond;
74        bool            m_frame_published_flag;
[10809]75        double           m_seek_time;
[9816]76    };
77
78}
79
80
81
82#endif // HEADER_GUARD_OSGFFMPEG_FFMPEG_IMAGE_STREAM_H
Note: See TracBrowser for help on using the browser.