denisq

Untitled

Aug 3rd, 2014
223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 "mediawidget.h"
  25.  
  26. class AbstractMediaWidget : public QWidget
  27. {
  28. public:
  29.     explicit AbstractMediaWidget(QWidget *parent);
  30.     virtual ~AbstractMediaWidget();
  31.  
  32.     void connectToMediaWidget(MediaWidget *mediaWidget_);
  33.  
  34.     // zero-based numbering is used everywhere (e.g. first audio channel = 0)
  35.  
  36.     MediaWidget::PlaybackStatus getPlaybackStatus() const { return playbackStatus; }
  37.     int getCurrentTime() const { return currentTime; } // milliseconds
  38.     int getTotalTime() const { return totalTime; } // milliseconds
  39.     bool isSeekable() const { return seekable; }
  40.     QMap<MediaWidget::MetadataType, QString> getMetadata() const { return metadata; }
  41.     QStringList getAudioStreams() const { return audioStreams; }
  42.     int getCurrentAudioStream() const { return currentAudioStream; }
  43.     QStringList getSubtitles() const { return subtitles; }
  44.     int getCurrentSubtitle() const { return currentSubtitle; }
  45.     int getTitleCount() const { return titleCount; }
  46.     int getCurrentTitle() const { return currentTitle; }
  47.     int getChapterCount() const { return chapterCount; }
  48.     int getCurrentChapter() const { return currentChapter; }
  49.     int getAngleCount() const { return angleCount; }
  50.     int getCurrentAngle() const { return currentAngle; }
  51.     bool hasDvdMenu() const { return dvdMenu; }
  52.     QSize getVideoSize() const { return videoSize; }
  53.  
  54.     virtual void setMuted(bool muted) = 0;
  55.     virtual void setVolume(int volume) = 0; // [0 - 200]
  56.     virtual void setAspectRatio(MediaWidget::AspectRatio aspectRatio) = 0;
  57.     virtual void setDeinterlacing(bool deinterlacing) = 0;
  58.     virtual void play(const MediaSource &source) = 0;
  59.     virtual void stop() = 0;
  60.     virtual void setPaused(bool paused) = 0;
  61.     virtual void seek(int time) = 0; // milliseconds
  62.     virtual void setCurrentAudioStream(int currentAudioStream) = 0;
  63.     virtual void setCurrentSubtitle(int currentSubtitle) = 0;
  64.     virtual void setExternalSubtitle(const QUrl &subtitleUrl) = 0;
  65.     virtual void setCurrentTitle(int currentTitle) = 0;
  66.     virtual void setCurrentChapter(int currentChapter) = 0;
  67.     virtual void setCurrentAngle(int currentAngle) = 0;
  68.     virtual bool jumpToPreviousChapter() = 0;
  69.     virtual bool jumpToNextChapter() = 0;
  70.     virtual void showDvdMenu() = 0;
  71.  
  72.     enum PendingUpdate
  73.     {
  74.         PlaybackFinished = (1 << 0),
  75.         PlaybackStatus = (1 << 1),
  76.         CurrentTotalTime = (1 << 2),
  77.         Seekable = (1 << 3),
  78.         Metadata = (1 << 4),
  79.         AudioStreams = (1 << 5),
  80.         Subtitles = (1 << 6),
  81.         Titles = (1 << 7),
  82.         Chapters = (1 << 8),
  83.         Angles = (1 << 9),
  84.         DvdMenu = (1 << 10),
  85.         VideoSize = (1 << 11)
  86.     };
  87.  
  88.     Q_DECLARE_FLAGS(PendingUpdates, PendingUpdate)
  89.  
  90. protected:
  91.     void addPendingUpdates(PendingUpdates pendingUpdatesToBeAdded); // thread-safe
  92.  
  93.     virtual void updatePlaybackStatus() = 0;
  94.     virtual void updateCurrentTotalTime() = 0;
  95.     virtual void updateSeekable() = 0;
  96.     virtual void updateMetadata() = 0;
  97.     virtual void updateAudioStreams() = 0;
  98.     virtual void updateSubtitles() = 0;
  99.     virtual void updateTitles() = 0;
  100.     virtual void updateChapters() = 0;
  101.     virtual void updateAngles() = 0;
  102.     virtual void updateDvdMenu() = 0;
  103.     virtual void updateVideoSize() = 0;
  104.  
  105.     MediaWidget::PlaybackStatus playbackStatus;
  106.     int currentTime;
  107.     int totalTime;
  108.     bool seekable;
  109.     QMap<MediaWidget::MetadataType, QString> metadata;
  110.     QStringList audioStreams;
  111.     int currentAudioStream;
  112.     QStringList subtitles;
  113.     int currentSubtitle;
  114.     int titleCount;
  115.     int currentTitle;
  116.     int chapterCount;
  117.     int currentChapter;
  118.     int angleCount;
  119.     int currentAngle;
  120.     bool dvdMenu;
  121.     QSize videoSize;
  122.  
  123. private:
  124.     void customEvent(QEvent *event);
  125.  
  126.     MediaWidget *mediaWidget;
  127.     QAtomicInt pendingUpdates;
  128. };
  129.  
  130. Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMediaWidget::PendingUpdates)
  131.  
  132. class DummyMediaWidget : public AbstractMediaWidget
  133. {
  134. public:
  135.     explicit DummyMediaWidget(QWidget *parent);
  136.     ~DummyMediaWidget();
  137.  
  138.     void setMuted(bool muted);
  139.     void setVolume(int volume); // [0 - 200]
  140.     void setAspectRatio(MediaWidget::AspectRatio aspectRatio);
  141.     void setDeinterlacing(bool deinterlacing);
  142.     void play(const MediaSource &source);
  143.     void stop();
  144.     void setPaused(bool paused);
  145.     void seek(int time); // milliseconds
  146.     void setCurrentAudioStream(int currentAudioStream);
  147.     void setCurrentSubtitle(int currentSubtitle);
  148.     void setExternalSubtitle(const QUrl &subtitleUrl);
  149.     void setCurrentTitle(int currentTitle);
  150.     void setCurrentChapter(int currentChapter);
  151.     void setCurrentAngle(int currentAngle);
  152.     bool jumpToPreviousChapter();
  153.     bool jumpToNextChapter();
  154.     void showDvdMenu();
  155.  
  156.     void updatePlaybackStatus();
  157.     void updateCurrentTotalTime();
  158.     void updateSeekable();
  159.     void updateMetadata();
  160.     void updateAudioStreams();
  161.     void updateSubtitles();
  162.     void updateTitles();
  163.     void updateChapters();
  164.     void updateAngles();
  165.     void updateDvdMenu();
  166.     void updateVideoSize();
  167. };
  168.  
  169. #endif /* ABSTRACTMEDIAWIDGET_H */
RAW Paste Data