2023-10-31 13:19:04 +00:00
|
|
|
package defs
|
|
|
|
|
|
|
|
import (
|
2023-12-08 18:17:17 +00:00
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/bluenviron/gortsplib/v4/pkg/base"
|
2023-10-31 13:19:04 +00:00
|
|
|
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
2023-12-08 18:17:17 +00:00
|
|
|
"github.com/google/uuid"
|
2023-10-31 13:19:04 +00:00
|
|
|
|
2023-12-08 18:17:17 +00:00
|
|
|
"github.com/bluenviron/mediamtx/internal/conf"
|
|
|
|
"github.com/bluenviron/mediamtx/internal/externalcmd"
|
2023-10-31 13:19:04 +00:00
|
|
|
"github.com/bluenviron/mediamtx/internal/stream"
|
|
|
|
)
|
|
|
|
|
2024-01-03 20:13:20 +00:00
|
|
|
// PathNoOnePublishingError is returned when no one is publishing.
|
|
|
|
type PathNoOnePublishingError struct {
|
2023-12-08 18:17:17 +00:00
|
|
|
PathName string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error implements the error interface.
|
2024-01-03 20:13:20 +00:00
|
|
|
func (e PathNoOnePublishingError) Error() string {
|
2023-12-08 18:17:17 +00:00
|
|
|
return fmt.Sprintf("no one is publishing to path '%s'", e.PathName)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Path is a path.
|
|
|
|
type Path interface {
|
|
|
|
Name() string
|
|
|
|
SafeConf() *conf.Path
|
|
|
|
ExternalCmdEnv() externalcmd.Environment
|
|
|
|
StartPublisher(req PathStartPublisherReq) PathStartPublisherRes
|
|
|
|
StopPublisher(req PathStopPublisherReq)
|
|
|
|
RemovePublisher(req PathRemovePublisherReq)
|
|
|
|
RemoveReader(req PathRemoveReaderReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathAccessRequest is an access request.
|
|
|
|
type PathAccessRequest struct {
|
|
|
|
Name string
|
|
|
|
Query string
|
|
|
|
Publish bool
|
|
|
|
SkipAuth bool
|
|
|
|
|
|
|
|
// only if skipAuth = false
|
|
|
|
IP net.IP
|
|
|
|
User string
|
|
|
|
Pass string
|
|
|
|
Proto AuthProtocol
|
|
|
|
ID *uuid.UUID
|
|
|
|
RTSPRequest *base.Request
|
|
|
|
RTSPBaseURL *base.URL
|
|
|
|
RTSPNonce string
|
|
|
|
}
|
|
|
|
|
2024-01-23 19:52:05 +00:00
|
|
|
// PathFindPathConfRes contains the response of FindPathConf().
|
|
|
|
type PathFindPathConfRes struct {
|
2023-12-08 18:17:17 +00:00
|
|
|
Conf *conf.Path
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
2024-01-23 19:52:05 +00:00
|
|
|
// PathFindPathConfReq contains arguments of FindPathConf().
|
|
|
|
type PathFindPathConfReq struct {
|
2023-12-08 18:17:17 +00:00
|
|
|
AccessRequest PathAccessRequest
|
2024-01-23 19:52:05 +00:00
|
|
|
Res chan PathFindPathConfRes
|
2023-12-08 18:17:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PathDescribeRes contains the response of Describe().
|
|
|
|
type PathDescribeRes struct {
|
|
|
|
Path Path
|
|
|
|
Stream *stream.Stream
|
|
|
|
Redirect string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathDescribeReq contains arguments of Describe().
|
|
|
|
type PathDescribeReq struct {
|
|
|
|
AccessRequest PathAccessRequest
|
|
|
|
Res chan PathDescribeRes
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathAddPublisherRes contains the response of AddPublisher().
|
|
|
|
type PathAddPublisherRes struct {
|
|
|
|
Path Path
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathAddPublisherReq contains arguments of AddPublisher().
|
|
|
|
type PathAddPublisherReq struct {
|
|
|
|
Author Publisher
|
|
|
|
AccessRequest PathAccessRequest
|
|
|
|
Res chan PathAddPublisherRes
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathRemovePublisherReq contains arguments of RemovePublisher().
|
|
|
|
type PathRemovePublisherReq struct {
|
|
|
|
Author Publisher
|
|
|
|
Res chan struct{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathStartPublisherRes contains the response of StartPublisher().
|
|
|
|
type PathStartPublisherRes struct {
|
|
|
|
Stream *stream.Stream
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathStartPublisherReq contains arguments of StartPublisher().
|
|
|
|
type PathStartPublisherReq struct {
|
|
|
|
Author Publisher
|
|
|
|
Desc *description.Session
|
|
|
|
GenerateRTPPackets bool
|
|
|
|
Res chan PathStartPublisherRes
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathStopPublisherReq contains arguments of StopPublisher().
|
|
|
|
type PathStopPublisherReq struct {
|
|
|
|
Author Publisher
|
|
|
|
Res chan struct{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathAddReaderRes contains the response of AddReader().
|
|
|
|
type PathAddReaderRes struct {
|
|
|
|
Path Path
|
|
|
|
Stream *stream.Stream
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathAddReaderReq contains arguments of AddReader().
|
|
|
|
type PathAddReaderReq struct {
|
|
|
|
Author Reader
|
|
|
|
AccessRequest PathAccessRequest
|
|
|
|
Res chan PathAddReaderRes
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathRemoveReaderReq contains arguments of RemoveReader().
|
|
|
|
type PathRemoveReaderReq struct {
|
|
|
|
Author Reader
|
|
|
|
Res chan struct{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathSourceStaticSetReadyRes contains the response of SetReadu().
|
2023-10-31 13:19:04 +00:00
|
|
|
type PathSourceStaticSetReadyRes struct {
|
|
|
|
Stream *stream.Stream
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
2023-12-08 18:17:17 +00:00
|
|
|
// PathSourceStaticSetReadyReq contains arguments of SetReady().
|
2023-10-31 13:19:04 +00:00
|
|
|
type PathSourceStaticSetReadyReq struct {
|
|
|
|
Desc *description.Session
|
|
|
|
GenerateRTPPackets bool
|
|
|
|
Res chan PathSourceStaticSetReadyRes
|
|
|
|
}
|
|
|
|
|
2023-12-08 18:17:17 +00:00
|
|
|
// PathSourceStaticSetNotReadyReq contains arguments of SetNotReady().
|
2023-10-31 13:19:04 +00:00
|
|
|
type PathSourceStaticSetNotReadyReq struct {
|
|
|
|
Res chan struct{}
|
|
|
|
}
|