mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
WebRTC SetVideoID.
This commit is contained in:
parent
aa7a131da2
commit
f62d36ac4f
@ -5,6 +5,7 @@ import "github.com/pion/webrtc/v3"
|
||||
type WebRTCPeer interface {
|
||||
SignalAnswer(sdp string) error
|
||||
SignalCandidate(candidate webrtc.ICECandidateInit) error
|
||||
SetVideoID(videoID string) error
|
||||
|
||||
Destroy() error
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session) (*webrtc.Sess
|
||||
})
|
||||
}
|
||||
|
||||
audioTransceiver, err := connection.AddTransceiverFromTrack(manager.audioTrack, webrtc.RtpTransceiverInit{
|
||||
_, err = connection.AddTransceiverFromTrack(manager.audioTrack, webrtc.RtpTransceiverInit{
|
||||
Direction: webrtc.RTPTransceiverDirectionSendonly,
|
||||
})
|
||||
if err != nil {
|
||||
@ -151,7 +151,8 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session) (*webrtc.Sess
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := connection.CreateDataChannel("data", nil); err != nil {
|
||||
_, err = connection.CreateDataChannel("data", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -206,7 +207,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session) (*webrtc.Sess
|
||||
settings: settings,
|
||||
connection: connection,
|
||||
configuration: configuration,
|
||||
audioTransceiver: audioTransceiver,
|
||||
videoTracks: manager.videoTracks,
|
||||
videoTransceiver: videoTransceiver,
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
package webrtc
|
||||
|
||||
import "github.com/pion/webrtc/v3"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pion/webrtc/v3"
|
||||
)
|
||||
|
||||
type WebRTCPeerCtx struct {
|
||||
api *webrtc.API
|
||||
@ -8,7 +12,7 @@ type WebRTCPeerCtx struct {
|
||||
settings *webrtc.SettingEngine
|
||||
connection *webrtc.PeerConnection
|
||||
configuration *webrtc.Configuration
|
||||
audioTransceiver *webrtc.RTPTransceiver
|
||||
videoTracks map[string]*webrtc.TrackLocalStaticSample
|
||||
videoTransceiver *webrtc.RTPTransceiver
|
||||
}
|
||||
|
||||
@ -23,11 +27,12 @@ func (webrtc_peer *WebRTCPeerCtx) SignalCandidate(candidate webrtc.ICECandidateI
|
||||
return webrtc_peer.connection.AddICECandidate(candidate)
|
||||
}
|
||||
|
||||
func (webrtc_peer *WebRTCPeerCtx) ReplaceAudioTrack(track webrtc.TrackLocal) error {
|
||||
return webrtc_peer.audioTransceiver.Sender().ReplaceTrack(track)
|
||||
}
|
||||
func (webrtc_peer *WebRTCPeerCtx) SetVideoID(videoID string) error {
|
||||
track, ok := webrtc_peer.videoTracks[videoID]
|
||||
if !ok {
|
||||
return fmt.Errorf("videoID not found in available tracks")
|
||||
}
|
||||
|
||||
func (webrtc_peer *WebRTCPeerCtx) ReplaceVideoTrack(track webrtc.TrackLocal) error {
|
||||
return webrtc_peer.videoTransceiver.Sender().ReplaceTrack(track)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user