]> git.sesse.net Git - vlc/blob - bindings/phonon/vlc/mediaobject.h
Add some locking.
[vlc] / bindings / phonon / vlc / mediaobject.h
1 /*****************************************************************************
2  * VLC backend for the Phonon library                                        *
3  * Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com>               *
4  * Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com>                *
5  * Copyright (C) 2009 Fathi Boudra <fabo@kde.org>                            *
6  *                                                                           *
7  * This program is free software; you can redistribute it and/or             *
8  * modify it under the terms of the GNU Lesser General Public                *
9  * License as published by the Free Software Foundation; either              *
10  * version 3 of the License, or (at your option) any later version.          *
11  *                                                                           *
12  * This program is distributed in the hope that it will be useful,           *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
15  * Lesser General Public License for more details.                           *
16  *                                                                           *
17  * You should have received a copy of the GNU Lesser General Public          *
18  * License along with this package; if not, write to the Free Software       *
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA *
20  *****************************************************************************/
21
22 #ifndef PHONON_VLC_MEDIAOBJECT_H
23 #define PHONON_VLC_MEDIAOBJECT_H
24
25 #include <phonon/mediaobjectinterface.h>
26
27 #include <QtCore/QObject>
28 #include <QtGui/QWidget>
29
30 namespace Phonon
31 {
32 namespace VLC {
33
34 class SeekStack;
35
36 class MediaObject : public QObject, public MediaObjectInterface
37 {
38     Q_OBJECT
39     friend class SeekStack;
40
41 public:
42
43     MediaObject(QObject *p_parent);
44     virtual ~MediaObject();
45
46     /**
47      * Widget Id where VLC will show the videos.
48      */
49     void setVideoWidgetId(WId i_widget_id);
50
51     void play();
52     void seek(qint64 milliseconds);
53
54     qint32 tickInterval() const;
55     void setTickInterval(qint32 tickInterval);
56
57     qint64 currentTime() const;
58     Phonon::State state() const;
59     Phonon::ErrorType errorType() const;
60     MediaSource source() const;
61     void setSource(const MediaSource & source);
62     void setNextSource(const MediaSource & source);
63
64     qint32 prefinishMark() const;
65     void setPrefinishMark(qint32 msecToEnd);
66
67     qint32 transitionTime() const;
68     void setTransitionTime(qint32);
69
70 signals:
71
72     void aboutToFinish();
73     void bufferStatus( int i_percent_filled );
74     void currentSourceChanged( const MediaSource & newSource );
75     void finished();
76     void hasVideoChanged(bool b_has_video);
77     void metaDataChanged(const QMultiMap<QString, QString> & metaData);
78     void prefinishMarkReached(qint32 msecToEnd);
79     void seekableChanged(bool b_is_seekable);
80     void stateChanged(Phonon::State newState, Phonon::State oldState);
81     void tick(qint64 time);
82     void totalTimeChanged(qint64 newTotalTime);
83
84     // Signal from VLCMediaObject
85     void stateChanged(Phonon::State newState);
86
87     void tickInternal(qint64 time);
88
89 protected:
90
91     virtual void loadMediaInternal(const QString & filename) = 0;
92     virtual void playInternal() = 0;
93     virtual void seekInternal(qint64 milliseconds) = 0;
94
95     virtual qint64 currentTimeInternal() const = 0;
96
97     WId i_video_widget_id;
98
99 private slots:
100
101     void stateChangedInternal(Phonon::State newState);
102
103     void tickInternalSlot(qint64 time);
104
105 private:
106
107     void loadMedia(const QString & filename);
108
109     void resume();
110
111     MediaSource mediaSource;
112
113     Phonon::State currentState;
114
115     qint32 i_prefinish_mark;
116     bool b_prefinish_mark_reached_emitted;
117
118     bool b_about_to_finish_emitted;
119
120     qint32 i_tick_interval;
121     qint32 i_transition_time;
122 };
123
124 }
125 } // Namespace Phonon::VLC
126
127 #endif // PHONON_VLC_MEDIAOBJECT_H