Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegioutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 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#include "qffmpegioutils_p.h"
5#include "qiodevice.h"
6#include "qffmpegdefs_p.h"
7
9
10namespace QFFmpeg {
11
12int readQIODevice(void *opaque, uint8_t *buf, int buf_size)
13{
14 auto *dev = static_cast<QIODevice *>(opaque);
15 Q_ASSERT(dev);
16
17 if (dev->atEnd())
18 return AVERROR_EOF;
19 return dev->read(reinterpret_cast<char *>(buf), buf_size);
20}
21
22int writeQIODevice(void *opaque, AvioWriteBufferType buf, int buf_size)
23{
24 auto dev = static_cast<QIODevice *>(opaque);
25 Q_ASSERT(dev);
26
27 return dev->write(reinterpret_cast<const char *>(buf), buf_size);
28}
29
30int64_t seekQIODevice(void *opaque, int64_t offset, int whence)
31{
32 QIODevice *dev = static_cast<QIODevice *>(opaque);
33 Q_ASSERT(dev);
34
35 if (dev->isSequential())
36 return AVERROR(EINVAL);
37
38 if (whence & AVSEEK_SIZE)
39 return dev->size();
40
41 whence &= ~AVSEEK_FORCE;
42
43 if (whence == SEEK_CUR)
44 offset += dev->pos();
45 else if (whence == SEEK_END)
46 offset += dev->size();
47
48 if (!dev->seek(offset))
49 return AVERROR(EINVAL);
50 return offset;
51}
52
53} // namespace QFFmpeg
54
\inmodule QtCore \reentrant
Definition qiodevice.h:34
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 bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
int writeQIODevice(void *opaque, AvioWriteBufferType buf, int buf_size)
int64_t seekQIODevice(void *opaque, int64_t offset, int whence)
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
int readQIODevice(void *opaque, uint8_t *buf, int buf_size)
Combined button and popup list for selecting options.
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLintptr offset
#define Q_ASSERT(cond)
Definition qrandom.cpp:47