fix
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m31s

This commit is contained in:
Smile Rex
2026-01-26 19:48:00 +03:00
parent 3630e22f20
commit 06a6b70467

18
peer.go
View File

@@ -2,7 +2,6 @@ package main
import ( import (
"encoding/json" "encoding/json"
"log"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
@@ -31,6 +30,21 @@ func NewPeer(conn *websocket.Conn, room *Room) *Peer {
panic(err) panic(err)
} }
// 🔥 ОБЯЗАТЕЛЬНО для SFU
_, _ = pc.AddTransceiverFromKind(
webrtc.RTPCodecTypeAudio,
webrtc.RTPTransceiverInit{
Direction: webrtc.RTPTransceiverDirectionSendrecv,
},
)
_, _ = pc.AddTransceiverFromKind(
webrtc.RTPCodecTypeVideo,
webrtc.RTPTransceiverInit{
Direction: webrtc.RTPTransceiverDirectionSendrecv,
},
)
p := &Peer{ p := &Peer{
ID: uuid.NewString(), ID: uuid.NewString(),
Conn: conn, Conn: conn,
@@ -47,8 +61,6 @@ func NewPeer(conn *websocket.Conn, room *Room) *Peer {
}) })
pc.OnTrack(func(remote *webrtc.TrackRemote, _ *webrtc.RTPReceiver) { pc.OnTrack(func(remote *webrtc.TrackRemote, _ *webrtc.RTPReceiver) {
log.Println("track received", remote.Kind())
local := NewTrack(remote) local := NewTrack(remote)
p.Room.mu.Lock() p.Room.mu.Lock()