123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- #ifndef CODECS_H
- #define CODECS_H
- #include <QObject>
- #include <QtCore/qglobal.h>
- #include <QList>
- #include <QSize>
- #include <QNetworkAccessManager>
- #include <QNetworkReply>
- #include <QQueue>
- #include <QUrl>
- #include <QVariant>
- #include <QElapsedTimer>
- #include <QSet>
- enum class CodecType {
- Decoder,
- Encoder,
- };
- struct CodecDriver {
- CodecType type;
- QString format;
- QString driver;
- bool present;
- bool external;
-
- QString getMangledName() const;
-
-
- QString getFileName() const;
-
-
- QString getPath() const;
-
-
-
-
- bool isSystemCodec() const;
-
- QString getSystemCodecType() const;
- bool isWhitelistedSystemAudioCodec() const;
- bool isWhitelistedSystemVideoCodec() const;
- bool valid() { return format.size() > 0; }
- };
- struct StreamInfo {
- bool isVideo, isAudio;
- QString codec;
- QString profile;
- int audioChannels;
- int audioSampleRate;
- QSize videoResolution;
- };
- struct PlaybackInfo {
- QList<StreamInfo> streams;
-
- QSet<QString> audioPassthroughCodecs;
- bool enableAC3Transcoding;
- };
- class Downloader : public QObject
- {
- Q_OBJECT
- public:
- typedef QPair<QString, QString> Header;
- typedef QList<Header> HeaderList;
- explicit Downloader(QVariant userData, const QUrl& url, const HeaderList& headers, QObject* parent);
- Q_SIGNALS:
- void done(QVariant userData, bool success, const QByteArray& data);
- private Q_SLOTS:
- void networkFinished(QNetworkReply* pReply);
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- private:
- QNetworkAccessManager m_WebCtrl;
- QByteArray m_DownloadedData;
- QVariant m_userData;
- QElapsedTimer m_currentStartTime;
- int m_lastProgress;
- };
- class CodecsFetcher : public QObject
- {
- Q_OBJECT
- public:
- CodecsFetcher()
- : startCodecs(true), m_eaeNeeded(false), m_fetchEAE(false)
- {
- }
-
-
- void installCodecs(const QList<CodecDriver>& codecs);
-
- QVariant userData;
- bool startCodecs;
- Q_SIGNALS:
- void done(CodecsFetcher* sender);
- private Q_SLOTS:
- void codecInfoDownloadDone(QVariant userData, bool success, const QByteArray& data);
- void codecDownloadDone(QVariant userData, bool success, const QByteArray& data);
- private:
- bool codecNeedsDownload(const CodecDriver& codec);
- bool processCodecInfoReply(const QVariant& context, const QByteArray& data);
- void processCodecDownloadDone(const QVariant& context, const QByteArray& data);
- void startNext();
- void startEAE();
- QQueue<CodecDriver> m_Codecs;
- QByteArray m_currentHash;
- bool m_eaeNeeded;
- bool m_fetchEAE;
- };
- class Codecs
- {
- public:
- static void preinitCodecs();
- static void initCodecs();
- static QString plexNameToFF(QString plex);
- static QString plexNameFromFF(QString ffname);
- static inline bool sameCodec(const CodecDriver& a, const CodecDriver& b)
- {
- return a.type == b.type && a.format == b.format && a.driver == b.driver;
- }
- static void updateCachedCodecList();
- static void Uninit();
- static const QList<CodecDriver>& getCachedCodecList();
- static QList<CodecDriver> findCodecsByFormat(const QList<CodecDriver>& list, CodecType type, const QString& format);
- static QList<CodecDriver> determineRequiredCodecs(const PlaybackInfo& info);
- };
- #endif
|