Skip to content

Commit 9f9dc1a

Browse files
author
Valentin Noel
committed
Add a first version of setProfile method into OutputStreamAudio
1 parent ef0bf2d commit 9f9dc1a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/AvTranscoder/OutputStreamAudio.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern "C" {
99
#include <libavutil/avutil.h>
1010
}
1111

12+
#include "Profile.hpp"
13+
1214
namespace avtranscoder
1315
{
1416

@@ -19,6 +21,7 @@ OutputStreamAudio::OutputStreamAudio()
1921

2022
bool OutputStreamAudio::setup()
2123
{
24+
std::cout << "[OutputStreamAudio::setup] ..." << std::endl;
2225
av_register_all(); // Warning: should be called only once
2326

2427
AVCodecContext* codecContext( m_audioDesc.getCodecContext() );
@@ -160,4 +163,17 @@ bool OutputStreamAudio::encodeFrame( DataStream& codedFrame )
160163
#endif
161164
}
162165

166+
void OutputStreamAudio::setProfile( const std::string& profile )
167+
{
168+
Profile p;
169+
p.loadAudioProfiles();
170+
Profile::ProfileDesc profDesc = p.getProfile( profile );
171+
172+
m_audioDesc.setAudioCodec( profDesc["codec"] );
173+
m_audioDesc.setAudioParameters( 48000, 2, av_get_sample_fmt( profDesc["sample_fmt"].c_str() ) );
174+
175+
setup();
163176
}
177+
178+
}
179+

src/AvTranscoder/OutputStreamAudio.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class OutputStreamAudio : public OutputStream
2626
*/
2727
bool encodeFrame( DataStream& codedFrame );
2828

29+
void setProfile( const std::string& profile );
30+
2931
AudioDesc& getAudioDesc() { return m_audioDesc; }
3032

3133
private:

0 commit comments

Comments
 (0)