Skip to content

Commit

Permalink
Improved checking of supported media tracks (Type) by protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Keukhan committed Dec 24, 2024
1 parent b1b68b1 commit b1c1a02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
36 changes: 23 additions & 13 deletions src/projects/publishers/push/push_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -264,14 +263,25 @@ namespace pub
return true;
}

bool PushSession::IsSupportTrack(const std::shared_ptr<MediaTrack> &track)
bool PushSession::IsSupportTrack(const info::Push::ProtocolType protocol_type, const std::shared_ptr<MediaTrack> &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;
Expand Down
2 changes: 1 addition & 1 deletion src/projects/publishers/push/push_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace pub
void DestoryWriter();

bool IsSelectedTrack(const std::shared_ptr<MediaTrack> &track);
bool IsSupportTrack(const std::shared_ptr<MediaTrack> &track);
bool IsSupportTrack(const info::Push::ProtocolType protocol_type, const std::shared_ptr<MediaTrack> &track);
bool IsSupportCodec(const info::Push::ProtocolType protocol_type, cmn::MediaCodecId codec_id);

std::shared_ptr<info::Push> _push = nullptr;
Expand Down

0 comments on commit b1c1a02

Please sign in to comment.