Skip to content

Commit

Permalink
Use supported tracks where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Jan 10, 2025
1 parent 8ef8263 commit 3ac04fd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions client_stream_processor_mpegts.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,26 @@ func (p *clientStreamProcessorMPEGTS) initializeReader(ctx context.Context, firs
p.onDecodeError(err)
})

var supportedTracks []*mpegts.Track

for _, track := range p.reader.Tracks() {
switch track.Codec.(type) {
case *mpegts.CodecH264, *mpegts.CodecMPEG4Audio:
supportedTracks = append(supportedTracks, track)
default:
return fmt.Errorf("unsupported track type: %T", track)
err = fmt.Errorf("Fuck unsupported track type: %T", track)
}
}

leadingTrackID := mpegtsPickLeadingTrack(p.reader.Tracks())
if len(supportedTracks) == 0 && err != nil {
return err
}

leadingTrackID := mpegtsPickLeadingTrack(supportedTracks)

tracks := make([]*Track, len(p.reader.Tracks()))
tracks := make([]*Track, len(supportedTracks))

for i, mpegtsTrack := range p.reader.Tracks() {
for i, mpegtsTrack := range supportedTracks {
tracks[i] = &Track{
Codec: codecs.FromMPEGTS(mpegtsTrack.Codec),
ClockRate: 90000,
Expand All @@ -179,7 +186,7 @@ func (p *clientStreamProcessorMPEGTS) initializeReader(ctx context.Context, firs
return fmt.Errorf("terminated")
}

for i, mpegtsTrack := range p.reader.Tracks() {
for i, mpegtsTrack := range supportedTracks {
track := p.clientStreamTracks[i]
isLeadingTrack := (i == leadingTrackID)
var trackProc *clientTrackProcessorMPEGTS
Expand Down

0 comments on commit 3ac04fd

Please sign in to comment.