File indexing completed on 2025-01-19 03:57:03
0001 /********************************************************* 0002 * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> * 0003 * * 0004 * This file is part of QtAVPlayer. * 0005 * Free Qt Media Player based on FFmpeg. * 0006 *********************************************************/ 0007 0008 #ifndef QAVDEMUXER_H 0009 #define QAVDEMUXER_H 0010 0011 // 0012 // W A R N I N G 0013 // ------------- 0014 // 0015 // This file is not part of the Qt API. It exists purely as an 0016 // implementation detail. This header file may change from version to 0017 // version without notice, or even be removed. 0018 // 0019 // We mean it. 0020 // 0021 0022 #include "qavpacket_p.h" 0023 #include "qavstream.h" 0024 #include "qavframe.h" 0025 #include "qavsubtitleframe.h" 0026 #include <QMap> 0027 #include <memory> 0028 0029 QT_BEGIN_NAMESPACE 0030 0031 extern "C" { 0032 #include <libavutil/avutil.h> 0033 } 0034 0035 class QAVDemuxerPrivate; 0036 class QAVVideoCodec; 0037 class QAVAudioCodec; 0038 class QAVIODevice; 0039 struct AVStream; 0040 struct AVCodecContext; 0041 struct AVFormatContext; 0042 class QAVDemuxer 0043 { 0044 public: 0045 QAVDemuxer(); 0046 ~QAVDemuxer(); 0047 0048 void abort(bool stop = true); 0049 int load(const QString &url, QAVIODevice *dev = nullptr); 0050 void unload(); 0051 0052 AVMediaType currentCodecType(int index) const; 0053 0054 QList<QAVStream> availableVideoStreams() const; 0055 QList<QAVStream> currentVideoStreams() const; 0056 bool setVideoStreams(const QList<QAVStream> &streams); 0057 0058 QList<QAVStream> availableAudioStreams() const; 0059 QList<QAVStream> currentAudioStreams() const; 0060 bool setAudioStreams(const QList<QAVStream> &streams); 0061 0062 QList<QAVStream> availableSubtitleStreams() const; 0063 QList<QAVStream> currentSubtitleStreams() const; 0064 bool setSubtitleStreams(const QList<QAVStream> &streams); 0065 0066 QAVPacket read(); 0067 0068 void decode(const QAVPacket &pkt, QList<QAVFrame> &frames) const; 0069 void decode(const QAVPacket &pkt, QList<QAVSubtitleFrame> &frames) const; 0070 void flushCodecBuffers(); 0071 0072 double duration() const; 0073 bool seekable() const; 0074 int seek(double sec); 0075 bool eof() const; 0076 double videoFrameRate() const; 0077 0078 QMap<QString, QString> metadata() const; 0079 0080 QString bitstreamFilter() const; 0081 int applyBitstreamFilter(const QString &bsfs); 0082 0083 QString inputFormat() const; 0084 void setInputFormat(const QString &format); 0085 0086 QString inputVideoCodec() const; 0087 void setInputVideoCodec(const QString &codec); 0088 0089 QMap<QString, QString> inputOptions() const; 0090 void setInputOptions(const QMap<QString, QString> &opts); 0091 0092 void onFrameSent(const QAVStreamFrame &frame); 0093 QAVStream::Progress progress(const QAVStream &s) const; 0094 0095 bool isMasterStream(const QAVStream &stream) const; 0096 0097 static QStringList supportedFormats(); 0098 static QStringList supportedVideoCodecs(); 0099 static QStringList supportedProtocols(); 0100 static QStringList supportedBitstreamFilters(); 0101 0102 protected: 0103 std::unique_ptr<QAVDemuxerPrivate> d_ptr; 0104 0105 private: 0106 int resetCodecs(); 0107 0108 Q_DISABLE_COPY(QAVDemuxer) 0109 Q_DECLARE_PRIVATE(QAVDemuxer) 0110 }; 0111 0112 QT_END_NAMESPACE 0113 0114 #endif