]> git.sesse.net Git - vlc/blob - bindings/phonon/vlc/vlcmediaobject.h
Phonon Backend using VLC
[vlc] / bindings / phonon / vlc / vlcmediaobject.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_VLCMEDIAOBJECT_H
23 #define PHONON_VLC_VLCMEDIAOBJECT_H
24
25 #include "vlcmediacontroller.h"
26
27 #include "mediaobject.h"
28
29 #include <phonon/mediaobjectinterface.h>
30 #include <phonon/addoninterface.h>
31
32 #include <QtCore/QObject>
33 #include <QtCore/QString>
34 #include <QtCore/QMultiMap>
35
36 namespace Phonon
37 {
38 namespace VLC {
39
40 /**
41  * VLC MediaObject.
42  *
43  * This is the "brain" of the VLC backend.
44  * VLCMediaObject uses libvlc in order to send commands and receive events from the VLC.
45  *
46  * Encapsulates VLC specific code.
47  * Take care of libvlc events via libvlc_callback()
48  *
49  * @see MediaObject
50  */
51 class VLCMediaObject : public MediaObject, public VLCMediaController
52 {
53     Q_OBJECT
54     Q_INTERFACES(Phonon::MediaObjectInterface  Phonon::AddonInterface)
55
56 public:
57
58     VLCMediaObject(QObject * parent);
59     ~VLCMediaObject();
60
61     void pause();
62     void stop();
63
64     bool hasVideo() const;
65     bool isSeekable() const;
66
67     qint64 totalTime() const;
68
69     QString errorString() const;
70
71 signals:
72
73     // MediaController signals
74     void availableSubtitlesChanged();
75     void availableAudioChannelsChanged();
76
77 //    void availableChaptersChanged();
78 //    void availableTitlesChanged();
79     void availableChaptersChanged(int);
80     void availableTitlesChanged(int);
81
82     void availableAnglesChanged(int availableAngles);
83     void angleChanged(int angleNumber);
84     void chapterChanged(int chapterNumber);
85     void titleChanged(int titleNumber);
86
87     /**
88      * New widget size computed by VLC.
89      *
90      * It should be applied to the widget that contains the VLC video.
91      */
92     void videoWidgetSizeChanged(int i_width, int i_height);
93
94 protected:
95
96     void loadMediaInternal(const QString & filename);
97     void playInternal();
98     void seekInternal(qint64 milliseconds);
99
100     qint64 currentTimeInternal() const;
101
102 private slots:
103
104     void loadMediaInternal();
105
106 private:
107
108     /**
109      * Connect libvlc_callback() to all vlc events.
110      *
111      * @see libvlc_callback()
112      */
113     void connectToAllVLCEvents();
114
115     /**
116      * Retrieve meta data of a file (i.e ARTIST, TITLE, ALBUM, etc...).
117      */
118     void updateMetaData();
119
120     /**
121      * Libvlc callback.
122      *
123      * Receive all vlc events.
124      *
125      * Warning: owned by libvlc thread.
126      *
127      * @see connectToAllVLCEvents()
128      * @see libvlc_event_attach()
129      */
130     static void libvlc_callback(const libvlc_event_t *p_event, void *p_user_data);
131
132     void unloadMedia();
133
134     void setVLCWidgetId();
135
136     // MediaPlayer
137 //    libvlc_media_player_t * p_vlc_media_player;
138     libvlc_event_manager_t * p_vlc_media_player_event_manager;
139
140     // Media
141     libvlc_media_t * p_vlc_media;
142     libvlc_event_manager_t * p_vlc_media_event_manager;
143
144     // MediaDiscoverer
145     libvlc_media_discoverer_t * p_vlc_media_discoverer;
146     libvlc_event_manager_t * p_vlc_media_discoverer_event_manager;
147
148     bool b_play_request_reached;
149
150     qint64 i_total_time;
151
152     bool b_has_video;
153
154     bool b_seekable;
155 };
156
157 }
158 } // Namespace Phonon::VLC
159
160 #endif