Skip to content

Commit c29783e

Browse files
authored
fix: llhls default playlist not created when first track has unsupported codec (#2033)
1 parent ad64c7a commit c29783e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/projects/publishers/llhls/llhls_stream.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,31 @@ bool LLHlsStream::Start()
166166
// Find data track
167167
auto data_track = GetFirstTrackByType(cmn::MediaType::Data);
168168

169+
// Find the first video track and audio track with supported codec, and set the reference track id for VTT track.
169170
std::shared_ptr<MediaTrack> first_video_track = nullptr, first_audio_track = nullptr;
170-
first_video_track = GetFirstTrackByType(cmn::MediaType::Video);
171-
first_audio_track = GetFirstTrackByType(cmn::MediaType::Audio);
171+
for (const auto &[id, track] : GetTracks())
172+
{
173+
if (IsSupportedMediaCodec(track->GetCodecId()) == true)
174+
{
175+
if (track->GetMediaType() == cmn::MediaType::Video && first_video_track == nullptr)
176+
{
177+
first_video_track = track;
178+
}
179+
else if (track->GetMediaType() == cmn::MediaType::Audio && first_audio_track == nullptr)
180+
{
181+
first_audio_track = track;
182+
}
183+
}
172184

185+
if (first_video_track != nullptr && first_audio_track != nullptr)
186+
{
187+
break;
188+
}
189+
}
173190
_vtt_reference_track_id = first_video_track ? first_video_track->GetId() : first_audio_track ? first_audio_track->GetId() : -1;
174-
for (const auto &[id, track] : _tracks)
191+
192+
// Add packager for each track
193+
for (const auto &[id, track] : GetTracks())
175194
{
176195
if (IsSupportedMediaCodec(track->GetCodecId()) == true)
177196
{

0 commit comments

Comments
 (0)