Commit b33c227c by cqm

AacTracker 增加构造函数

parent e628cba1
......@@ -18,8 +18,8 @@ using namespace toolkit;
namespace mediakit{
#ifndef ENABLE_MP4
unsigned const samplingFrequencyTable[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 };
#ifndef ENABLE_MP4
class AdtsHeader{
public:
......@@ -246,6 +246,22 @@ AACTrack::AACTrack(const string &aac_cfg) {
onReady();
}
AACTrack::AACTrack(int samplerate, int channel, int profile) : _channel(channel), _sampleRate(samplerate) {
uint8_t audioSpecificConfig[2] = { 0 };
uint8_t audioObjectType = profile+1;
int samplingFrequencyIndex = 0;
for (size_t i = 0; i < sizeof(samplingFrequencyTable) / sizeof(samplingFrequencyTable[0]); i++) {
if (samplingFrequencyTable[i] == (unsigned)samplerate) {
samplingFrequencyIndex = i;
break;
}
}
_cfg.resize(2);
_cfg[0] = (audioObjectType << 3) | (samplingFrequencyIndex >> 1);
_cfg[1] = (samplingFrequencyIndex << 7) | (channel << 3);
// onReady();
}
const string &AACTrack::getConfig() const {
return _cfg;
}
......
......@@ -40,6 +40,7 @@ public:
* @param aac_cfg aac配置信息
*/
AACTrack(const std::string &aac_cfg);
AACTrack(int samplerate, int channel, int profile=1);
/**
* 获取aac 配置信息
......
......@@ -22,7 +22,7 @@ namespace mediakit{
class G711Track : public AudioTrackImp{
public:
using Ptr = std::shared_ptr<G711Track>;
G711Track(CodecId codecId, int sample_rate, int channels, int sample_bit) : AudioTrackImp(codecId, 8000, 1, 16) {}
G711Track(CodecId codecId, int sample_rate = 8000, int channels = 1, int sample_bit = 16) : AudioTrackImp(codecId, sample_rate, channels, sample_bit) {}
private:
Sdp::Ptr getSdp() override;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论