diff --git a/src/projects/publishers/push/push_session.cpp b/src/projects/publishers/push/push_session.cpp index 14b764e53..928a3359d 100755 --- a/src/projects/publishers/push/push_session.cpp +++ b/src/projects/publishers/push/push_session.cpp @@ -85,23 +85,22 @@ namespace pub for (auto &[track_id, track] : GetStream()->GetTracks()) { - if (IsSupportTrack(track) == false) + // If the selected track list exists. if the current trackid does not exist on the list, ignore it. + // If no track list is selected, save all tracks. + if (IsSelectedTrack(track) == false) { - logtw("Could not supported track. track_id:%d, codec_id: %d", track->GetId(), track->GetCodecId()); continue; } - // If the selected track list exists. if the current trackid does not exist on the list, ignore it. - // If no track list is selected, save all tracks. - if (IsSelectedTrack(track) == false) + if (IsSupportTrack(GetPush()->GetProtocolType(), track) == false) { + logtd("Could not supported track. track_id:%d, codec_id: %d", track->GetId(), track->GetCodecId()); continue; } if (IsSupportCodec(GetPush()->GetProtocolType(), track->GetCodecId()) == false) { - logtw("Could not supported codec. track_id:%d, codec_id: %d", track->GetId(), track->GetCodecId()); - + logtd("Could not supported codec. track_id:%d, codec_id: %d", track->GetId(), track->GetCodecId()); continue; } @@ -264,14 +263,25 @@ namespace pub return true; } - bool PushSession::IsSupportTrack(const std::shared_ptr &track) + bool PushSession::IsSupportTrack(const info::Push::ProtocolType protocol_type, const std::shared_ptr &track) { - // If the track is not video, audio, or data, ignore it. - if (track->GetMediaType() == cmn::MediaType::Video || - track->GetMediaType() == cmn::MediaType::Audio || - track->GetMediaType() == cmn::MediaType::Data) + if (protocol_type == info::Push::ProtocolType::RTMP) { - return true; + if (track->GetMediaType() == cmn::MediaType::Video || + track->GetMediaType() == cmn::MediaType::Audio || + track->GetMediaType() == cmn::MediaType::Data) + { + return true; + } + } + else if (protocol_type == info::Push::ProtocolType::SRT || protocol_type == info::Push::ProtocolType::MPEGTS) + { + if (track->GetMediaType() == cmn::MediaType::Video || + track->GetMediaType() == cmn::MediaType::Audio) + // SRT and MPEGTS do not support data track. + { + return true; + } } return false; diff --git a/src/projects/publishers/push/push_session.h b/src/projects/publishers/push/push_session.h index 27a55fd02..0c9ca4625 100755 --- a/src/projects/publishers/push/push_session.h +++ b/src/projects/publishers/push/push_session.h @@ -45,7 +45,7 @@ namespace pub void DestoryWriter(); bool IsSelectedTrack(const std::shared_ptr &track); - bool IsSupportTrack(const std::shared_ptr &track); + bool IsSupportTrack(const info::Push::ProtocolType protocol_type, const std::shared_ptr &track); bool IsSupportCodec(const info::Push::ProtocolType protocol_type, cmn::MediaCodecId codec_id); std::shared_ptr _push = nullptr;