mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add Video error return.
This commit is contained in:
parent
f62d36ac4f
commit
761f6d8a8f
@ -168,8 +168,9 @@ func (manager *CaptureManagerCtx) Audio() types.StreamManager {
|
||||
return manager.audio
|
||||
}
|
||||
|
||||
func (manager *CaptureManagerCtx) Video(videoID string) types.StreamManager {
|
||||
return manager.videos[videoID]
|
||||
func (manager *CaptureManagerCtx) Video(videoID string) (types.StreamManager, bool) {
|
||||
video, ok := manager.videos[videoID]
|
||||
return video, ok
|
||||
}
|
||||
|
||||
func (manager *CaptureManagerCtx) VideoIDs() []string {
|
||||
|
@ -37,7 +37,7 @@ type CaptureManager interface {
|
||||
Broadcast() BroadcastManager
|
||||
Screencast() ScreencastManager
|
||||
Audio() StreamManager
|
||||
Video(videoID string) StreamManager
|
||||
Video(videoID string) (StreamManager, bool)
|
||||
VideoIDs() []string
|
||||
|
||||
StartStream()
|
||||
|
@ -57,7 +57,11 @@ func (manager *WebRTCManagerCtx) Start() {
|
||||
videoIDs := manager.capture.VideoIDs()
|
||||
manager.videoTracks = map[string]*webrtc.TrackLocalStaticSample{}
|
||||
for _, videoID := range videoIDs {
|
||||
video := manager.capture.Video(videoID)
|
||||
video, ok := manager.capture.Video(videoID)
|
||||
if !ok {
|
||||
manager.logger.Warn().Str("videoID", videoID).Msg("video stream not found, skipping")
|
||||
continue
|
||||
}
|
||||
|
||||
track, err := webrtc.NewTrackLocalStaticSample(video.Codec().Capability, "video", "stream")
|
||||
if err != nil {
|
||||
@ -218,7 +222,12 @@ func (manager *WebRTCManagerCtx) mediaEngine() (*webrtc.MediaEngine, error) {
|
||||
engine := &webrtc.MediaEngine{}
|
||||
|
||||
// all videos must have the same codec
|
||||
videoCodec := manager.capture.Video(manager.defaultVideoID).Codec()
|
||||
video, ok := manager.capture.Video(manager.defaultVideoID)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("default video track not found")
|
||||
}
|
||||
|
||||
videoCodec := video.Codec()
|
||||
if err := videoCodec.Register(engine); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user