From 4fb0e3e8ec94077fd00ccc2cd473cc6441db9caf Mon Sep 17 00:00:00 2001 From: notedit Date: Sun, 30 Jun 2019 22:14:36 +0800 Subject: [PATCH] remove raw rtp input Former-commit-id: 887c9f09f0f2e557506c3882bd8788e3833dffca [formerly aec82c41f6f35dfba62dbc88eb440d8e46cf9536] [formerly d14350caeee6c06bf3516ff9bb49ac1b2f51bac5 [formerly f950d1066ff03696e07c6d5958dae02c17112df3]] Former-commit-id: b422cfffcf42c112ff7902858b98ed74c8d5ea08 [formerly e7d26aa0135459850903cc35f4232fcae60b2aba] Former-commit-id: 249f649ad6f71c20628f82f75e673b854e8657bb --- rawstreamer.go | 48 ----------------------- rawstreamersession.go | 89 ------------------------------------------- 2 files changed, 137 deletions(-) delete mode 100644 rawstreamer.go delete mode 100644 rawstreamersession.go diff --git a/rawstreamer.go b/rawstreamer.go deleted file mode 100644 index 8baa129..0000000 --- a/rawstreamer.go +++ /dev/null @@ -1,48 +0,0 @@ -package mediaserver - -import ( - "sync" - - "github.com/notedit/sdp" -) - -// RawStreamer streamer that can send raw rtp data -type RawStreamer struct { - sessions map[string]*RawStreamerSession - sync.Mutex -} - -// NewRawStreamer create new raw rtp streamer -func NewRawStreamer() *RawStreamer { - streamer := &RawStreamer{} - streamer.sessions = make(map[string]*RawStreamerSession) - return streamer -} - -// CreateSession create a audio/media session -func (s *RawStreamer) CreateSession(media *sdp.MediaInfo) *RawStreamerSession { - - session := NewRawStreamerSession(media) - - s.Lock() - s.sessions[session.id] = session - s.Unlock() - - return session -} - -// RemoveSession remove a session -func (s *RawStreamer) RemoveSession(session *RawStreamerSession) { - s.Lock() - delete(s.sessions, session.id) - s.Unlock() -} - -// Stop stop this streamer -func (s *RawStreamer) Stop() { - - for _, session := range s.sessions { - session.Stop() - } - s.sessions = nil -} diff --git a/rawstreamersession.go b/rawstreamersession.go deleted file mode 100644 index 5f448f2..0000000 --- a/rawstreamersession.go +++ /dev/null @@ -1,89 +0,0 @@ -package mediaserver - -/* -#include -*/ -import "C" -import ( - "fmt" - "strings" - - "github.com/gofrs/uuid" - native "github.com/notedit/media-server-go/wrapper" - "github.com/notedit/sdp" -) - -type RawStreamerSession struct { - id string - incoming *IncomingStreamTrack - session native.RawRTPSessionFacade -} - -func NewRawStreamerSession(media *sdp.MediaInfo) *RawStreamerSession { - - streamerSession := &RawStreamerSession{} - var mediaType native.MediaFrameType = 0 - if strings.ToLower(media.GetType()) == "video" { - mediaType = 1 - } - session := native.NewRawRTPSessionFacade(mediaType) - streamerSession.id = uuid.Must(uuid.NewV4()).String() - - properties := native.NewProperties() - if media != nil { - num := 0 - for _, codec := range media.GetCodecs() { - item := fmt.Sprintf("codecs.%d", num) - properties.SetProperty(item+".codec", codec.GetCodec()) - properties.SetProperty(item+".pt", codec.GetType()) - if codec.HasRTX() { - properties.SetProperty(item+".rtx", codec.GetRTX()) - } - num = num + 1 - } - properties.SetProperty("codecs.length", num) - } - - session.Init(properties) - native.DeleteProperties(properties) - streamerSession.session = session - streamerSession.incoming = NewIncomingStreamTrack(media.GetType(), media.GetType(), native.RTPSessionToReceiver(session), map[string]native.RTPIncomingSourceGroup{"": session.GetIncomingSourceGroup()}) - - streamerSession.incoming.OnStop(func() { - streamerSession.incoming = nil - }) - - return streamerSession -} - -func (s *RawStreamerSession) GetID() string { - return s.id -} - -func (s *RawStreamerSession) GetIncomingStreamTrack() *IncomingStreamTrack { - return s.incoming -} - -func (s *RawStreamerSession) Push(rtp []byte) { - if rtp == nil || len(rtp) == 0 { - return - } - s.session.OnRTPPacket(&rtp[0], len(rtp)) -} - -func (s *RawStreamerSession) Stop() { - - if s.session == nil { - return - } - - if s.incoming != nil { - s.incoming.Stop() - } - - s.session.End() - - native.DeleteRawRTPSessionFacade(s.session) - - s.session = nil -}