mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 14:45:55 +08:00
MediaSink: 修复静音音频添加逻辑bug
This commit is contained in:
parent
817542cd0c
commit
1ce841ce42
@ -176,8 +176,8 @@ void MediaSink::emitAllTrackReady() {
|
|||||||
|
|
||||||
void MediaSink::onAllTrackReady_l() {
|
void MediaSink::onAllTrackReady_l() {
|
||||||
//是否添加静音音频
|
//是否添加静音音频
|
||||||
GET_CONFIG(bool, addMuteAudio, General::kAddMuteAudio);
|
GET_CONFIG(bool, add_mute_audio, General::kAddMuteAudio);
|
||||||
if (addMuteAudio && _track_map.find(TrackAudio) == _track_map.end()) {
|
if (add_mute_audio) {
|
||||||
addMuteAudioTrack();
|
addMuteAudioTrack();
|
||||||
}
|
}
|
||||||
onAllTrackReady();
|
onAllTrackReady();
|
||||||
@ -248,20 +248,25 @@ bool MuteAudioMaker::inputFrame(const Frame::Ptr &frame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MediaSink::addMuteAudioTrack() {
|
bool MediaSink::addMuteAudioTrack() {
|
||||||
if (_track_map.find(TrackAudio) != _track_map.end()) {
|
GET_CONFIG(bool, enabel_audio, General::kEnableAudio);
|
||||||
WarnL << "audio track already existed";
|
if (!enabel_audio) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (_track_map.find(TrackAudio) != _track_map.end()) {
|
||||||
if (MediaSink::addTrack(std::make_shared<AACTrack>(makeAacConfig(MUTE_ADTS_DATA, ADTS_HEADER_LEN)))) {
|
return false;
|
||||||
_mute_audio_maker = std::make_shared<MuteAudioMaker>();
|
|
||||||
_mute_audio_maker->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame) {
|
|
||||||
return inputFrame(frame);
|
|
||||||
}));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
auto audio = std::make_shared<AACTrack>(makeAacConfig(MUTE_ADTS_DATA, ADTS_HEADER_LEN));
|
||||||
|
_track_map[audio->getTrackType()] = audio;
|
||||||
|
audio->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame) {
|
||||||
|
return onTrackFrame(frame);
|
||||||
|
}));
|
||||||
|
_mute_audio_maker = std::make_shared<MuteAudioMaker>();
|
||||||
|
_mute_audio_maker->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame) {
|
||||||
|
return inputFrame(frame);
|
||||||
|
}));
|
||||||
|
onTrackReady(audio);
|
||||||
|
TraceL << "mute aac track added";
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
Loading…
Reference in New Issue
Block a user