Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
mfstream_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef MFSTREAM_H
5#define MFSTREAM_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <mfapi.h>
19#include <mfidl.h>
20#include <QtCore/qmutex.h>
21#include <QtCore/qiodevice.h>
22#include <QtCore/qcoreevent.h>
23#include <QtCore/qpointer.h>
24
26
27class MFStream : public QObject, public IMFByteStream
28{
29 Q_OBJECT
30public:
31 MFStream(QIODevice *stream, bool ownStream);
32
33 ~MFStream();
34
35 //from IUnknown
36 STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject) override;
37
38 STDMETHODIMP_(ULONG) AddRef(void) override;
39
40 STDMETHODIMP_(ULONG) Release(void) override;
41
42
43 //from IMFByteStream
44 STDMETHODIMP GetCapabilities(DWORD *pdwCapabilities) override;
45
46 STDMETHODIMP GetLength(QWORD *pqwLength) override;
47
48 STDMETHODIMP SetLength(QWORD) override;
49
50 STDMETHODIMP GetCurrentPosition(QWORD *pqwPosition) override;
51
52 STDMETHODIMP SetCurrentPosition(QWORD qwPosition) override;
53
54 STDMETHODIMP IsEndOfStream(BOOL *pfEndOfStream) override;
55
56 STDMETHODIMP Read(BYTE *pb, ULONG cb, ULONG *pcbRead) override;
57
58 STDMETHODIMP BeginRead(BYTE *pb, ULONG cb, IMFAsyncCallback *pCallback,
59 IUnknown *punkState) override;
60
61 STDMETHODIMP EndRead(IMFAsyncResult* pResult, ULONG *pcbRead) override;
62
63 STDMETHODIMP Write(const BYTE *, ULONG, ULONG *) override;
64
65 STDMETHODIMP BeginWrite(const BYTE *, ULONG ,
66 IMFAsyncCallback *,
67 IUnknown *) override;
68
69 STDMETHODIMP EndWrite(IMFAsyncResult *,
70 ULONG *) override;
71
72 STDMETHODIMP Seek(
73 MFBYTESTREAM_SEEK_ORIGIN SeekOrigin,
74 LONGLONG llSeekOffset,
75 DWORD,
76 QWORD *pqwCurrentPosition) override;
77
78 STDMETHODIMP Flush() override;
79
80 STDMETHODIMP Close() override;
81
82private:
83 class AsyncReadState : public IUnknown
84 {
85 public:
86 AsyncReadState(BYTE *pb, ULONG cb);
87 virtual ~AsyncReadState() = default;
88
89 //from IUnknown
90 STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject) override;
91
92 STDMETHODIMP_(ULONG) AddRef(void) override;
93
94 STDMETHODIMP_(ULONG) Release(void) override;
95
96 BYTE* pb() const;
97 ULONG cb() const;
98 ULONG bytesRead() const;
99
100 void setBytesRead(ULONG cbRead);
101
102 private:
103 long m_cRef;
104 BYTE *m_pb;
105 ULONG m_cb;
106 ULONG m_cbRead;
107 };
108
109 long m_cRef;
110 QPointer<QIODevice> m_stream;
111 bool m_ownStream;
112 DWORD m_workQueueId;
113 QMutex m_mutex;
114
115 void doRead();
116
117protected:
118 void customEvent(QEvent *event) override;
119 IMFAsyncResult *m_currentReadResult;
120};
121
122QT_END_NAMESPACE
123
124#endif
qint64 duration() const override
void setAudioFormat(const QAudioFormat &format) override
bool bufferAvailable() const override
QUrl source() const override
void setSourceDevice(QIODevice *device) override
QAudioFormat audioFormat() const override
QAudioBuffer read() override
qint64 position() const override
QIODevice * sourceDevice() const override
bool streamPlaybackSupported() const override
bool isAudioAvailable() const override
void handleError(QMediaPlayer::Error errorCode, const QString &errorString, bool isFatal)
qreal playbackRate() const override
QMediaPlayer::PlaybackState state() const override
QMediaMetaData metaData() const override
const QIODevice * mediaStream() const override
void pause() override
void setActiveTrack(TrackType type, int index) override
void setAudioOutput(QPlatformAudioOutput *output) override
QMediaMetaData trackMetaData(TrackType type, int trackNumber) override
void setPlaybackRate(qreal rate) override
void setMedia(const QUrl &media, QIODevice *stream) override
void play() override
QMediaPlayer::MediaStatus mediaStatus() const override
int activeTrack(TrackType type) override
QUrl media() const override
QMediaTimeRange availablePlaybackRanges() const override
MFPlayerControl(QMediaPlayer *player)
float bufferProgress() const override
void setVideoSink(QVideoSink *sink) override
bool isVideoAvailable() const override
void handleSeekableUpdate(bool seekable)
qint64 duration() const override
qint64 position() const override
void handleDurationUpdate(qint64 duration)
int trackCount(TrackType type) override
void setPosition(qint64 position) override
bool isSeekable() const override
void stop() override
The QAudioFormat class stores audio stream parameter information.
constexpr ChannelConfig channelConfig() const noexcept
Returns the current channel configuration.
constexpr SampleFormat sampleFormat() const noexcept
Returns the current sample format.
Q_MULTIMEDIA_EXPORT void setChannelConfig(ChannelConfig config) noexcept
Sets the channel configuration to config.
constexpr void setChannelCount(int channelCount) noexcept
Sets the channel count to channels.
AudioChannelPosition
Describes the possible audio channel positions.
Q_MULTIMEDIA_EXPORT int channelOffset(AudioChannelPosition channel) const noexcept
Returns the position of a certain audio channel inside an audio frame for the given format.
constexpr void setSampleFormat(SampleFormat f) noexcept
Sets the sample format to format.
friend bool operator==(const QAudioFormat &a, const QAudioFormat &b)
Returns true if audio format a is equal to b, otherwise returns false.
constexpr bool isValid() const noexcept
Returns true if all of the parameters are valid.
constexpr int sampleRate() const noexcept
Returns the current sample rate in Hertz.
static constexpr int NChannelPositions
constexpr int bytesPerFrame() const
Returns the number of bytes required to represent one frame (a sample in each channel) in this format...
static constexpr ChannelConfig channelConfig(Args... channels)
Returns the current channel configuration for the given channels.
friend bool operator!=(const QAudioFormat &a, const QAudioFormat &b)
Returns true if audio format a is not equal to b, otherwise returns false.
SampleFormat
Qt will always expect and use samples in the endianness of the host platform.
constexpr int channelCount() const noexcept
Returns the current channel count value.
constexpr int bytesPerSample() const noexcept
Returns the number of bytes required to represent one sample in this format.
Q_MULTIMEDIA_EXPORT float normalizedSampleValue(const void *sample) const
Normalizes the sample value to a number between -1 and 1.
constexpr void setSampleRate(int sampleRate) noexcept
Sets the sample rate to samplerate in Hertz.
ChannelConfig
\variable QAudioFormat::NChannelPositions
@ ChannelConfigSurround7Dot1
@ ChannelConfigSurround5Dot1
@ ChannelConfigSurround7Dot0
@ ChannelConfigSurround5Dot0
int capture(const QString &fileName) override
virtual ~QWindowsImageCapture()
QImageEncoderSettings imageSettings() const override
void setImageSettings(const QImageEncoderSettings &settings) override
void setCaptureSession(QPlatformMediaCaptureSession *session)
bool isReadyForCapture() const override
QPlatformImageCapture * imageCapture() override
void setCamera(QPlatformCamera *camera) override
void setAudioInput(QPlatformAudioInput *) override
QPlatformCamera * camera() override
QPlatformMediaRecorder * mediaRecorder() override
void setImageCapture(QPlatformImageCapture *imageCapture) override
void setAudioOutput(QPlatformAudioOutput *output) override
void setMediaRecorder(QPlatformMediaRecorder *recorder) override
QWindowsMediaDeviceSession * session() const
void setMetaData(const QMediaMetaData &metaData) override
QMediaRecorder::RecorderState state() const override
void setCaptureSession(QPlatformMediaCaptureSession *session)
QMediaMetaData metaData() const override
bool isLocationWritable(const QUrl &location) const override
qint64 duration() const override
void record(QMediaEncoderSettings &settings) override
q23::expected< QPlatformVideoSink *, QString > createVideoSink(QVideoSink *sink) override
QPlatformMediaFormatInfo * createFormatInfo() override
q23::expected< QPlatformAudioDecoder *, QString > createAudioDecoder(QAudioDecoder *decoder) override
q23::expected< QPlatformCamera *, QString > createCamera(QCamera *camera) override
q23::expected< QPlatformImageCapture *, QString > createImageCapture(QImageCapture *imageCapture) override
QPlatformVideoDevices * createVideoDevices() override
q23::expected< QPlatformMediaRecorder *, QString > createRecorder(QMediaRecorder *recorder) override
q23::expected< QPlatformMediaPlayer *, QString > createPlayer(QMediaPlayer *parent) override
q23::expected< QPlatformMediaCaptureSession *, QString > createCaptureSession() override
STDMETHODIMP_(ULONG) AddRef(void) override
void mediaSourceReady()
IMFMediaSource * mediaSource() const
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject) override
constexpr int channelConfig(Args... values)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568