mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 12:11:36 +08:00
webrtc answer m-lines次序错误 (#1695)
Co-authored-by: james <mrjamesli@126.com>
This commit is contained in:
parent
483a75284e
commit
3a9408bcec
@ -1521,15 +1521,17 @@ void RtcConfigure::enableREMB(bool enable, TrackType type){
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<RtcSession> RtcConfigure::createAnswer(const RtcSession &offer){
|
||||
shared_ptr<RtcSession> RtcConfigure::createAnswer(const RtcSession &offer) const {
|
||||
shared_ptr<RtcSession> ret = std::make_shared<RtcSession>();
|
||||
ret->version = offer.version;
|
||||
ret->origin = offer.origin;
|
||||
ret->session_name = offer.session_name;
|
||||
ret->msid_semantic = offer.msid_semantic;
|
||||
matchMedia(ret, TrackAudio, offer.media, audio);
|
||||
matchMedia(ret, TrackVideo, offer.media, video);
|
||||
matchMedia(ret, TrackApplication, offer.media, application);
|
||||
|
||||
for (auto &m : offer.media) {
|
||||
matchMedia(ret, m);
|
||||
}
|
||||
|
||||
//设置音视频端口复用
|
||||
if (!offer.group.mids.empty()) {
|
||||
for (auto &m : ret->media) {
|
||||
@ -1573,17 +1575,22 @@ static DtlsRole mathDtlsRole(DtlsRole role){
|
||||
}
|
||||
}
|
||||
|
||||
void RtcConfigure::matchMedia(const shared_ptr<RtcSession> &ret, TrackType type, const vector<RtcMedia> &medias, const RtcTrackConfigure &configure){
|
||||
void RtcConfigure::matchMedia(const std::shared_ptr<RtcSession> &ret,const RtcMedia &offer_media) const {
|
||||
bool check_profile = true;
|
||||
bool check_codec = true;
|
||||
const RtcTrackConfigure *cfg_ptr = nullptr;
|
||||
|
||||
switch (offer_media.type) {
|
||||
case TrackAudio: cfg_ptr = &audio; break;
|
||||
case TrackVideo: cfg_ptr = &video; break;
|
||||
case TrackApplication: cfg_ptr = &application; break;
|
||||
default: return;
|
||||
}
|
||||
auto &configure = *cfg_ptr;
|
||||
|
||||
RETRY:
|
||||
|
||||
for (auto &offer_media : medias) {
|
||||
if (offer_media.type != type) {
|
||||
continue;
|
||||
}
|
||||
if (type == TrackApplication) {
|
||||
if (offer_media.type == TrackApplication) {
|
||||
RtcMedia answer_media = offer_media;
|
||||
answer_media.role = mathDtlsRole(offer_media.role);
|
||||
#ifdef ENABLE_SCTP
|
||||
@ -1720,7 +1727,6 @@ RETRY:
|
||||
ret->media.emplace_back(answer_media);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (check_profile) {
|
||||
//如果是由于检查profile导致匹配失败,那么重试一次,且不检查profile
|
||||
@ -1765,7 +1771,7 @@ void RtcConfigure::setPlayRtspInfo(const string &sdp){
|
||||
static const string kProfile{"profile-level-id"};
|
||||
static const string kMode{"packetization-mode"};
|
||||
|
||||
bool RtcConfigure::onCheckCodecProfile(const RtcCodecPlan &plan, CodecId codec){
|
||||
bool RtcConfigure::onCheckCodecProfile(const RtcCodecPlan &plan, CodecId codec) const {
|
||||
if (_rtsp_audio_plan && codec == getCodecId(_rtsp_audio_plan->codec)) {
|
||||
if (plan.sample_rate != _rtsp_audio_plan->sample_rate || plan.channel != _rtsp_audio_plan->channel) {
|
||||
//音频采样率和通道数必须相同
|
||||
@ -1785,7 +1791,7 @@ bool RtcConfigure::onCheckCodecProfile(const RtcCodecPlan &plan, CodecId codec){
|
||||
return true;
|
||||
}
|
||||
|
||||
void RtcConfigure::onSelectPlan(RtcCodecPlan &plan, CodecId codec){
|
||||
void RtcConfigure::onSelectPlan(RtcCodecPlan &plan, CodecId codec) const {
|
||||
if (_rtsp_video_plan && codec == CodecH264 && getCodecId(_rtsp_video_plan->codec) == CodecH264) {
|
||||
//h264时,设置packetization-mod为一致
|
||||
auto mode = _rtsp_video_plan->fmtp[kMode];
|
||||
|
@ -720,7 +720,7 @@ public:
|
||||
void setDefaultSetting(std::string ice_ufrag, std::string ice_pwd, RtpDirection direction, const SdpAttrFingerprint &fingerprint);
|
||||
void addCandidate(const SdpAttrCandidate &candidate, mediakit::TrackType type = mediakit::TrackInvalid);
|
||||
|
||||
std::shared_ptr<RtcSession> createAnswer(const RtcSession &offer);
|
||||
std::shared_ptr<RtcSession> createAnswer(const RtcSession &offer) const;
|
||||
|
||||
void setPlayRtspInfo(const std::string &sdp);
|
||||
|
||||
@ -728,9 +728,9 @@ public:
|
||||
void enableREMB(bool enable = true, mediakit::TrackType type = mediakit::TrackInvalid);
|
||||
|
||||
private:
|
||||
void matchMedia(const std::shared_ptr<RtcSession> &ret, mediakit::TrackType type, const std::vector<RtcMedia> &medias, const RtcTrackConfigure &configure);
|
||||
bool onCheckCodecProfile(const RtcCodecPlan &plan, mediakit::CodecId codec);
|
||||
void onSelectPlan(RtcCodecPlan &plan, mediakit::CodecId codec);
|
||||
void matchMedia(const std::shared_ptr<RtcSession> &ret, const RtcMedia &media) const;
|
||||
bool onCheckCodecProfile(const RtcCodecPlan &plan, mediakit::CodecId codec) const;
|
||||
void onSelectPlan(RtcCodecPlan &plan, mediakit::CodecId codec) const;
|
||||
|
||||
private:
|
||||
RtcCodecPlan::Ptr _rtsp_video_plan;
|
||||
|
Loading…
Reference in New Issue
Block a user