From 0245c73e2b8b2b4ca2bcf8940c1451c5e270618c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Fri, 1 Oct 2021 00:02:54 +0200 Subject: [PATCH] rename to PeerStreamTrack. --- internal/webrtc/manager.go | 4 ++-- .../webrtc/{peertrack.go => peerstreamtrack.go} | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) rename internal/webrtc/{peertrack.go => peerstreamtrack.go} (81%) diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index 04e9b7a7..f410bb4a 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -113,7 +113,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin // audio track - audioTrack, err := manager.newPeerTrack(audioStream, logger) + audioTrack, err := manager.newPeerStreamTrack(audioStream, logger) if err != nil { return nil, err } @@ -125,7 +125,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin // video track - videoTrack, err := manager.newPeerTrack(videoStream, logger) + videoTrack, err := manager.newPeerStreamTrack(videoStream, logger) if err != nil { return nil, err } diff --git a/internal/webrtc/peertrack.go b/internal/webrtc/peerstreamtrack.go similarity index 81% rename from internal/webrtc/peertrack.go rename to internal/webrtc/peerstreamtrack.go index 597181fa..7e9e7296 100644 --- a/internal/webrtc/peertrack.go +++ b/internal/webrtc/peerstreamtrack.go @@ -11,7 +11,7 @@ import ( "github.com/rs/zerolog" ) -func (manager *WebRTCManagerCtx) newPeerTrack(stream types.StreamManager, logger zerolog.Logger) (*PeerTrack, error) { +func (manager *WebRTCManagerCtx) newPeerStreamTrack(stream types.StreamManager, logger zerolog.Logger) (*PeerStreamTrack, error) { codec := stream.Codec() id := codec.Type.String() @@ -22,7 +22,7 @@ func (manager *WebRTCManagerCtx) newPeerTrack(stream types.StreamManager, logger logger = logger.With().Str("id", id).Logger() - peer := &PeerTrack{ + peer := &PeerStreamTrack{ logger: logger, track: track, listener: func(sample types.Sample) { @@ -35,19 +35,18 @@ func (manager *WebRTCManagerCtx) newPeerTrack(stream types.StreamManager, logger peer.SetStream(stream) return peer, nil - } -type PeerTrack struct { +type PeerStreamTrack struct { logger zerolog.Logger track *webrtc.TrackLocalStaticSample listener func(sample types.Sample) - streamMu sync.Mutex stream types.StreamManager + streamMu sync.Mutex } -func (peer *PeerTrack) SetStream(stream types.StreamManager) error { +func (peer *PeerStreamTrack) SetStream(stream types.StreamManager) error { peer.streamMu.Lock() defer peer.streamMu.Unlock() @@ -75,7 +74,7 @@ func (peer *PeerTrack) SetStream(stream types.StreamManager) error { return nil } -func (peer *PeerTrack) RemoveStream() { +func (peer *PeerStreamTrack) RemoveStream() { peer.streamMu.Lock() defer peer.streamMu.Unlock() @@ -85,7 +84,7 @@ func (peer *PeerTrack) RemoveStream() { } } -func (peer *PeerTrack) AddToConnection(connection *webrtc.PeerConnection) error { +func (peer *PeerStreamTrack) AddToConnection(connection *webrtc.PeerConnection) error { sender, err := connection.AddTrack(peer.track) if err != nil { return err