File indexing completed on 2024-05-12 04:52:15
0001 /* 0002 * dvbliveview_p.h 0003 * 0004 * Copyright (C) 2007-2011 Christoph Pfister <christophpfister@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation; either version 2 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License along 0017 * with this program; if not, write to the Free Software Foundation, Inc., 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 0019 */ 0020 0021 #ifndef DVBLIVEVIEW_P_H 0022 #define DVBLIVEVIEW_P_H 0023 0024 #include <QFile> 0025 #include "../mediawidget.h" 0026 #include "../osdwidget.h" 0027 #include "dvbepg.h" 0028 #include "dvbsi.h" 0029 #include "dvbmanager.h" 0030 0031 class QSocketNotifier; 0032 0033 class DvbOsd : public OsdObject 0034 { 0035 public: 0036 enum OsdLevel { 0037 Off, 0038 ShortOsd, 0039 LongOsd 0040 }; 0041 0042 DvbOsd() : level(Off) { } 0043 ~DvbOsd() { } 0044 0045 void init(DvbManager *manager_, OsdLevel level_, const QString &channelName_, 0046 const QList<DvbSharedEpgEntry> &epgEntries); 0047 0048 OsdLevel level; 0049 0050 private: 0051 QPixmap paintOsd(QRect &rect, const QFont &font, Qt::LayoutDirection direction) override; 0052 0053 QString channelName; 0054 DvbEpgEntry firstEntry; 0055 DvbEpgEntry secondEntry; 0056 DvbManager *manager; 0057 }; 0058 0059 class DvbLiveViewInternal : public QObject, public DvbPidFilter, public MediaSource 0060 { 0061 Q_OBJECT 0062 public: 0063 explicit DvbLiveViewInternal(QObject *parent); 0064 ~DvbLiveViewInternal(); 0065 0066 void resetPipe(); 0067 0068 bool overrideAudioStreams() const override { return !audioStreams.isEmpty(); } 0069 QStringList getAudioStreams() const override { return audioStreams; } 0070 QStringList getSubtitles() const override { return QStringList(); } 0071 int getCurrentAudioStream() const override { return currentAudioStream; } 0072 int getCurrentSubtitle() const override { return currentSubtitle; } 0073 0074 void setCurrentAudioStream(int currentAudioStream_) override 0075 { 0076 currentAudioStream = currentAudioStream_; 0077 emit currentAudioStreamChanged(currentAudioStream); 0078 } 0079 0080 void setCurrentSubtitle(int currentSubtitle_) override 0081 { 0082 currentSubtitle = currentSubtitle_; 0083 emit currentSubtitleChanged(currentSubtitle); 0084 } 0085 0086 bool overrideCaption() const override { return true; } 0087 0088 QString getDefaultCaption() const override { return channelName; } 0089 0090 Type getType() const override { return Dvb; } 0091 0092 QUrl getUrl() const override { return url; } 0093 0094 void updateUrl() { 0095 if (timeShiftFile.isOpen()) 0096 url = QUrl::fromLocalFile(timeShiftFile.fileName()); 0097 else 0098 url = QUrl::fromLocalFile(fileName); 0099 } 0100 0101 virtual void validateCurrentTotalTime(int ¤tTime, int &totalTime) const override; 0102 bool hideCurrentTotalTime() const override { return !timeshift; } 0103 0104 MediaWidget *mediaWidget; 0105 QString channelName; 0106 DvbPmtFilter pmtFilter; 0107 QByteArray pmtSectionData; 0108 DvbSectionGenerator patGenerator; 0109 DvbSectionGenerator pmtGenerator; 0110 QByteArray buffer; 0111 QFile timeShiftFile; 0112 QString fileName; 0113 DvbOsd dvbOsd; 0114 bool emptyBuffer; 0115 QTime startTime; 0116 bool timeshift; 0117 QStringList audioStreams; 0118 int currentAudioStream; 0119 int currentSubtitle; 0120 int retryCounter; 0121 0122 signals: 0123 void currentAudioStreamChanged(int currentAudioStream); 0124 void currentSubtitleChanged(int currentSubtitle); 0125 void replay() override; 0126 void playbackFinished() override; 0127 void playbackStatusChanged(MediaWidget::PlaybackStatus playbackStatus) override; 0128 void previous() override; 0129 void next() override; 0130 0131 private slots: 0132 void writeToPipe(); 0133 0134 private: 0135 void processData(const char data[188]) override; 0136 0137 QUrl url; 0138 int readFd; 0139 int writeFd; 0140 QSocketNotifier *notifier; 0141 QList<QByteArray> buffers; 0142 }; 0143 0144 #endif /* DVBLIVEVIEW_P_H */