]> git.sesse.net Git - vlc/blob - bindings/phonon/vlc/mediaobject.h
Phonon Backend using VLC
[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
29 namespace Phonon
30 {
31 namespace VLC {
32
33 class SeekStack;
34
35 class MediaObject : public QObject, public MediaObjectInterface
36 {
37     Q_OBJECT
38     friend class SeekStack;
39
40 public:
41
42     MediaObject(QObject *p_parent);
43     virtual ~MediaObject();
44
45     /**
46      * Widget Id where VLC will show the videos.
47      */
48     void setVideoWidgetId(int i_widget_id);
49
50     void play();
51     void seek(qint64 milliseconds);
52
53     qint32 tickInterval() const;
54     void setTickInterval(qint32 tickInterval);
55
56     qint64 currentTime() const;
57     Phonon::State state() const;
58     Phonon::ErrorType errorType() const;
59     MediaSource source() const;
60     void setSource(const MediaSource & source);
61     void setNextSource(const MediaSource & source);
62
63     qint32 prefinishMark() const;
64     void setPrefinishMark(qint32 msecToEnd);
65
66     qint32 transitionTime() const;
67     void setTransitionTime(qint32);
68
69 signals:
70
71     void aboutToFinish();
72 //    void bufferStatus( int i_percent_filled );
73 //    void currentSourceChanged( const MediaSource & newSource );
74     void finished();
75     void hasVideoChanged(bool b_has_video);
76     void metaDataChanged(const QMultiMap<QString, QString> & metaData);
77     void prefinishMarkReached(qint32 msecToEnd);
78     void seekableChanged(bool b_is_seekable);
79     void stateChanged(Phonon::State newState, Phonon::State oldState);
80     void tick(qint64 time);
81     void totalTimeChanged(qint64 newTotalTime);
82
83     // Signal from VLCMediaObject
84     void stateChanged(Phonon::State newState);
85
86     void tickInternal(qint64 time);
87
88 protected:
89
90     virtual void loadMediaInternal(const QString & filename) = 0;
91     virtual void playInternal() = 0;
92     virtual void seekInternal(qint64 milliseconds) = 0;
93
94     virtual qint64 currentTimeInternal() const = 0;
95
96     int i_video_widget_id;
97
98 private slots:
99
100     void stateChangedInternal(Phonon::State newState);
101
102     void tickInternalSlot(qint64 time);
103
104 private:
105
106     void loadMedia(const QString & filename);
107
108     void resume();
109
110     MediaSource mediaSource;
111
112     Phonon::State currentState;
113
114     qint32 i_prefinish_mark;
115     bool b_prefinish_mark_reached_emitted;
116
117     bool b_about_to_finish_emitted;
118
119     qint32 i_tick_interval;
120     qint32 i_transition_time;
121 };
122
123 }
124 } // Namespace Phonon::VLC
125
126 #endif // PHONON_VLC_MEDIAOBJECT_H