"Fossies" - the Fresh Open Source Software Archive

Member "kaffeine-2.0.18/src/abstractmediawidget.h" (14 May 2019, 6031 Bytes) of package /linux/misc/kaffeine-2.0.18.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "abstractmediawidget.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.0.14_vs_2.0.15.

    1 /*
    2  * abstractmediawidget.h
    3  *
    4  * Copyright (C) 2010-2012 Christoph Pfister <christophpfister@gmail.com>
    5  *
    6  * This program is free software; you can redistribute it and/or modify
    7  * it under the terms of the GNU General Public License as published by
    8  * the Free Software Foundation; either version 2 of the License, or
    9  * (at your option) any later version.
   10  *
   11  * This program is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License along
   17  * with this program; if not, write to the Free Software Foundation, Inc.,
   18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   19  */
   20 
   21 #ifndef ABSTRACTMEDIAWIDGET_H
   22 #define ABSTRACTMEDIAWIDGET_H
   23 
   24 #include <QMap>
   25 #include "mediawidget.h"
   26 
   27 class AbstractMediaWidget : public QWidget
   28 {
   29 public:
   30     explicit AbstractMediaWidget(QWidget *parent);
   31     virtual ~AbstractMediaWidget() {};
   32 
   33     void connectToMediaWidget(MediaWidget *mediaWidget_);
   34 
   35     // zero-based numbering is used everywhere (e.g. first audio channel = 0)
   36 
   37     MediaWidget::PlaybackStatus getPlaybackStatus() const { return playbackStatus; }
   38     int getCurrentTime() const { return currentTime; } // milliseconds
   39     int getTotalTime() const { return totalTime; } // milliseconds
   40     bool isSeekable() const { return seekable; }
   41     QMap<MediaWidget::MetadataType, QString> getMetadata() const { return metadata; }
   42     QStringList getAudioStreams() const { return audioStreams; }
   43     int getCurrentAudioStream() const { return currentAudioStream; }
   44     QStringList getSubtitles() const { return subtitles; }
   45     int getCurrentSubtitle() const { return currentSubtitle; }
   46     int getTitleCount() const { return titleCount; }
   47     int getCurrentTitle() const { return currentTitle; }
   48     int getChapterCount() const { return chapterCount; }
   49     int getCurrentChapter() const { return currentChapter; }
   50     int getAngleCount() const { return angleCount; }
   51     int getCurrentAngle() const { return currentAngle; }
   52     bool hasDvdMenu() const { return dvdMenu; }
   53     QSize getVideoSize() const { return videoSize; }
   54 
   55     virtual QStringList getAudioDevices() = 0;
   56     virtual void setAudioDevice(QString device) = 0;
   57     virtual void setMuted(bool muted) = 0;
   58     virtual void setVolume(int volume) = 0; // [0 - 200]
   59     virtual void setAspectRatio(MediaWidget::AspectRatio aspectRatio) = 0;
   60     virtual void resizeToVideo(float scale) = 0;
   61     virtual void setDeinterlacing(MediaWidget::DeinterlaceMode) = 0;
   62     virtual void play(const MediaSource &source) = 0;
   63     virtual void stop() = 0;
   64     virtual void setPaused(bool paused) = 0;
   65     virtual void seek(int time) = 0; // milliseconds
   66     virtual void setCurrentAudioStream(int currentAudioStream) = 0;
   67     virtual void setCurrentSubtitle(int currentSubtitle) = 0;
   68     virtual void setExternalSubtitle(const QUrl &subtitleUrl) = 0;
   69     virtual void setCurrentTitle(int currentTitle) = 0;
   70     virtual void setCurrentChapter(int currentChapter) = 0;
   71     virtual void setCurrentAngle(int currentAngle) = 0;
   72     virtual bool jumpToPreviousChapter() = 0;
   73     virtual bool jumpToNextChapter() = 0;
   74     virtual void showDvdMenu() = 0;
   75     virtual void dvdNavigate(int key) = 0;
   76 
   77     enum PendingUpdate
   78     {
   79         PlaybackFinished = (1 << 0),
   80         PlaybackStatus = (1 << 1),
   81         CurrentTotalTime = (1 << 2),
   82         Seekable = (1 << 3),
   83         Metadata = (1 << 4),
   84         AudioStreams = (1 << 5),
   85         Subtitles = (1 << 6),
   86         Titles = (1 << 7),
   87         Chapters = (1 << 8),
   88         Angles = (1 << 9),
   89         DvdMenu = (1 << 10),
   90         VideoSize = (1 << 11)
   91     };
   92 
   93     Q_DECLARE_FLAGS(PendingUpdates, PendingUpdate)
   94 
   95 protected:
   96     void addPendingUpdates(PendingUpdates pendingUpdatesToBeAdded); // thread-safe
   97 
   98     virtual int updatePlaybackStatus() = 0;
   99     virtual void updateCurrentTotalTime() = 0;
  100     virtual void updateSeekable() = 0;
  101     virtual void updateMetadata() = 0;
  102     virtual void updateAudioStreams() = 0;
  103     virtual void updateSubtitles() = 0;
  104     virtual void updateTitles() = 0;
  105     virtual void updateChapters() = 0;
  106     virtual void updateAngles() = 0;
  107     virtual void updateDvdMenu() = 0;
  108     virtual void updateVideoSize() = 0;
  109 
  110     MediaWidget::PlaybackStatus playbackStatus;
  111     int currentTime;
  112     int totalTime;
  113     bool seekable;
  114     QMap<MediaWidget::MetadataType, QString> metadata;
  115     QStringList audioStreams;
  116     int currentAudioStream;
  117     QStringList subtitles;
  118     int currentSubtitle;
  119     int titleCount;
  120     int currentTitle;
  121     int chapterCount;
  122     int currentChapter;
  123     int angleCount;
  124     int currentAngle;
  125     bool dvdMenu;
  126     QSize videoSize;
  127 
  128 private:
  129     void customEvent(QEvent *event);
  130 
  131     MediaWidget *mediaWidget;
  132     QAtomicInt pendingUpdates;
  133 };
  134 
  135 Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMediaWidget::PendingUpdates)
  136 
  137 class DummyMediaWidget : public AbstractMediaWidget
  138 {
  139 public:
  140     explicit DummyMediaWidget(QWidget *parent): AbstractMediaWidget(parent) {};
  141     ~DummyMediaWidget() {};
  142 
  143     QStringList getAudioDevices() { QStringList empty; return empty; };
  144     void setAudioDevice(QString) {};
  145     void setMuted(bool) {};
  146     void setVolume(int) {}; // [0 - 200]
  147     void setAspectRatio(MediaWidget::AspectRatio) {};
  148     void resizeToVideo(float) {};
  149     void setDeinterlacing(MediaWidget::DeinterlaceMode) {};
  150     void play(const MediaSource &) {};
  151     void stop() {};
  152     void setPaused(bool) {};
  153     void seek(int) {}; // milliseconds
  154     void setCurrentAudioStream(int) {};
  155     void setCurrentSubtitle(int) {};
  156     void setExternalSubtitle(const QUrl &) {};
  157     void setCurrentTitle(int) {};
  158     void setCurrentChapter(int) {};
  159     void setCurrentAngle(int) {};
  160     bool jumpToPreviousChapter() { return false; };
  161     bool jumpToNextChapter() { return false; }
  162     void showDvdMenu() {};
  163     void dvdNavigate(int) {};
  164 
  165     int updatePlaybackStatus() { return true; };
  166     void updateCurrentTotalTime() {};
  167     void updateSeekable() {};
  168     void updateMetadata() {};
  169     void updateAudioDevices() {};
  170     void updateAudioStreams() {};
  171     void updateSubtitles() {};
  172     void updateTitles() {};
  173     void updateChapters() {};
  174     void updateAngles() {};
  175     void updateDvdMenu() {};
  176     void updateVideoSize() {};
  177 };
  178 
  179 #endif /* ABSTRACTMEDIAWIDGET_H */