mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
rename to PeerStreamTrack.
This commit is contained in:
parent
c9c8cc67ca
commit
0245c73e2b
@ -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
|
||||
}
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user