5#include <QtCore/qcoreapplication.h>
14 , m_ownStream(ownStream)
15 , m_currentReadResult(0)
36 if (
riid == IID_IMFByteStream) {
37 *ppvObject =
static_cast<IMFByteStream*
>(
this);
38 }
else if (
riid == IID_IUnknown) {
39 *ppvObject =
static_cast<IUnknown*
>(
this);
50 return InterlockedIncrement(&m_cRef);
55 LONG cRef = InterlockedDecrement(&m_cRef);
68 *pdwCapabilities = MFBYTESTREAM_IS_READABLE;
70 *pdwCapabilities |= MFBYTESTREAM_IS_SEEKABLE;
79 *pqwLength = QWORD(m_stream->
size());
93 *pqwPosition = m_stream->
pos();
106 bool seekOK = m_stream->
seek(
qint64(qwPosition));
118 *pfEndOfStream = m_stream->
atEnd() ? TRUE : FALSE;
127 *pcbRead = ULONG(
read);
134 if (!pCallback || !pb)
139 AsyncReadState *
state =
new (std::nothrow) AsyncReadState(pb,
cb);
141 return E_OUTOFMEMORY;
157 pResult->GetObject(&pUnk);
158 AsyncReadState *
state =
static_cast<AsyncReadState*
>(pUnk);
159 *pcbRead =
state->bytesRead();
187 MFBYTESTREAM_SEEK_ORIGIN SeekOrigin,
188 LONGLONG llSeekOffset,
190 QWORD *pqwCurrentPosition)
197 switch (SeekOrigin) {
204 bool seekOK = m_stream->
seek(
pos);
205 if (pqwCurrentPosition)
206 *pqwCurrentPosition =
pos;
226void MFStream::doRead()
231 bool readDone =
true;
232 IUnknown *pUnk = NULL;
236 AsyncReadState *
state =
static_cast<AsyncReadState*
>(pUnk);
241 state->setBytesRead(cbRead +
state->bytesRead());
266MFStream::AsyncReadState::AsyncReadState(BYTE *pb, ULONG
cb)
275STDMETHODIMP MFStream::AsyncReadState::QueryInterface(REFIID
riid, LPVOID *ppvObject)
280 if (
riid == IID_IUnknown) {
281 *ppvObject =
static_cast<IUnknown*
>(
this);
284 return E_NOINTERFACE;
292 return InterlockedIncrement(&m_cRef);
297 LONG cRef = InterlockedDecrement(&m_cRef);
304BYTE* MFStream::AsyncReadState::pb()
const
309ULONG MFStream::AsyncReadState::cb()
const
314ULONG MFStream::AsyncReadState::bytesRead()
const
319void MFStream::AsyncReadState::setBytesRead(ULONG cbRead)
326#include "moc_mfstream_p.cpp"
STDMETHODIMP SetLength(QWORD) override
STDMETHODIMP EndWrite(IMFAsyncResult *, ULONG *) override
STDMETHODIMP Flush() override
STDMETHODIMP Write(const BYTE *, ULONG, ULONG *) override
STDMETHODIMP SetCurrentPosition(QWORD qwPosition) override
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObject) override
MFStream(QIODevice *stream, bool ownStream)
void customEvent(QEvent *event) override
This event handler can be reimplemented in a subclass to receive custom events.
IMFAsyncResult * m_currentReadResult
STDMETHODIMP GetCapabilities(DWORD *pdwCapabilities) override
STDMETHODIMP Seek(MFBYTESTREAM_SEEK_ORIGIN SeekOrigin, LONGLONG llSeekOffset, DWORD, QWORD *pqwCurrentPosition) override
STDMETHODIMP GetCurrentPosition(QWORD *pqwPosition) override
STDMETHODIMP Close() override
STDMETHODIMP BeginRead(BYTE *pb, ULONG cb, IMFAsyncCallback *pCallback, IUnknown *punkState) override
STDMETHODIMP IsEndOfStream(BOOL *pfEndOfStream) override
STDMETHODIMP Read(BYTE *pb, ULONG cb, ULONG *pcbRead) override
STDMETHODIMP BeginWrite(const BYTE *, ULONG, IMFAsyncCallback *, IUnknown *) override
STDMETHODIMP EndRead(IMFAsyncResult *pResult, ULONG *pcbRead) override
STDMETHODIMP GetLength(QWORD *pqwLength) override
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
\inmodule QtCore \reentrant
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
QThread * thread() const
Returns the thread in which the object lives.
void deleteLater()
\threadsafe
virtual void customEvent(QEvent *event)
This event handler can be reimplemented in a subclass to receive custom events.
STDMETHODIMP_(ULONG) MFStream
Combined button and popup list for selecting options.
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
ReturnedValue read(const char *data)
IUIViewSettingsInterop __RPC__in REFIID riid