hls, webrtc: add FromStream / ToStream (#3752)
Some checks failed
code_lint / golangci_lint (push) Has been cancelled
code_lint / mod_tidy (push) Has been cancelled
code_lint / api_docs (push) Has been cancelled
code_test / test_64 (push) Has been cancelled
code_test / test_32 (push) Has been cancelled
code_test / test_highlevel (push) Has been cancelled

This commit is contained in:
Alessandro Ros 2024-09-09 12:59:23 +02:00 committed by GitHub
parent 7b01f48d40
commit 6a38c87a5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 1776 additions and 1689 deletions

View file

@ -0,0 +1,45 @@
package webrtc
import (
"testing"
"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/stream"
"github.com/bluenviron/mediamtx/internal/test"
"github.com/stretchr/testify/require"
)
func TestFromStream(t *testing.T) {
for _, ca := range toFromStreamCases {
if ca.in == nil {
continue
}
t.Run(ca.name, func(t *testing.T) {
desc := &description.Session{
Medias: []*description.Media{{
Formats: []format.Format{ca.in},
}},
}
stream, err := stream.New(
1460,
desc,
false,
test.NilLogger,
)
require.NoError(t, err)
defer stream.Close()
writer := asyncwriter.New(0, nil)
pc := &PeerConnection{}
err = FromStream(stream, writer, pc)
require.NoError(t, err)
require.Equal(t, ca.webrtcCaps, pc.OutgoingTracks[0].Caps)
})
}
}