diff --git a/streamer.go b/streamer.go deleted file mode 100644 index 85f4ede..0000000 --- a/streamer.go +++ /dev/null @@ -1,48 +0,0 @@ -package mediaserver - -import ( - "sync" - - "github.com/notedit/sdp" -) - -// Streamer -type Streamer struct { - sessions map[string]*StreamerSession - sync.Mutex -} - -// NewStreamer create a streamer -func NewStreamer() *Streamer { - streamer := &Streamer{} - streamer.sessions = make(map[string]*StreamerSession) - return streamer -} - -// CreateSession -func (s *Streamer) CreateSession(local bool, ip string, port int, media *sdp.MediaInfo) *StreamerSession { - - session := NewStreamerSession(local, ip, port, media) - - s.Lock() - s.sessions[session.id] = session - s.Unlock() - - return session -} - -// RemoveSession remove a session -func (s *Streamer) RemoveSession(session *StreamerSession) { - s.Lock() - delete(s.sessions, session.id) - s.Unlock() -} - -// Stop stop all sessions -func (s *Streamer) Stop() { - - for _, session := range s.sessions { - session.Stop() - } - s.sessions = nil -} diff --git a/streamersession.go b/streamersession.go index e6260a4..1ab7739 100644 --- a/streamersession.go +++ b/streamersession.go @@ -23,7 +23,7 @@ type StreamerSession struct { } // NewStreamerSession new StreamerSession -func NewStreamerSession(local bool, ip string, port int, media *sdp.MediaInfo) *StreamerSession { +func NewStreamerSession(media *sdp.MediaInfo) *StreamerSession { streamerSession := &StreamerSession{} var mediaType native.MediaFrameType = 0 @@ -31,11 +31,6 @@ func NewStreamerSession(local bool, ip string, port int, media *sdp.MediaInfo) * mediaType = 1 } session := native.NewRTPSessionFacade(mediaType) - if local { - session.SetLocalPort(port) - } else { - session.SetRemotePort(ip, port) - } streamerSession.id = uuid.Must(uuid.NewV4()).String() @@ -75,6 +70,15 @@ func (s *StreamerSession) GetID() string { return s.id } +func (s *StreamerSession) SetLocalPort(port int) { + + s.session.SetLocalPort(port) +} + +func (s *StreamerSession) SetRemotePort(ip string, port int) { + s.session.SetRemotePort(ip, port) +} + // GetIncomingStreamTrack get asso incoming track, func (s *StreamerSession) GetIncomingStreamTrack() *IncomingStreamTrack { return s.incoming