mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 23:56:54 +08:00
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/bluenviron/mediacommon](https://github.com/bluenviron/mediacommon) from 1.13.4-0.20250119173005-20b296ab1174 to 1.13.4. - [Commits](https://github.com/bluenviron/mediacommon/commits/v1.13.4) --- updated-dependencies: - dependency-name: github.com/bluenviron/mediacommon dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
package udp
|
|
|
|
import (
|
|
"bufio"
|
|
"net"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/bluenviron/mediacommon/pkg/formats/mpegts"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/bluenviron/mediamtx/internal/conf"
|
|
"github.com/bluenviron/mediamtx/internal/defs"
|
|
"github.com/bluenviron/mediamtx/internal/test"
|
|
)
|
|
|
|
func TestSource(t *testing.T) {
|
|
te := test.NewSourceTester(
|
|
func(p defs.StaticSourceParent) defs.StaticSource {
|
|
return &Source{
|
|
ReadTimeout: conf.Duration(10 * time.Second),
|
|
Parent: p,
|
|
}
|
|
},
|
|
"udp://127.0.0.1:9001",
|
|
&conf.Path{},
|
|
)
|
|
defer te.Close()
|
|
|
|
time.Sleep(50 * time.Millisecond)
|
|
|
|
conn, err := net.Dial("udp", "127.0.0.1:9001")
|
|
require.NoError(t, err)
|
|
defer conn.Close()
|
|
|
|
track := &mpegts.Track{
|
|
Codec: &mpegts.CodecH264{},
|
|
}
|
|
|
|
bw := bufio.NewWriter(conn)
|
|
w := mpegts.NewWriter(bw, []*mpegts.Track{track})
|
|
require.NoError(t, err)
|
|
|
|
err = w.WriteH2642(track, 0, 0, [][]byte{{ // IDR
|
|
5, 1,
|
|
}})
|
|
require.NoError(t, err)
|
|
|
|
err = w.WriteH2642(track, 0, 0, [][]byte{{ // non-IDR
|
|
5, 2,
|
|
}})
|
|
require.NoError(t, err)
|
|
|
|
err = bw.Flush()
|
|
require.NoError(t, err)
|
|
|
|
<-te.Unit
|
|
}
|