Files
upstream-pion-webrtc/ortc_media_test.go
upstream-mirror 8acb1a3a29
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 20:06:07 +05:00

69 lines
1.7 KiB
Go

// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
//go:build !js
package webrtc
import (
"context"
"testing"
"time"
"github.com/pion/transport/v4/test"
"github.com/pion/webrtc/v4/pkg/media"
"github.com/stretchr/testify/assert"
)
func Test_ORTC_Media(t *testing.T) {
lim := test.TimeOut(time.Second * 20)
defer lim.Stop()
report := test.CheckRoutines(t)
defer report()
stackA, stackB, err := newORTCPair()
assert.NoError(t, err)
assert.NoError(t, signalORTCPair(stackA, stackB))
track, err := NewTrackLocalStaticSample(RTPCodecCapability{MimeType: MimeTypeVP8}, "video", "pion")
assert.NoError(t, err)
rtpSender, err := stackA.api.NewRTPSender(track, stackA.dtls)
assert.NoError(t, err)
assert.NoError(t, rtpSender.Send(rtpSender.GetParameters()))
rtpReceiver, err := stackB.api.NewRTPReceiver(RTPCodecTypeVideo, stackB.dtls)
assert.NoError(t, err)
assert.NoError(t, rtpReceiver.Receive(RTPReceiveParameters{Encodings: []RTPDecodingParameters{
{RTPCodingParameters: rtpSender.GetParameters().Encodings[0].RTPCodingParameters},
}}))
seenPacket, seenPacketCancel := context.WithCancel(context.Background())
go func() {
track := rtpReceiver.Track()
_, _, err := track.ReadRTP()
assert.NoError(t, err)
seenPacketCancel()
}()
func() {
for range time.Tick(time.Millisecond * 20) {
select {
case <-seenPacket.Done():
return
default:
assert.NoError(t, track.WriteSample(media.Sample{Data: []byte{0xAA}, Duration: time.Second}))
}
}
}()
assert.NoError(t, rtpSender.Stop())
assert.NoError(t, rtpReceiver.Stop())
assert.NoError(t, stackA.close())
assert.NoError(t, stackB.close())
}