直播:后台 JWT 推流、前台画中画;WebRTC 服务与 Nginx WebSocket 代理

Made-with: Cursor
This commit is contained in:
whm
2026-03-25 15:00:14 +08:00
parent b83ec91b1a
commit 7811adca66
1050 changed files with 146524 additions and 37 deletions

View File

@@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
//go:build !js
// +build !js
package fakenet
import (
"net"
"time"
)
// MockPacketConn for tests
type MockPacketConn struct{}
func (m *MockPacketConn) ReadFrom([]byte) (n int, addr net.Addr, err error) { return 0, nil, nil } //nolint:revive
func (m *MockPacketConn) WriteTo([]byte, net.Addr) (n int, err error) { return 0, nil } //nolint:revive
func (m *MockPacketConn) Close() error { return nil } //nolint:revive
func (m *MockPacketConn) LocalAddr() net.Addr { return nil } //nolint:revive
func (m *MockPacketConn) SetDeadline(time.Time) error { return nil } //nolint:revive
func (m *MockPacketConn) SetReadDeadline(time.Time) error { return nil } //nolint:revive
func (m *MockPacketConn) SetWriteDeadline(time.Time) error { return nil } //nolint:revive

View File

@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
// Package fakenet contains fake network abstractions
package fakenet
import (
"net"
)
// Compile-time assertion
var _ net.PacketConn = (*PacketConn)(nil)
// PacketConn wraps a net.Conn and emulates net.PacketConn
type PacketConn struct {
net.Conn
}
// ReadFrom reads a packet from the connection,
func (f *PacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
n, err = f.Conn.Read(p)
addr = f.Conn.RemoteAddr()
return
}
// WriteTo writes a packet with payload p to addr.
func (f *PacketConn) WriteTo(p []byte, _ net.Addr) (int, error) {
return f.Conn.Write(p)
}