put protocol before entities
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package converterhls
|
||||
package hlsconverter
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -119,7 +119,7 @@ type PathMan interface {
|
||||
OnReadPublisherSetupPlay(readpublisher.SetupPlayReq)
|
||||
}
|
||||
|
||||
// Parent is implemented by serverhls.Server.
|
||||
// Parent is implemented by hlsserver.Server.
|
||||
type Parent interface {
|
||||
Log(logger.Level, string, ...interface{})
|
||||
OnConverterClose(*Converter)
|
||||
@@ -594,7 +594,7 @@ func (c *Converter) runRequestHandler(terminate chan struct{}, done chan struct{
|
||||
}
|
||||
}
|
||||
|
||||
// OnRequest is called by serverhls.Server.
|
||||
// OnRequest is called by hlsserver.Server.
|
||||
func (c *Converter) OnRequest(req Request) {
|
||||
c.request <- req
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package converterhls
|
||||
package hlsconverter
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package converterhls
|
||||
package hlsconverter
|
||||
|
||||
import (
|
||||
"io"
|
||||
@@ -1,4 +1,4 @@
|
||||
package converterhls
|
||||
package hlsconverter
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package serverhls
|
||||
package hlsserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/converterhls"
|
||||
"github.com/aler9/rtsp-simple-server/internal/hlsconverter"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
@@ -31,11 +31,11 @@ type Server struct {
|
||||
|
||||
ln net.Listener
|
||||
wg sync.WaitGroup
|
||||
converters map[string]*converterhls.Converter
|
||||
converters map[string]*hlsconverter.Converter
|
||||
|
||||
// in
|
||||
request chan converterhls.Request
|
||||
connClose chan *converterhls.Converter
|
||||
request chan hlsconverter.Request
|
||||
connClose chan *hlsconverter.Converter
|
||||
terminate chan struct{}
|
||||
|
||||
// out
|
||||
@@ -66,9 +66,9 @@ func New(
|
||||
pathMan: pathMan,
|
||||
parent: parent,
|
||||
ln: ln,
|
||||
converters: make(map[string]*converterhls.Converter),
|
||||
request: make(chan converterhls.Request),
|
||||
connClose: make(chan *converterhls.Converter),
|
||||
converters: make(map[string]*hlsconverter.Converter),
|
||||
request: make(chan hlsconverter.Request),
|
||||
connClose: make(chan *hlsconverter.Converter),
|
||||
terminate: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
@@ -103,7 +103,7 @@ outer:
|
||||
case req := <-s.request:
|
||||
c, ok := s.converters[req.Path]
|
||||
if !ok {
|
||||
c = converterhls.New(
|
||||
c = hlsconverter.New(
|
||||
s.hlsSegmentCount,
|
||||
s.hlsSegmentDuration,
|
||||
s.readBufferCount,
|
||||
@@ -174,7 +174,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
cres := make(chan io.Reader)
|
||||
s.request <- converterhls.Request{
|
||||
s.request <- hlsconverter.Request{
|
||||
Path: parts[0],
|
||||
Subpath: parts[1],
|
||||
Req: r,
|
||||
@@ -201,12 +201,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) doConverterClose(c *converterhls.Converter) {
|
||||
func (s *Server) doConverterClose(c *hlsconverter.Converter) {
|
||||
delete(s.converters, c.PathName())
|
||||
c.ParentClose()
|
||||
}
|
||||
|
||||
// OnConverterClose is called by converterhls.Converter.
|
||||
func (s *Server) OnConverterClose(c *converterhls.Converter) {
|
||||
// OnConverterClose is called by hlsconverter.Converter.
|
||||
func (s *Server) OnConverterClose(c *hlsconverter.Converter) {
|
||||
s.connClose <- c
|
||||
}
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/readpublisher"
|
||||
"github.com/aler9/rtsp-simple-server/internal/source"
|
||||
"github.com/aler9/rtsp-simple-server/internal/sourcertmp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/sourcertsp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpsource"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspsource"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
"github.com/aler9/rtsp-simple-server/internal/streamproc"
|
||||
)
|
||||
@@ -403,7 +403,7 @@ func (pa *Path) hasExternalSource() bool {
|
||||
func (pa *Path) startExternalSource() {
|
||||
if strings.HasPrefix(pa.conf.Source, "rtsp://") ||
|
||||
strings.HasPrefix(pa.conf.Source, "rtsps://") {
|
||||
pa.source = sourcertsp.New(
|
||||
pa.source = rtspsource.New(
|
||||
pa.conf.Source,
|
||||
pa.conf.SourceProtocolParsed,
|
||||
pa.conf.SourceFingerprint,
|
||||
@@ -416,7 +416,7 @@ func (pa *Path) startExternalSource() {
|
||||
pa)
|
||||
|
||||
} else if strings.HasPrefix(pa.conf.Source, "rtmp://") {
|
||||
pa.source = sourcertmp.New(
|
||||
pa.source = rtmpsource.New(
|
||||
pa.conf.Source,
|
||||
pa.readTimeout,
|
||||
pa.writeTimeout,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package connrtmp
|
||||
package rtmpconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -54,7 +54,7 @@ type PathMan interface {
|
||||
OnReadPublisherAnnounce(readpublisher.AnnounceReq)
|
||||
}
|
||||
|
||||
// Parent is implemented by serverrtmp.Server.
|
||||
// Parent is implemented by rtmpserver.Server.
|
||||
type Parent interface {
|
||||
Log(logger.Level, string, ...interface{})
|
||||
OnConnClose(*Conn)
|
||||
@@ -1,11 +1,11 @@
|
||||
package serverrtmp
|
||||
package rtmpserver
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/connrtmp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
@@ -30,10 +30,10 @@ type Server struct {
|
||||
|
||||
l net.Listener
|
||||
wg sync.WaitGroup
|
||||
conns map[*connrtmp.Conn]struct{}
|
||||
conns map[*rtmpconn.Conn]struct{}
|
||||
|
||||
// in
|
||||
connClose chan *connrtmp.Conn
|
||||
connClose chan *rtmpconn.Conn
|
||||
terminate chan struct{}
|
||||
|
||||
// out
|
||||
@@ -69,8 +69,8 @@ func New(
|
||||
pathMan: pathMan,
|
||||
parent: parent,
|
||||
l: l,
|
||||
conns: make(map[*connrtmp.Conn]struct{}),
|
||||
connClose: make(chan *connrtmp.Conn),
|
||||
conns: make(map[*rtmpconn.Conn]struct{}),
|
||||
connClose: make(chan *rtmpconn.Conn),
|
||||
terminate: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
@@ -121,7 +121,7 @@ outer:
|
||||
break outer
|
||||
|
||||
case nconn := <-connNew:
|
||||
c := connrtmp.New(
|
||||
c := rtmpconn.New(
|
||||
s.rtspAddress,
|
||||
s.readTimeout,
|
||||
s.writeTimeout,
|
||||
@@ -181,13 +181,13 @@ outer:
|
||||
close(s.connClose)
|
||||
}
|
||||
|
||||
func (s *Server) doConnClose(c *connrtmp.Conn) {
|
||||
func (s *Server) doConnClose(c *rtmpconn.Conn) {
|
||||
delete(s.conns, c)
|
||||
c.ParentClose()
|
||||
c.Close()
|
||||
}
|
||||
|
||||
// OnConnClose is called by connrtmp.Conn.
|
||||
func (s *Server) OnConnClose(c *connrtmp.Conn) {
|
||||
// OnConnClose is called by rtmpconn.Conn.
|
||||
func (s *Server) OnConnClose(c *rtmpconn.Conn) {
|
||||
s.connClose <- c
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package sourcertmp
|
||||
package rtmpsource
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package connrtsp
|
||||
package rtspconn
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -37,7 +37,7 @@ type PathMan interface {
|
||||
OnReadPublisherDescribe(readpublisher.DescribeReq)
|
||||
}
|
||||
|
||||
// Parent is implemented by serverrtsp.Server.
|
||||
// Parent is implemented by rtspserver.Server.
|
||||
type Parent interface {
|
||||
Log(logger.Level, string, ...interface{})
|
||||
}
|
||||
@@ -121,17 +121,17 @@ func (c *Conn) ip() net.IP {
|
||||
return c.conn.NetConn().RemoteAddr().(*net.TCPAddr).IP
|
||||
}
|
||||
|
||||
// OnRequest is called by serverrtsp.Server.
|
||||
// OnRequest is called by rtspserver.Server.
|
||||
func (c *Conn) OnRequest(req *base.Request) {
|
||||
c.log(logger.Debug, "[c->s] %v", req)
|
||||
}
|
||||
|
||||
// OnResponse is called by serverrtsp.Server.
|
||||
// OnResponse is called by rtspserver.Server.
|
||||
func (c *Conn) OnResponse(res *base.Response) {
|
||||
c.log(logger.Debug, "[s->c] %v", res)
|
||||
}
|
||||
|
||||
// OnDescribe is called by serverrtsp.Server.
|
||||
// OnDescribe is called by rtspserver.Server.
|
||||
func (c *Conn) OnDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, []byte, error) {
|
||||
resc := make(chan readpublisher.DescribeRes)
|
||||
c.pathMan.OnReadPublisherDescribe(readpublisher.DescribeReq{
|
||||
@@ -1,4 +1,4 @@
|
||||
package serverrtsp
|
||||
package rtspserver
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/connrtsp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/sessionrtsp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspsession"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
)
|
||||
|
||||
func newSessionVisualID(sessions map[*gortsplib.ServerSession]*sessionrtsp.Session) (string, error) {
|
||||
func newSessionVisualID(sessions map[*gortsplib.ServerSession]*rtspsession.Session) (string, error) {
|
||||
for {
|
||||
b := make([]byte, 4)
|
||||
_, err := rand.Read(b)
|
||||
@@ -61,8 +61,8 @@ type Server struct {
|
||||
|
||||
srv *gortsplib.Server
|
||||
mutex sync.RWMutex
|
||||
conns map[*gortsplib.ServerConn]*connrtsp.Conn
|
||||
sessions map[*gortsplib.ServerSession]*sessionrtsp.Session
|
||||
conns map[*gortsplib.ServerConn]*rtspconn.Conn
|
||||
sessions map[*gortsplib.ServerSession]*rtspsession.Session
|
||||
|
||||
// in
|
||||
terminate chan struct{}
|
||||
@@ -100,8 +100,8 @@ func New(
|
||||
stats: stats,
|
||||
pathMan: pathMan,
|
||||
parent: parent,
|
||||
conns: make(map[*gortsplib.ServerConn]*connrtsp.Conn),
|
||||
sessions: make(map[*gortsplib.ServerSession]*sessionrtsp.Session),
|
||||
conns: make(map[*gortsplib.ServerConn]*rtspconn.Conn),
|
||||
sessions: make(map[*gortsplib.ServerSession]*rtspsession.Session),
|
||||
terminate: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
@@ -199,7 +199,7 @@ outer:
|
||||
|
||||
// OnConnOpen implements gortsplib.ServerHandlerOnConnOpen.
|
||||
func (s *Server) OnConnOpen(ctx *gortsplib.ServerHandlerOnConnOpenCtx) {
|
||||
c := connrtsp.New(
|
||||
c := rtspconn.New(
|
||||
s.rtspAddress,
|
||||
s.readTimeout,
|
||||
s.runOnConnect,
|
||||
@@ -250,7 +250,7 @@ func (s *Server) OnSessionOpen(ctx *gortsplib.ServerHandlerOnSessionOpenCtx) {
|
||||
// use a new random ID
|
||||
visualID, _ := newSessionVisualID(s.sessions)
|
||||
|
||||
se := sessionrtsp.New(
|
||||
se := rtspsession.New(
|
||||
s.rtspAddress,
|
||||
s.protocols,
|
||||
visualID,
|
||||
@@ -1,4 +1,4 @@
|
||||
package sessionrtsp
|
||||
package rtspsession
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/connrtsp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspconn"
|
||||
"github.com/aler9/rtsp-simple-server/internal/externalcmd"
|
||||
"github.com/aler9/rtsp-simple-server/internal/logger"
|
||||
"github.com/aler9/rtsp-simple-server/internal/readpublisher"
|
||||
@@ -30,7 +30,7 @@ type PathMan interface {
|
||||
OnReadPublisherAnnounce(readpublisher.AnnounceReq)
|
||||
}
|
||||
|
||||
// Parent is implemented by serverrtsp.Server.
|
||||
// Parent is implemented by rtspserver.Server.
|
||||
type Parent interface {
|
||||
Log(logger.Level, string, ...interface{})
|
||||
}
|
||||
@@ -119,8 +119,8 @@ func (s *Session) log(level logger.Level, format string, args ...interface{}) {
|
||||
s.parent.Log(level, "[session %s] "+format, append([]interface{}{s.visualID}, args...)...)
|
||||
}
|
||||
|
||||
// OnAnnounce is called by serverrtsp.Server.
|
||||
func (s *Session) OnAnnounce(c *connrtsp.Conn, ctx *gortsplib.ServerHandlerOnAnnounceCtx) (*base.Response, error) {
|
||||
// OnAnnounce is called by rtspserver.Server.
|
||||
func (s *Session) OnAnnounce(c *rtspconn.Conn, ctx *gortsplib.ServerHandlerOnAnnounceCtx) (*base.Response, error) {
|
||||
resc := make(chan readpublisher.AnnounceRes)
|
||||
s.pathMan.OnReadPublisherAnnounce(readpublisher.AnnounceReq{
|
||||
Author: s,
|
||||
@@ -159,8 +159,8 @@ func (s *Session) OnAnnounce(c *connrtsp.Conn, ctx *gortsplib.ServerHandlerOnAnn
|
||||
}, nil
|
||||
}
|
||||
|
||||
// OnSetup is called by serverrtsp.Server.
|
||||
func (s *Session) OnSetup(c *connrtsp.Conn, ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, error) {
|
||||
// OnSetup is called by rtspserver.Server.
|
||||
func (s *Session) OnSetup(c *rtspconn.Conn, ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, error) {
|
||||
if ctx.Transport.Protocol == gortsplib.StreamProtocolUDP {
|
||||
if _, ok := s.protocols[gortsplib.StreamProtocolUDP]; !ok {
|
||||
return &base.Response{
|
||||
@@ -232,7 +232,7 @@ func (s *Session) OnSetup(c *connrtsp.Conn, ctx *gortsplib.ServerHandlerOnSetupC
|
||||
}, nil
|
||||
}
|
||||
|
||||
// OnPlay is called by serverrtsp.Server.
|
||||
// OnPlay is called by rtspserver.Server.
|
||||
func (s *Session) OnPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) {
|
||||
h := make(base.Header)
|
||||
|
||||
@@ -309,7 +309,7 @@ func (s *Session) OnPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// OnRecord is called by serverrtsp.Server.
|
||||
// OnRecord is called by rtspserver.Server.
|
||||
func (s *Session) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base.Response, error) {
|
||||
if ctx.Path != s.path.Name() {
|
||||
return &base.Response{
|
||||
@@ -355,7 +355,7 @@ func (s *Session) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base.Respo
|
||||
}, nil
|
||||
}
|
||||
|
||||
// OnPause is called by serverrtsp.Server.
|
||||
// OnPause is called by rtspserver.Server.
|
||||
func (s *Session) OnPause(ctx *gortsplib.ServerHandlerOnPauseCtx) (*base.Response, error) {
|
||||
switch s.ss.State() {
|
||||
case gortsplib.ServerSessionStatePlay:
|
||||
@@ -391,7 +391,7 @@ func (s *Session) OnFrame(trackID int, streamType gortsplib.StreamType, payload
|
||||
s.ss.WriteFrame(trackID, streamType, payload)
|
||||
}
|
||||
|
||||
// OnIncomingFrame is called by serverrtsp.Server.
|
||||
// OnIncomingFrame is called by rtspserver.Server.
|
||||
func (s *Session) OnIncomingFrame(ctx *gortsplib.ServerHandlerOnFrameCtx) {
|
||||
if s.ss.State() != gortsplib.ServerSessionStateRecord {
|
||||
return
|
||||
@@ -1,4 +1,4 @@
|
||||
package sourcertsp
|
||||
package rtspsource
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pprof"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rlimit"
|
||||
"github.com/aler9/rtsp-simple-server/internal/serverhls"
|
||||
"github.com/aler9/rtsp-simple-server/internal/serverrtmp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/serverrtsp"
|
||||
"github.com/aler9/rtsp-simple-server/internal/hlsserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmpserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtspserver"
|
||||
"github.com/aler9/rtsp-simple-server/internal/stats"
|
||||
)
|
||||
|
||||
@@ -33,10 +33,10 @@ type program struct {
|
||||
metrics *metrics.Metrics
|
||||
pprof *pprof.PPROF
|
||||
pathMan *pathman.PathManager
|
||||
serverRTSPPlain *serverrtsp.Server
|
||||
serverRTSPTLS *serverrtsp.Server
|
||||
serverRTMP *serverrtmp.Server
|
||||
serverHLS *serverhls.Server
|
||||
serverRTSPPlain *rtspserver.Server
|
||||
serverRTSPTLS *rtspserver.Server
|
||||
serverRTMP *rtmpserver.Server
|
||||
serverHLS *hlsserver.Server
|
||||
confWatcher *confwatcher.ConfWatcher
|
||||
|
||||
terminate chan struct{}
|
||||
@@ -206,7 +206,7 @@ func (p *program) createResources(initial bool) error {
|
||||
p.conf.EncryptionParsed == conf.EncryptionOptional) {
|
||||
if p.serverRTSPPlain == nil {
|
||||
_, useUDP := p.conf.ProtocolsParsed[gortsplib.StreamProtocolUDP]
|
||||
p.serverRTSPPlain, err = serverrtsp.New(
|
||||
p.serverRTSPPlain, err = rtspserver.New(
|
||||
p.conf.RTSPAddress,
|
||||
p.conf.ReadTimeout,
|
||||
p.conf.WriteTimeout,
|
||||
@@ -235,7 +235,7 @@ func (p *program) createResources(initial bool) error {
|
||||
(p.conf.EncryptionParsed == conf.EncryptionStrict ||
|
||||
p.conf.EncryptionParsed == conf.EncryptionOptional) {
|
||||
if p.serverRTSPTLS == nil {
|
||||
p.serverRTSPTLS, err = serverrtsp.New(
|
||||
p.serverRTSPTLS, err = rtspserver.New(
|
||||
p.conf.RTSPSAddress,
|
||||
p.conf.ReadTimeout,
|
||||
p.conf.WriteTimeout,
|
||||
@@ -262,7 +262,7 @@ func (p *program) createResources(initial bool) error {
|
||||
|
||||
if !p.conf.RTMPDisable {
|
||||
if p.serverRTMP == nil {
|
||||
p.serverRTMP, err = serverrtmp.New(
|
||||
p.serverRTMP, err = rtmpserver.New(
|
||||
p.conf.RTMPAddress,
|
||||
p.conf.ReadTimeout,
|
||||
p.conf.WriteTimeout,
|
||||
@@ -281,7 +281,7 @@ func (p *program) createResources(initial bool) error {
|
||||
|
||||
if !p.conf.HLSDisable {
|
||||
if p.serverHLS == nil {
|
||||
p.serverHLS, err = serverhls.New(
|
||||
p.serverHLS, err = hlsserver.New(
|
||||
p.conf.HLSAddress,
|
||||
p.conf.HLSSegmentCount,
|
||||
p.conf.HLSSegmentDuration,
|
||||
|
||||
Reference in New Issue
Block a user