fork
Configure Feed
Select the types of activity you want to include in your feed.
Live video on the AT Protocol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1package media
2
3import (
4 "context"
5 "io"
6 "os"
7 "testing"
8 "time"
9
10 "github.com/stretchr/testify/require"
11 "golang.org/x/sync/errgroup"
12 "stream.place/streamplace/pkg/bus"
13)
14
15func TestPacketize(t *testing.T) {
16 withNoGSTLeaks(t, func() {
17 g, _ := errgroup.WithContext(context.Background())
18 for range streamplaceTestCount {
19 g.Go(func() error {
20 innerTestPacketize(t)
21 return nil
22 })
23 }
24 err := g.Wait()
25 require.NoError(t, err)
26 })
27}
28
29func innerTestPacketize(t *testing.T) {
30 filename := getFixture("sample-segment.mp4")
31 inputFile, err := os.Open(filename)
32 require.NoError(t, err)
33 defer inputFile.Close()
34
35 bs, err := io.ReadAll(inputFile)
36 require.NoError(t, err)
37
38 testSeg := &bus.Seg{
39 Data: bs,
40 Filepath: filename,
41 }
42
43 packet, err := Packetize(context.Background(), testSeg)
44 require.NoError(t, err)
45 require.NotNil(t, packet)
46 require.Equal(t, 49, len(packet.Video))
47 require.Equal(t, 40, len(packet.Audio))
48 require.Equal(t, time.Duration(800*time.Millisecond), packet.Duration)
49}