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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
/**
* Copyright (C) 2002-2003 by Koos Vriezen <koos.vriezen@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef KMPLAYERPARTBASE_H
#define KMPLAYERPARTBASE_H
#include <config.h>
#include "kmplayer_def.h"
#include <qobject.h>
#include <qguardedptr.h>
#include <qstringlist.h>
#include <qmap.h>
#include <dcopobject.h>
#include <kmediaplayer/player.h>
#include <kurl.h>
#include "kmplayerview.h"
#include "kmplayersource.h"
class KAboutData;
class KInstance;
class KActionCollection;
class KBookmarkMenu;
class KConfig;
class QIODevice;
class QTextStream;
class QListViewItem;
namespace KIO {
class Job;
}
namespace KMPlayer {
class PartBase;
class Process;
class MPlayer;
class BookmarkOwner;
class BookmarkManager;
class MEncoder;
class MPlayerDumpstream;
class FFMpeg;
class Xine;
class Settings;
/*
* Source from URLs
*/
class KMPLAYER_EXPORT URLSource : public Source {
Q_OBJECT
public:
URLSource (PartBase * player, const KURL & url = KURL ());
virtual ~URLSource ();
virtual void dimensions (int & w, int & h);
virtual bool hasLength ();
virtual QString prettyName ();
virtual void reset ();
virtual void setURL (const KURL & url);
public slots:
virtual void init ();
virtual void activate ();
virtual void deactivate ();
virtual void playCurrent ();
virtual void forward ();
virtual void backward ();
virtual void jump (NodePtr e);
void play ();
private slots:
void kioData (KIO::Job *, const QByteArray &);
void kioMimetype (KIO::Job *, const QString &);
void kioResult (KIO::Job *);
protected:
virtual bool requestPlayURL (NodePtr mrl);
virtual bool resolveURL (NodePtr mrl);
private:
void read (NodePtr mrl, QTextStream &);
void stopResolving ();
struct ResolveInfo {
ResolveInfo (NodePtr mrl, KIO::Job * j, SharedPtr <ResolveInfo> & n)
: resolving_mrl (mrl), job (j), progress (0), next (n) {}
NodePtrW resolving_mrl;
KIO::Job * job;
QByteArray data;
int progress;
SharedPtr <ResolveInfo> next;
};
SharedPtr <ResolveInfo> m_resolve_info;
bool activated; // 'solve' an singleShot race w/ cmdline url's
};
/*
* KDE's KMediaPlayer::Player implementation and base for KMPlayerPart
*/
class KMPLAYER_EXPORT PartBase : public KMediaPlayer::Player {
Q_OBJECT
K_DCOP
public:
typedef QMap <QString, Process *> ProcessMap;
PartBase (QWidget * parent, const char * wname,QObject * objectParent, const char * name, KConfig *);
~PartBase ();
void init (KActionCollection * = 0L);
virtual KMediaPlayer::View* view ();
static KAboutData* createAboutData ();
Settings * settings () const { return m_settings; }
void keepMovieAspect (bool);
KURL url () const { return m_sources ["urlsource"]->url (); }
void setURL (const KURL & url) { m_sources ["urlsource"]->setURL (url); }
/* Changes the backend process */
void setProcess (const char *);
bool setProcess (Mrl *mrl);
void setRecorder (const char *);
/* Changes the source,
* calls init() and reschedules an activate() on the source
* */
void setSource (Source * source);
void connectPanel (ControlPanel * panel);
void connectPlaylist (PlayListView * playlist);
void connectInfoPanel (InfoWindow * infopanel);
void connectSource (Source * old_source, Source * source);
Process * process () const { return m_process; }
Process * recorder () const { return m_recorder; }
Source * source () const { return m_source; }
QMap <QString, Process *> & players () { return m_players; }
QMap <QString, Process *> & recorders () { return m_recorders; }
QMap <QString, Source *> & sources () { return m_sources; }
KConfig * config () const { return m_config; }
bool mayResize () const { return !m_noresize; }
void updatePlayerMenu (ControlPanel *);
void updateInfo (const QString & msg);
void updateStatus (const QString & msg);
#ifdef HAVE_DBUS
void setServiceName (const QString & srv) { m_service = srv; }
QString serviceName () const { return m_service; }
#endif
// these are called from Process
void changeURL (const QString & url);
void updateTree (bool full=true, bool force=false);
void setLanguages (const QStringList & alang, const QStringList & slang);
public slots:
virtual bool openURL (const KURL & url);
virtual bool openURL (const KURL::List & urls);
virtual bool closeURL ();
virtual void pause (void);
virtual void play (void);
virtual void stop (void);
void record ();
virtual void seek (unsigned long msec);
void adjustVolume (int incdec);
bool playing () const;
void showConfigDialog ();
void showPlayListWindow ();
void slotPlayerMenu (int);
void back ();
void forward ();
void addBookMark (const QString & title, const QString & url);
void volumeChanged (int);
void increaseVolume ();
void decreaseVolume ();
void setPosition (int position, int length);
virtual void setLoaded (int percentage);
public:
virtual bool isSeekable (void) const;
virtual unsigned long position (void) const;
virtual bool hasLength (void) const;
virtual unsigned long length (void) const;
k_dcop:
void toggleFullScreen ();
bool isPlaying ();
signals:
void sourceChanged (KMPlayer::Source * old, KMPlayer::Source * nw);
void sourceDimensionChanged ();
void loading (int percentage);
void urlAdded (const QString & url);
void urlChanged (const QString & url);
void processChanged (const char *);
void treeChanged (int id, NodePtr root, NodePtr, bool select, bool open);
void treeUpdated ();
void infoUpdated (const QString & msg);
void statusUpdated (const QString & msg);
void languagesUpdated(const QStringList & alang, const QStringList & slang);
void audioIsSelected (int id);
void subtitleIsSelected (int id);
void positioned (int pos, int length);
protected:
bool openFile();
virtual void timerEvent (QTimerEvent *);
protected slots:
void posSliderPressed ();
void posSliderReleased ();
void positionValueChanged (int val);
void contrastValueChanged (int val);
void brightnessValueChanged (int val);
void hueValueChanged (int val);
void saturationValueChanged (int val);
void sourceHasChangedAspects ();
void fullScreen ();
void playListItemClicked (QListViewItem *);
void playListItemExecuted (QListViewItem *);
virtual void playingStarted ();
virtual void playingStopped ();
void recordingStarted ();
void recordingStopped ();
void settingsChanged ();
void audioSelected (int);
void subtitleSelected (int);
protected:
KConfig * m_config;
QGuardedPtr <View> m_view;
QMap <QString, QString> temp_backends;
Settings * m_settings;
Process * m_process;
Process * m_recorder;
Source * m_source;
ProcessMap m_players;
ProcessMap m_recorders;
QMap <QString, Source *> m_sources;
BookmarkManager * m_bookmark_manager;
BookmarkOwner * m_bookmark_owner;
KBookmarkMenu * m_bookmark_menu;
#ifdef HAVE_DBUS
QString m_service;
#endif
int m_record_timer;
int m_update_tree_timer;
bool m_noresize : 1;
bool m_auto_controls : 1;
bool m_use_slave : 1;
bool m_bPosSliderPressed : 1;
bool m_in_update_tree : 1;
bool m_update_tree_full : 1;
};
class KMPLAYER_NO_EXPORT DataCache : public QObject {
Q_OBJECT
typedef QMap <QString, QByteArray> DataMap;
typedef QMap <QString, bool> PreserveMap;
DataMap cache_map;
PreserveMap preserve_map;
public:
DataCache () {}
~DataCache () {}
void add (const QString &, const QByteArray &);
bool get (const QString &, QByteArray &);
bool preserve (const QString &);
bool unpreserve (const QString &);
bool isPreserved (const QString &);
signals:
void preserveRemoved (const QString &); // ready or canceled
};
class KMPLAYER_NO_EXPORT RemoteObjectPrivate : public QObject {
Q_OBJECT
public:
RemoteObjectPrivate (RemoteObject * r);
~RemoteObjectPrivate ();
bool download (const QString &);
void clear ();
KIO::Job * job;
QString url;
QByteArray data;
QString mime;
private slots:
void slotResult (KIO::Job*);
void slotData (KIO::Job*, const QByteArray& qb);
void slotMimetype (KIO::Job * job, const QString & mimestr);
void cachePreserveRemoved (const QString &);
private:
RemoteObject * remote_object;
bool preserve_wait;
};
} // namespace
#endif
|