QAudioDecoder Class

QAudioDecoder 클래스는 오디오 디코딩을 구현합니다. 더 보기...

헤더: #include <QAudioDecoder>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
상속합니다: QObject
상태: 예비

이 클래스는 개발 중이며 변경될 수 있습니다.

공용 유형

enum Error { NoError, ResourceError, FormatError, AccessDeniedError, NotSupportedError }

속성

공용 기능

QAudioDecoder(QObject *parent = nullptr)
virtual ~QAudioDecoder() override
QAudioFormat audioFormat() const
bool bufferAvailable() const
qint64 duration() const
QAudioDecoder::Error error() const
QString errorString() const
bool isDecoding() const
bool isSupported() const
qint64 position() const
QAudioBuffer read() const
void setAudioFormat(const QAudioFormat &format)
void setSource(const QUrl &fileName)
void setSourceDevice(QIODevice *device)
QUrl source() const
QIODevice *sourceDevice() const

공용 슬롯

void start()
void stop()

신호

void bufferAvailableChanged(bool available)
void bufferReady()
void durationChanged(qint64 duration)
void error(QAudioDecoder::Error error)
void finished()
void formatChanged(const QAudioFormat &format)
void isDecodingChanged(bool)
void positionChanged(qint64 position)
void sourceChanged()

상세 설명

QAudioDecoder 클래스는 오디오 미디어 파일을 디코딩하기 위한 상위 클래스입니다. 오디오가 오디오 하드웨어로 직접 라우팅되지 않고 이 API를 통해 다시 제공된다는 점을 제외하면 QMediaPlayer 클래스와 유사합니다.

QAudioBuffer참조하세요 .

멤버 유형 문서

enum QAudioDecoder::Error

미디어 플레이어 오류 조건을 정의합니다.

상수설명
QAudioDecoder::NoError0오류가 발생하지 않았습니다.
QAudioDecoder::ResourceError1미디어 리소스를 확인할 수 없습니다.
QAudioDecoder::FormatError2미디어 리소스의 형식이 지원되지 않습니다.
QAudioDecoder::AccessDeniedError3미디어 리소스를 재생할 수 있는 적절한 권한이 없습니다.
QAudioDecoder::NotSupportedError4QAudioDecoder 이 플랫폼에서는 지원되지 않습니다.

속성 문서

[read-only] bufferAvailable : const bool

이 프로퍼티는 디코딩된 오디오 버퍼가 있는지 여부를 보유합니다.

액세스 함수:

bool bufferAvailable() const

알림 신호:

void bufferAvailableChanged(bool available)

[read-only] error : const QString

현재 오류에 대한 사람이 읽을 수 있는 설명을 반환하거나 오류가 없는 경우 빈 문자열을 반환합니다.

액세스 함수:

QString errorString() const

[read-only] isDecoding : const bool

true 디코더가 현재 실행 중이고 오디오 데이터를 디코딩하고 있는 경우.

기능 액세스:

bool isDecoding() const

알림 신호:

void isDecodingChanged(bool)

source : QUrl

이 프로퍼티는 디코더 객체가 디코딩 중인 활성 파일 이름을 보유합니다.

함수에 액세스합니다:

QUrl source() const
void setSource(const QUrl &fileName)

알림 신호:

void sourceChanged()

멤버 함수 문서

[explicit] QAudioDecoder::QAudioDecoder(QObject *parent = nullptr)

parent 를 사용하여 QAudioDecoder 인스턴스를 생성합니다.

[override virtual noexcept] QAudioDecoder::~QAudioDecoder()

오디오 디코더 객체를 삭제합니다.

QAudioFormat QAudioDecoder::audioFormat() const

디코더가 설정된 오디오 포맷을 반환합니다.

참고: 오디오 포맷이 잘못된 포맷으로 설정된 경우 디코딩된 샘플의 포맷과 다를 수 있습니다.

setAudioFormat() 및 formatChanged()도 참조하세요 .

bool QAudioDecoder::bufferAvailable() const

읽을 수 있는 버퍼가 있으면 참을 반환하고 그렇지 않으면 거짓을 반환합니다. 사용 가능한 버퍼가 없는 경우 read() 함수를 호출하면 유효하지 않은 버퍼가 반환됩니다.

참고: 속성 bufferAvailable에 대한 겟터 함수.

[signal] void QAudioDecoder::bufferAvailableChanged(bool available)

새 버퍼의 사용 가능 여부( available 가 참인 경우)를 알립니다.

available 이 거짓이면 사용 가능한 버퍼가 없습니다.

참고: bufferAvailable 속성에 대한 알림 신호입니다.

bufferAvailable() 및 bufferReady()도 참조하세요 .

[signal] void QAudioDecoder::bufferReady()

디코딩된 새 오디오 버퍼를 읽을 수 있다는 신호를 보냅니다.

read() 및 bufferAvailable()도 참조하세요 .

qint64 QAudioDecoder::duration() const

오디오 스트림의 총 지속 시간(밀리초)을 반환하거나 사용할 수 없는 경우 -1을 반환합니다.

[signal] void QAudioDecoder::durationChanged(qint64 duration)

디코딩된 데이터의 예상 duration 이 변경되었음을 알립니다.

positionChanged()도 참조하세요 .

QAudioDecoder::Error QAudioDecoder::error() const

QAudioDecoder 의 현재 오류 상태를 반환합니다.

