mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
AacTracker 增加构造函数
This commit is contained in:
parent
e628cba1ca
commit
b33c227cf4
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user