|
vdr-plugin-softhddevice-drm-gles 1.6.7
|
Audio Decoder. More...
#include <codec_audio.h>
Public Member Functions | |
| cAudioDecoder (cSoftHdAudio *) | |
| Create a new audio decoder for the given audio context. | |
| ~cAudioDecoder (void) | |
| void | Open (AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 }) |
| Open and initiate the audio decoder. | |
| void | Close (void) |
| Close the audio decoder. | |
| void | Decode (const AVPacket *) |
| Forward an audio packet either to the decoder or passthrough. | |
| void | FlushBuffers (void) |
| Flush the audio decoder buffers. | |
| void | SetPassthroughMask (int) |
| Set audio pass-through mask. | |
| AVCodecID | GetCodecId () const |
Private Member Functions | |
| bool | OpenSpdifMuxer (AVCodecID, int) |
| Open the spdif muxer. | |
| void | CloseSpdifMuxer (void) |
| Close the spdif muxer and free the resources. | |
| const std::vector< uint8_t > & | BuildIEC61937 (const AVPacket *) |
| Prepend an IEC61937 header to the raw audio data by sending the avpkt to the spdif muxer. | |
| bool | ShouldTryPassthrough (void) |
| Test, if passthrough audio should be tried. | |
| int | Passthrough (const AVPacket *) |
| Passthrough audio data. | |
| void | DecodePCM (const AVPacket *) |
| Decode an audio packet. | |
| int | CheckUpdateFormat (bool) |
| Handle audio format changes and setup audio, if format changed. | |
Static Private Member Functions | |
| static int | SpdifWriteCallback (void *, uint8_t *, int) |
| Callback for the spdif muxer. | |
Private Attributes | |
| cSoftHdAudio * | m_pAudio |
| audio module | |
| AVCodecContext * | m_pAudioCtx = nullptr |
| ffmpeg audio codec context | |
| AVCodecID | m_codecId = AV_CODEC_ID_NONE |
| current codec id | |
| AVFrame * | m_pFrame |
| decoded ffmpeg audio frame | |
| int64_t | m_lastPts = AV_NOPTS_VALUE |
| last seen PTS | |
| int | m_passthroughMask |
| passthrough mask to be set | |
| int | m_currentPassthroughMask |
| current passthrough mask | |
| int | m_currentSampleRate |
| current sample rate | |
| int | m_currentNumChannels |
| current number of channels | |
| int | m_currentHwSampleRate |
| current hw sample rate | |
| int | m_currentHwNumChannels |
| current number of hw channels | |
| std::mutex | m_mutex |
| decoder mutex | |
| std::array< uint8_t, 32768 > | m_spdifIoBuffer |
| spdif I/O buffer | |
| AVFormatContext * | m_spdifFmtCtx = nullptr |
| spdif muxer context | |
| std::vector< uint8_t > | m_spdifOutputBuf |
| spdif muxer output | |
Static Private Attributes | |
| static constexpr int | AUDIO_PASSTHROUGH_NUM_CHANNELS = 2 |
| fixed passthrough channel number | |
| static constexpr int | AUDIO_PASSTHROUGH_RATE_HZ = 48000 |
| fixed passthrough sample rate | |
Audio Decoder.
FFmpeg Based Audio Decoder Frontend
Handles:
Definition at line 59 of file codec_audio.h.
| cAudioDecoder::cAudioDecoder | ( | cSoftHdAudio * | audio | ) |
Create a new audio decoder for the given audio context.
| audio | audio context |
Definition at line 60 of file codec_audio.cpp.
References GetPassthroughMaskString(), L_CODEC, LOGDEBUG2, LOGFATAL, m_passthroughMask, and m_pFrame.
| cAudioDecoder::~cAudioDecoder | ( | void | ) |
Definition at line 70 of file codec_audio.cpp.
Prepend an IEC61937 header to the raw audio data by sending the avpkt to the spdif muxer.
| avpkt | input packet |
Definition at line 242 of file codec_audio.cpp.
References av_err2str, LOGERROR, m_spdifFmtCtx, and m_spdifOutputBuf.
Referenced by Passthrough().
Handle audio format changes and setup audio, if format changed.
| 0 | if new audio was correctly set up, otherwise return value of cSoftHdAudio::Setup() |
Definition at line 296 of file codec_audio.cpp.
References AUDIO_PASSTHROUGH_NUM_CHANNELS, AUDIO_PASSTHROUGH_RATE_HZ, CloseSpdifMuxer(), GetPassthroughMaskString(), L_SOUND, LOGDEBUG2, LOGERROR, m_currentHwNumChannels, m_currentHwSampleRate, m_currentNumChannels, m_currentPassthroughMask, m_currentSampleRate, m_passthroughMask, m_pAudio, m_pAudioCtx, and cSoftHdAudio::Setup().
Referenced by DecodePCM(), and Passthrough().
Close the audio decoder.
Definition at line 134 of file codec_audio.cpp.
References AV_NOPTS_VALUE, CloseSpdifMuxer(), L_CODEC, LOGDEBUG2, m_codecId, m_lastPts, m_mutex, and m_pAudioCtx.
Referenced by cSoftHdDevice::PlayAudio(), and ~cAudioDecoder().
Close the spdif muxer and free the resources.
Definition at line 220 of file codec_audio.cpp.
References L_CODEC, LOGDEBUG2, m_spdifFmtCtx, and m_spdifOutputBuf.
Referenced by CheckUpdateFormat(), Close(), and OpenSpdifMuxer().
Forward an audio packet either to the decoder or passthrough.
| avpkt | audio packet to decode |
Definition at line 349 of file codec_audio.cpp.
References DecodePCM(), m_mutex, Passthrough(), and ShouldTryPassthrough().
Referenced by cSoftHdDevice::PlayAudio(), and cSoftHdDevice::PlayAudioPkts().
Decode an audio packet.
| avpkt | audio packet to decode |
Definition at line 398 of file codec_audio.cpp.
References av_err2str, AV_NOPTS_VALUE, CheckUpdateFormat(), cSoftHdAudio::Filter(), LOGERROR, m_lastPts, m_pAudio, m_pAudioCtx, and m_pFrame.
Referenced by Decode().
Flush the audio decoder buffers.
Also resets the last PTS and Codec ID
Definition at line 452 of file codec_audio.cpp.
References AV_NOPTS_VALUE, L_CODEC, LOGDEBUG2, m_codecId, m_lastPts, m_mutex, and m_pAudioCtx.
Referenced by cSoftHdDevice::FlushAudio().
|
inline |
Definition at line 68 of file codec_audio.h.
References m_codecId.
Referenced by cSoftHdDevice::PlayAudio().
| void cAudioDecoder::Open | ( | AVCodecID | codecId, |
| AVCodecParameters * | par = nullptr, |
||
| AVRational | timebase = { .num = 1, .den = 90000 } |
||
| ) |
Open and initiate the audio decoder.
| codecId | audio codec id |
| par | audio codec parameters |
| timebase | timebase |
Definition at line 86 of file codec_audio.cpp.
References GetPassthroughMaskString(), L_CODEC, LOGDEBUG2, LOGERROR, LOGFATAL, m_codecId, m_currentHwNumChannels, m_currentHwSampleRate, m_currentNumChannels, m_currentPassthroughMask, m_currentSampleRate, m_mutex, m_passthroughMask, and m_pAudioCtx.
Referenced by cSoftHdDevice::PlayAudio(), and cSoftHdDevice::SetAudioCodec().
Open the spdif muxer.
| codecId | Codec ID of the stream |
| sampleRate | Samplerate of the stream |
Definition at line 178 of file codec_audio.cpp.
References CloseSpdifMuxer(), L_CODEC, LOGDEBUG2, LOGERROR, m_spdifFmtCtx, m_spdifIoBuffer, m_spdifOutputBuf, and SpdifWriteCallback().
Referenced by Passthrough().
Passthrough audio data.
Build spdif headers depending on the codec and send the data to the audio device.
| avpkt | undecoded audio packet |
| 0 | codec is not supported for passthrough, sth. went wrong or we need more data to finish a spdif burst packet |
| 1 | spdif burst was enqueued |
Definition at line 370 of file codec_audio.cpp.
References BuildIEC61937(), CheckUpdateFormat(), cSoftHdAudio::EnqueueSpdif(), LOGERROR, m_currentHwSampleRate, m_pAudio, m_pAudioCtx, m_spdifFmtCtx, OpenSpdifMuxer(), and cSoftHdAudio::SetTimebase().
Referenced by Decode().
Set audio pass-through mask.
| mask | codec mask to enable (AC-3, E-AC-3, DTS) |
Definition at line 469 of file codec_audio.cpp.
References CODEC_AC3, CODEC_DTS, CODEC_EAC3, and m_passthroughMask.
Referenced by cSoftHdDevice::SetPassthroughMask().
Test, if passthrough audio should be tried.
To enable passthrough, the current codec must be enabled in the setup
Currently supported: AC3, E-AC-3, DTS
Definition at line 283 of file codec_audio.cpp.
References CODEC_AC3, CODEC_DTS, CODEC_EAC3, m_passthroughMask, and m_pAudioCtx.
Referenced by Decode().
|
staticprivate |
Callback for the spdif muxer.
This is called, whenever FFmpeg flushes data from the muxer to the AVIOContext. In the current implementation, a flush is forced after every muxer input write.
Definition at line 160 of file codec_audio.cpp.
Referenced by OpenSpdifMuxer().
fixed passthrough channel number
Definition at line 88 of file codec_audio.h.
Referenced by CheckUpdateFormat().
fixed passthrough sample rate
Definition at line 89 of file codec_audio.h.
Referenced by CheckUpdateFormat().
|
private |
current codec id
Definition at line 73 of file codec_audio.h.
Referenced by Close(), FlushBuffers(), GetCodecId(), and Open().
|
private |
current number of hw channels
Definition at line 81 of file codec_audio.h.
Referenced by CheckUpdateFormat(), and Open().
|
private |
current hw sample rate
Definition at line 80 of file codec_audio.h.
Referenced by CheckUpdateFormat(), Open(), and Passthrough().
|
private |
current number of channels
Definition at line 79 of file codec_audio.h.
Referenced by CheckUpdateFormat(), and Open().
|
private |
current passthrough mask
Definition at line 77 of file codec_audio.h.
Referenced by CheckUpdateFormat(), and Open().
|
private |
current sample rate
Definition at line 78 of file codec_audio.h.
Referenced by CheckUpdateFormat(), and Open().
|
private |
last seen PTS
Definition at line 75 of file codec_audio.h.
Referenced by Close(), DecodePCM(), and FlushBuffers().
|
private |
decoder mutex
Definition at line 82 of file codec_audio.h.
Referenced by Close(), Decode(), FlushBuffers(), and Open().
|
private |
passthrough mask to be set
Definition at line 76 of file codec_audio.h.
Referenced by cAudioDecoder(), CheckUpdateFormat(), Open(), SetPassthroughMask(), and ShouldTryPassthrough().
|
private |
audio module
Definition at line 71 of file codec_audio.h.
Referenced by CheckUpdateFormat(), DecodePCM(), and Passthrough().
|
private |
ffmpeg audio codec context
Definition at line 72 of file codec_audio.h.
Referenced by CheckUpdateFormat(), Close(), DecodePCM(), FlushBuffers(), Open(), Passthrough(), and ShouldTryPassthrough().
|
private |
decoded ffmpeg audio frame
Definition at line 74 of file codec_audio.h.
Referenced by cAudioDecoder(), DecodePCM(), and ~cAudioDecoder().
|
private |
spdif muxer context
Definition at line 85 of file codec_audio.h.
Referenced by BuildIEC61937(), CloseSpdifMuxer(), OpenSpdifMuxer(), and Passthrough().
|
private |
|
private |
spdif muxer output
Definition at line 86 of file codec_audio.h.
Referenced by BuildIEC61937(), CloseSpdifMuxer(), and OpenSpdifMuxer().