mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-06 12:13:49 +08:00
RTMP协议限制G711规格、日志打印codec相关信息
This commit is contained in:
parent
46740b7c31
commit
e85a8f277e
|
@ -293,7 +293,34 @@ void MediaSource::regist() {
|
|||
lock_guard<recursive_mutex> lock(g_mtxMediaSrc);
|
||||
g_mapMediaSrc[_strSchema][_strVhost][_strApp][_strId] = shared_from_this();
|
||||
}
|
||||
InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
||||
_StrPrinter codec_info;
|
||||
auto tracks = getTracks(true);
|
||||
for(auto &track : tracks) {
|
||||
auto codec_type = track->getTrackType();
|
||||
codec_info << track->getCodecName();
|
||||
switch (codec_type) {
|
||||
case TrackAudio : {
|
||||
auto audio_track = dynamic_pointer_cast<AudioTrack>(track);
|
||||
codec_info << "["
|
||||
<< audio_track->getAudioSampleRate() << "/"
|
||||
<< audio_track->getAudioChannel() << "/"
|
||||
<< audio_track->getAudioSampleBit() << "] ";
|
||||
break;
|
||||
}
|
||||
case TrackVideo : {
|
||||
auto video_track = dynamic_pointer_cast<VideoTrack>(track);
|
||||
codec_info << "["
|
||||
<< video_track->getVideoWidth() << "/"
|
||||
<< video_track->getVideoHeight() << "/"
|
||||
<< (int) video_track->getVideoFps() << "] ";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId << " " << codec_info;
|
||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, true, *this);
|
||||
}
|
||||
|
||||
|
@ -319,7 +346,7 @@ bool MediaSource::unregist() {
|
|||
}
|
||||
|
||||
if(ret){
|
||||
InfoL << "" << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
||||
InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
|
||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, false, *this);
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -39,6 +39,28 @@ void RtmpMuxer::addTrack(const Track::Ptr &track) {
|
|||
|
||||
}
|
||||
|
||||
switch (track->getCodecId()){
|
||||
case CodecG711A:
|
||||
case CodecG711U:{
|
||||
auto audio_track = dynamic_pointer_cast<AudioTrack>(track);
|
||||
if(!audio_track){
|
||||
return;
|
||||
}
|
||||
if (audio_track->getAudioSampleRate() != 8000 ||
|
||||
audio_track->getAudioChannel() != 1 ||
|
||||
audio_track->getAudioSampleBit() != 16) {
|
||||
WarnL << "RTMP只支持8000/1/16规格的G711,目前规格是:"
|
||||
<< audio_track->getAudioSampleRate() << "/"
|
||||
<< audio_track->getAudioChannel() << "/"
|
||||
<< audio_track->getAudioSampleBit()
|
||||
<< ",该音频已被忽略";
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default : break;
|
||||
}
|
||||
|
||||
auto &encoder = _encoder[track->getTrackType()];
|
||||
//生成rtmp编码器,克隆该Track,防止循环引用
|
||||
encoder = Factory::getRtmpCodecByTrack(track->clone());
|
||||
|
|
Loading…
Reference in New Issue
Block a user