ClipWorkflow.h 3.87 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/*****************************************************************************
 * ClipWorkflow.h : Clip workflow. Will extract a single frame from a VLCMedia
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef CLIPWORKFLOW_H
#define CLIPWORKFLOW_H

//TODO: THIS HAS TO GO REALLY REALLY REALLY SOON !!!!
//FIXME:
//UGLY:
#define VIDEOWIDTH 640
#define VIDEOHEIGHT 480

#include <QReadWriteLock>
#include <QMutex>
#include <QWaitCondition>
#include <QObject>

#include "Clip.h"
#include "VLCMediaPlayer.h"

class   ClipWorkflow : public QObject
{
    Q_OBJECT

    public:
        ClipWorkflow( Clip* clip, QMutex* condMutex, QWaitCondition* waitCond );
        virtual ~ClipWorkflow();

48 49 50 51 52
        /**
         *  Will return true if the render is completed or the end of the clip has been
         *  reached.
         *  If the workflow is still rendering, this will return false.
         */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
53
        bool                    renderComplete() const;
54
        unsigned char*          getOutput();
55
        void                    initialize( LibVLCpp::MediaPlayer* mediaPlayer );
56 57
        bool                    isReady() const;
        bool                    isEndReached() const;
58
        void                    startRender();
59 60 61 62 63 64
        /**
            \brief              Returns the Clip this workflow instance is based
                                uppon, so that you can query information on it.
            \return             A pointer to a constant clip instance.
        */
        const Clip*             getClip() const;
65 66 67 68 69
        /**
            \brief  Stop this workflow.
        */
        void                    stop();
        void                    setPosition( float pos );
70 71 72 73
        /**
         *  \return true if the workflow has already been stopped.
         */
        bool                    isStopped() const;
74

75 76
        void                    scheduleStop();

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
77 78 79
    private:
        static void             lock( ClipWorkflow* clipWorkflow, void** pp_ret );
        static void             unlock( ClipWorkflow* clipWorkflow );
80
        void                    setVmem();
81
        void                    reinitFlags();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
82 83 84

    private:
        Clip*                   m_clip;
85
        QReadWriteLock*         m_renderCompleteMutex;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
86 87
        bool                    m_renderComplete;
        unsigned char*          m_buffer;
88

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
89 90
        QMutex*                 m_condMutex;
        QWaitCondition*         m_waitCond;
91

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
92
        LibVLCpp::MediaPlayer*  m_mediaPlayer;
93

94 95
        QReadWriteLock*         m_initMutex;
        bool                    m_isReady;
96
        QReadWriteLock*         m_endReachedLock;
97 98 99
        bool                    m_endReached;
        QReadWriteLock*         m_stopScheduledMutex;
        bool                    m_stopScheduled;
100 101

    public slots:
102 103
        void                    pauseAfterPlaybackStarted();
        void                    pausedMediaPlayer();
104
        void                    setPositionAfterPlayback();
105
        void                    endReached();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
106 107 108
};

#endif // CLIPWORKFLOW_H