[signal] void QAudioDecoder::error(QAudioDecoder::Error error)

error 조건이 발생했음을 알립니다.

참고: 이 클래스에서는 신호 에러가 오버로드됩니다. 함수 포인터 구문을 사용하여 이 신호에 연결하려면 이 예제와 같이 함수 포인터를 얻기 위한 편리한 헬퍼를 Qt에서 제공합니다:

connect(audioDecoder, QOverload<QAudioDecoder::Error>::of(&QAudioDecoder::error),
    [=](QAudioDecoder::Error error){ /* ... */ });

errorString()도 참조하십시오 .

[signal] void QAudioDecoder::finished()

디코딩이 성공적으로 완료되었음을 알리는 신호입니다. 디코딩에 실패하면 오류 신호가 대신 전송됩니다.

start(), stop() 및 error()도 참조하세요 .

[signal] void QAudioDecoder::formatChanged(const QAudioFormat &format)

디코더의 현재 오디오 형식이 format 로 변경되었음을 알립니다.

audioFormat() 및 setAudioFormat()도 참조하세요 .

bool QAudioDecoder::isSupported() const

이 플랫폼에서 오디오 디코딩이 지원되면 true를 반환합니다.

qint64 QAudioDecoder::position() const

디코더에서 마지막으로 읽은 버퍼의 위치(밀리초 단위)를 반환하거나 읽은 버퍼가 없는 경우 -1을 반환합니다.

[signal] void QAudioDecoder::positionChanged(qint64 position)

디코더의 현재 position 가 변경되었음을 알립니다.

durationChanged()도 참조하세요 .

QAudioBuffer QAudioDecoder::read() const

디코더에서 버퍼를 읽을 수 있는 경우 버퍼를 읽습니다. 현재 사용 가능한 디코딩된 버퍼가 없거나 실패하면 유효하지 않은 버퍼를 반환합니다. 두 경우 모두 이 함수는 차단되지 않습니다.

유용한 데이터를 얻으려면 read() 함수를 호출하기 전에 bufferReady() 신호에 응답하거나 bufferAvailable() 함수를 확인해야 합니다.

void QAudioDecoder::setAudioFormat(const QAudioFormat &format)

디코딩된 샘플에 대해 원하는 오디오 형식을 format 으로 설정합니다.

이 속성은 디코더가 중지된 상태에서만 설정할 수 있습니다. 다른 시간에 이 속성을 설정하면 무시됩니다.

디코더가 이 형식을 지원하지 않는 경우 error()는 FormatError 으로 설정됩니다.

형식을 지정하지 않으면 디코딩된 오디오 자체의 형식이 사용됩니다. 그렇지 않으면 일부 형식 변환이 적용됩니다.

디코딩된 형식을 원본 오디오 파일의 형식으로 재설정하려면 잘못된 format 을 지정할 수 있습니다.

경고: 원하는 오디오 포맷 설정은 아직 Android 백엔드에서 지원되지 않습니다. 기본 FFMPEG 백엔드에서는 작동합니다.

audioFormat()도 참조하세요 .

void QAudioDecoder::setSource(const QUrl &fileName)

현재 오디오 파일 이름을 fileName 로 설정합니다.

이 속성을 설정하면 현재 디코딩이 중지되고 오디오 버퍼가 모두 삭제됩니다.

소스 파일 이름 또는 소스 QIODevice 만 지정할 수 있습니다. 하나를 설정하면 다른 하나는 설정이 해제됩니다.

참고: 속성 설정자 함수 source.

source()도 참조하세요 .

void QAudioDecoder::setSourceDevice(QIODevice *device)

현재 오디오 QIODevicedevice 로 설정합니다.

이 속성을 설정하면 현재 디코딩이 중지되고 오디오 버퍼가 모두 삭제됩니다.

소스 파일 이름 또는 소스 QIODevice 만 지정할 수 있습니다. 하나를 설정하면 다른 하나는 설정 해제됩니다.

sourceDevice()도 참조하세요 .

QUrl QAudioDecoder::source() const

디코딩할 현재 파일 이름을 반환합니다. setSourceDevice 이 호출된 경우 비어 있습니다.

참고: 속성 소스에 대한 게터 함수입니다.

setSource()도 참조하세요 .

[signal] void QAudioDecoder::sourceChanged()

디코더의 현재 소스가 변경되었음을 알리는 신호입니다.

참고: 속성 source 에 대한 알림 신호입니다.

source() 및 sourceDevice()도 참조하세요 .

QIODevice *QAudioDecoder::sourceDevice() const

현재 소스 QIODevice 를 반환합니다(설정된 경우). setSource ()가 호출된 경우 nullptr이 됩니다.

setSourceDevice()도 참조하세요 .

[slot] void QAudioDecoder::start()

오디오 리소스 디코딩을 시작합니다.

데이터가 디코딩되면 데이터가 충분히 디코딩되면 bufferReady() 신호가 전송됩니다. 그러면 read()를 호출하면 차단되지 않고 오디오 버퍼가 반환됩니다.

버퍼가 준비되기 전에 read()를 호출하면 차단 없이 유효하지 않은 버퍼가 반환됩니다.

read()도 참조하세요 .

[slot] void QAudioDecoder::stop()

오디오 디코딩을 중지합니다. start ()를 다시 호출하면 처음부터 디코딩이 다시 시작됩니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.