Skip to content

Commit b323cc4

Browse files
author
Clement Champetier
committed
InputStreamAudio: fix channels error when decode stream
* InputStreamAudio: update constructor to indicate number of channels of the CodecContext. * AudioDesc: add getters for channels, sample rate and sample format.
1 parent c7ff0c3 commit b323cc4

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/AvTranscoder/DatasStructures/AudioDesc.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,21 @@ AVCodecID AudioDesc::getAudioCodecId() const
193193
return m_codecContext->codec_id;
194194
}
195195

196+
197+
const size_t AudioDesc::getSampleRate() const
198+
{
199+
return m_codecContext->sample_rate;
200+
}
201+
202+
const size_t AudioDesc::getChannels() const
203+
{
204+
return m_codecContext->channels;
205+
}
206+
207+
const AVSampleFormat AudioDesc::getSampleFormat() const
208+
{
209+
return m_codecContext->sample_fmt;
210+
}
211+
212+
196213
}

src/AvTranscoder/DatasStructures/AudioDesc.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class AvExport AudioDesc
3838

3939
std::string getAudioCodec() const;
4040
AVCodecID getAudioCodecId() const;
41+
42+
const size_t getSampleRate() const;
43+
const size_t getChannels() const;
44+
const AVSampleFormat getSampleFormat() const;
4145

4246
#ifndef SWIG
4347
AVCodec* getCodec() const { return m_codec; }

src/AvTranscoder/InputStreamAudio.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ InputStreamAudio::InputStreamAudio( const InputStream& inputStream )
3939
{
4040
throw std::runtime_error( "unable to find context for codec" );
4141
}
42+
43+
m_codecContext->channels = m_inputStream->getAudioDesc().getChannels();
4244

4345
std::cout << "Audio codec Id : " << m_codecContext->codec_id << std::endl;
4446
std::cout << "Audio codec Id : " << m_codec->long_name << std::endl;

0 commit comments

Comments
 (0)