input_manager.hpp 2.82 KB
Newer Older
zorglub's avatar
zorglub committed
1 2 3
/*****************************************************************************
 * input_manager.hpp : Manage an input and interact with its GUI elements
 ****************************************************************************
4 5
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
zorglub's avatar
zorglub committed
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
 *
 * Authors: Clément Stenac <zorglub@videolan.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 _INPUT_MANAGER_H_
#define _INPUT_MANAGER_H_

#include <QObject>
#include <vlc/vlc.h>

class InputManager : public QObject
{
    Q_OBJECT;
public:
    InputManager( QObject *, intf_thread_t *);
    virtual ~InputManager();

37
    void delInput();
38 39
    bool hasAudio() { return b_has_audio; }
    bool hasVideo() { return b_has_video; }
40
    bool b_has_audio, b_has_video, b_had_audio, b_had_video;
zorglub's avatar
zorglub committed
41 42 43
private:
    intf_thread_t *p_intf;
    input_thread_t *p_input;
44
    int i_old_playing_status;
zorglub's avatar
zorglub committed
45 46

public slots:
47
    void togglePlayPause();
zorglub's avatar
zorglub committed
48
    void update(); ///< Periodic updates
zorglub's avatar
zorglub committed
49
    void setInput( input_thread_t * ); ///< Our controlled input changed
zorglub's avatar
zorglub committed
50 51 52 53
    void sliderUpdate( float ); ///< User dragged the slider. We get new pos
signals:
    /// Send new position, new time and new length
    void positionUpdated( float , int, int );
54 55 56
    void nameChanged( QString );
    void navigationChanged( int );
    void statusChanged( int );
57 58
    void audioStarted();
    void videoStarted();
zorglub's avatar
zorglub committed
59 60
};

61 62 63 64 65 66 67 68 69 70
class MainInputManager : public QObject
{
    Q_OBJECT;
public:
    static MainInputManager *getInstance( intf_thread_t *_p_intf )
    {
        if( !instance )
            instance = new MainInputManager( _p_intf );
        return instance;
    }
zorglub's avatar
zorglub committed
71 72 73 74 75
    static void killInstance()
    {
        if( instance ) delete instance;
    }
    virtual ~MainInputManager();
76 77 78 79 80 81 82 83 84
    input_thread_t *getInput() { return p_input; };
    InputManager *getIM() { return im; };

private:
    InputManager *im;
    intf_thread_t *p_intf;
    input_thread_t *p_input;
    static MainInputManager *instance;
    MainInputManager( intf_thread_t *);
85 86
public slots:
    void togglePlayPause();
87 88 89 90 91 92
private slots:
    void updateInput();
signals:
    void inputChanged( input_thread_t *);
};

zorglub's avatar
zorglub committed
93 94

#endif