-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
warn users about skipped tracks when reading or publishing
- Loading branch information
Showing
27 changed files
with
584 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package hls | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/bluenviron/gohlslib" | ||
"github.com/bluenviron/gortsplib/v4/pkg/description" | ||
"github.com/bluenviron/gortsplib/v4/pkg/format" | ||
"github.com/bluenviron/mediamtx/internal/asyncwriter" | ||
"github.com/bluenviron/mediamtx/internal/logger" | ||
"github.com/bluenviron/mediamtx/internal/stream" | ||
"github.com/bluenviron/mediamtx/internal/test" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFromStreamNoSupportedCodecs(t *testing.T) { | ||
stream, err := stream.New( | ||
1460, | ||
&description.Session{Medias: []*description.Media{{ | ||
Type: description.MediaTypeVideo, | ||
Formats: []format.Format{&format.VP8{}}, | ||
}}}, | ||
true, | ||
test.NilLogger, | ||
) | ||
require.NoError(t, err) | ||
|
||
writer := asyncwriter.New(0, nil) | ||
|
||
l := test.Logger(func(logger.Level, string, ...interface{}) { | ||
t.Error("should not happen") | ||
}) | ||
|
||
err = FromStream(stream, writer, nil, l) | ||
require.Equal(t, ErrNoSupportedCodecs, err) | ||
} | ||
|
||
func TestFromStreamSkipUnsupportedTracks(t *testing.T) { | ||
stream, err := stream.New( | ||
1460, | ||
&description.Session{Medias: []*description.Media{ | ||
{ | ||
Type: description.MediaTypeVideo, | ||
Formats: []format.Format{&format.VP9{}}, | ||
}, | ||
{ | ||
Type: description.MediaTypeVideo, | ||
Formats: []format.Format{&format.VP8{}}, | ||
}, | ||
{ | ||
Type: description.MediaTypeAudio, | ||
Formats: []format.Format{&format.MPEG1Audio{}}, | ||
}, | ||
}}, | ||
true, | ||
test.NilLogger, | ||
) | ||
require.NoError(t, err) | ||
|
||
writer := asyncwriter.New(0, nil) | ||
|
||
m := &gohlslib.Muxer{} | ||
|
||
n := 0 | ||
|
||
l := test.Logger(func(l logger.Level, format string, args ...interface{}) { | ||
require.Equal(t, logger.Warn, l) | ||
switch n { | ||
case 0: | ||
require.Equal(t, "skipping track with codec VP8", fmt.Sprintf(format, args...)) | ||
case 1: | ||
require.Equal(t, "skipping track with codec MPEG-1/2 Audio", fmt.Sprintf(format, args...)) | ||
} | ||
n++ | ||
}) | ||
|
||
err = FromStream(stream, writer, m, l) | ||
require.NoError(t, err) | ||
require.Equal(t, 2, n) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package hls | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/bluenviron/gohlslib" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestToStreamNoSupportedCodecs(t *testing.T) { | ||
_, err := ToStream(nil, []*gohlslib.Track{}, nil) | ||
require.Equal(t, ErrNoSupportedCodecs, err) | ||
} | ||
|
||
// this is impossible to test since currently we support all gohlslib.Tracks. | ||
// func TestToStreamSkipUnsupportedTracks(t *testing.T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.