Documentation ¶
Index ¶
- Constants
- Variables
- func PackRequest(method, uri string, headers map[string]string, body string) (ret string)
- func PackResponseAnnounce(cseq string) string
- func PackResponseAuthorized(cseq, authenticate string) string
- func PackResponseDescribe(cseq, sdp string) string
- func PackResponseOptions(cseq string) string
- func PackResponsePlay(cseq string) string
- func PackResponseRecord(cseq string) string
- func PackResponseSetup(cseq string, htv string) string
- func PackResponseTeardown(cseq string) string
- type Auth
- func (a *Auth) CheckAuthorization(method, username, password string) bool
- func (a *Auth) FeedWwwAuthenticate(auths []string, username, password string)
- func (a *Auth) MakeAuthenticate(method string) string
- func (a *Auth) MakeAuthorization(method, uri string) string
- func (a *Auth) ParseAuthorization(authStr string) (err error)
- type AvPacketQueue
- type BaseInSession
- func (session *BaseInSession) Dispose() error
- func (session *BaseInSession) GetSdp() sdp.LogicContext
- func (session *BaseInSession) GetStat() base.StatSession
- func (session *BaseInSession) HandleInterleavedPacket(b []byte, channel int)
- func (session *BaseInSession) InitWithSdp(sdpCtx sdp.LogicContext)
- func (session *BaseInSession) IsAlive() (readAlive, writeAlive bool)
- func (session *BaseInSession) SetObserver(observer IBaseInSessionObserver)
- func (session *BaseInSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
- func (session *BaseInSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
- func (session *BaseInSession) UniqueKey() string
- func (session *BaseInSession) UpdateStat(intervalSec uint32)
- func (session *BaseInSession) WaitChan() <-chan error
- func (session *BaseInSession) WriteRtpRtcpDummy()
- type BaseOutSession
- func (session *BaseOutSession) Dispose() error
- func (session *BaseOutSession) GetStat() base.StatSession
- func (session *BaseOutSession) HandleInterleavedPacket(b []byte, channel int)
- func (session *BaseOutSession) InitWithSdp(sdpCtx sdp.LogicContext)
- func (session *BaseOutSession) IsAlive() (readAlive, writeAlive bool)
- func (session *BaseOutSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
- func (session *BaseOutSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
- func (session *BaseOutSession) UniqueKey() string
- func (session *BaseOutSession) UpdateStat(intervalSec uint32)
- func (session *BaseOutSession) WaitChan() <-chan error
- func (session *BaseOutSession) WriteRtpPacket(packet rtprtcp.RtpPacket) error
- type ClientCommandSession
- func (session *ClientCommandSession) AppName() string
- func (session *ClientCommandSession) Dispose() error
- func (session *ClientCommandSession) Do(rawUrl string) error
- func (session *ClientCommandSession) InitWithSdp(sdpCtx sdp.LogicContext)
- func (session *ClientCommandSession) RawQuery() string
- func (session *ClientCommandSession) RemoteAddr() string
- func (session *ClientCommandSession) StreamName() string
- func (session *ClientCommandSession) UniqueKey() string
- func (session *ClientCommandSession) Url() string
- func (session *ClientCommandSession) WaitChan() <-chan error
- func (session *ClientCommandSession) WriteInterleavedPacket(packet []byte, channel int) error
- type ClientCommandSessionOption
- type ClientCommandSessionType
- type IBaseInSessionObserver
- type IClientCommandSessionObserver
- type IInterleavedPacketWriter
- type IPubSessionObserver
- type IPullSessionObserver
- type IServerCommandSessionObserver
- type IServerObserver
- type ModClientCommandSessionOption
- type ModPullSessionOption
- type ModPushSessionOption
- type OnAvPacket
- type PubSession
- func (session *PubSession) AppName() string
- func (session *PubSession) Dispose() error
- func (session *PubSession) GetSdp() sdp.LogicContext
- func (session *PubSession) GetStat() base.StatSession
- func (session *PubSession) HandleInterleavedPacket(b []byte, channel int)
- func (session *PubSession) InitWithSdp(sdpCtx sdp.LogicContext)
- func (session *PubSession) IsAlive() (readAlive, writeAlive bool)
- func (session *PubSession) RawQuery() string
- func (session *PubSession) SetObserver(observer IPubSessionObserver)
- func (session *PubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
- func (session *PubSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
- func (session *PubSession) StreamName() string
- func (session *PubSession) UniqueKey() string
- func (session *PubSession) UpdateStat(intervalSec uint32)
- func (session *PubSession) Url() string
- func (session *PubSession) WriteInterleavedPacket(packet []byte, channel int) error
- type PullSession
- func (session *PullSession) AppName() string
- func (session *PullSession) Dispose() error
- func (session *PullSession) GetSdp() sdp.LogicContext
- func (session *PullSession) GetStat() base.StatSession
- func (session *PullSession) IsAlive() (readAlive, writeAlive bool)
- func (session *PullSession) OnConnectResult()
- func (session *PullSession) OnDescribeResponse(sdpCtx sdp.LogicContext)
- func (session *PullSession) OnInterleavedPacket(packet []byte, channel int)
- func (session *PullSession) OnSetupResult()
- func (session *PullSession) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)
- func (session *PullSession) OnSetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection)
- func (session *PullSession) Pull(rawUrl string) error
- func (session *PullSession) RawQuery() string
- func (session *PullSession) StreamName() string
- func (session *PullSession) UniqueKey() string
- func (session *PullSession) UpdateStat(intervalSec uint32)
- func (session *PullSession) Url() string
- func (session *PullSession) WaitChan() <-chan error
- func (session *PullSession) WithOnDescribeResponse(onDescribeResponse func()) *PullSession
- func (session *PullSession) WriteInterleavedPacket(packet []byte, channel int) error
- type PullSessionOption
- type PushSession
- func (session *PushSession) AppName() string
- func (session *PushSession) Dispose() error
- func (session *PushSession) GetStat() base.StatSession
- func (session *PushSession) IsAlive() (readAlive, writeAlive bool)
- func (session *PushSession) OnConnectResult()
- func (session *PushSession) OnDescribeResponse(sdpCtx sdp.LogicContext)
- func (session *PushSession) OnInterleavedPacket(packet []byte, channel int)
- func (session *PushSession) OnSetupResult()
- func (session *PushSession) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)
- func (session *PushSession) OnSetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection)
- func (session *PushSession) Push(rawUrl string, sdpCtx sdp.LogicContext) error
- func (session *PushSession) RawQuery() string
- func (session *PushSession) StreamName() string
- func (session *PushSession) UniqueKey() string
- func (session *PushSession) UpdateStat(intervalSec uint32)
- func (session *PushSession) Url() string
- func (session *PushSession) WaitChan() <-chan error
- func (session *PushSession) WriteInterleavedPacket(packet []byte, channel int) error
- func (session *PushSession) WriteRtpPacket(packet rtprtcp.RtpPacket) error
- type PushSessionOption
- type Server
- func (s *Server) Dispose()
- func (s *Server) Listen() (err error)
- func (s *Server) OnDelRtspPubSession(session *PubSession)
- func (s *Server) OnDelRtspSubSession(session *SubSession)
- func (s *Server) OnNewRtspPubSession(session *PubSession) error
- func (s *Server) OnNewRtspSubSessionDescribe(session *SubSession) (ok bool, sdp []byte)
- func (s *Server) OnNewRtspSubSessionPlay(session *SubSession) error
- func (s *Server) RunLoop() error
- type ServerAuthConfig
- type ServerCommandSession
- func (session *ServerCommandSession) Dispose() error
- func (session *ServerCommandSession) FeedSdp(b []byte)
- func (session *ServerCommandSession) GetStat() base.StatSession
- func (session *ServerCommandSession) IsAlive() (readAlive, writeAlive bool)
- func (session *ServerCommandSession) RemoteAddr() string
- func (session *ServerCommandSession) RunLoop() error
- func (session *ServerCommandSession) UniqueKey() string
- func (session *ServerCommandSession) UpdateStat(intervalSec uint32)
- func (session *ServerCommandSession) WriteInterleavedPacket(packet []byte, channel int) error
- type SubSession
- func (session *SubSession) AppName() string
- func (session *SubSession) Dispose() error
- func (session *SubSession) FeedSdp(sdpCtx sdp.LogicContext)
- func (session *SubSession) GetStat() base.StatSession
- func (session *SubSession) HandleInterleavedPacket(b []byte, channel int)
- func (session *SubSession) InitWithSdp(sdpCtx sdp.LogicContext)
- func (session *SubSession) IsAlive() (readAlive, writeAlive bool)
- func (session *SubSession) RawQuery() string
- func (session *SubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
- func (session *SubSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
- func (session *SubSession) StreamName() string
- func (session *SubSession) UniqueKey() string
- func (session *SubSession) UpdateStat(intervalSec uint32)
- func (session *SubSession) Url() string
- func (session *SubSession) WriteInterleavedPacket(packet []byte, channel int) error
- func (session *SubSession) WriteRtpPacket(packet rtprtcp.RtpPacket)
Constants ¶
const ( AuthTypeDigest = "Digest" AuthTypeBasic = "Basic" AuthAlgorithm = "MD5" )
const ( MethodOptions = "OPTIONS" MethodAnnounce = "ANNOUNCE" MethodDescribe = "DESCRIBE" MethodSetup = "SETUP" MethodRecord = "RECORD" MethodPlay = "PLAY" MethodTeardown = "TEARDOWN" MethodGetParameter = "GET_PARAMETER" )
const ( // HeaderAccept header key HeaderAccept = "Accept" HeaderUserAgent = "User-Agent" HeaderCSeq = "CSeq" HeaderContentLength = "Content-Length" HeaderTransport = "Transport" HeaderSession = "Session" HeaderRange = "Range" HeaderWwwAuthenticate = "WWW-Authenticate" HeaderAuthorization = "Authorization" HeaderPublic = "Public" // HeaderAcceptApplicationSdp header value HeaderAcceptApplicationSdp = "application/sdp" HeaderRangeDefault = "npt=0.000-" HeaderTransportClientPlayTmpl = "RTP/AVP/UDP;unicast;client_port=%d-%d" // localRtpPort, localRtcpPort HeaderTransportClientPlayTcpTmpl = "RTP/AVP/TCP;unicast;interleaved=%d-%d" // rtpChannel, rtcpChannel HeaderTransportClientRecordTmpl = "RTP/AVP/UDP;unicast;client_port=%d-%d;mode=record" HeaderTransportClientRecordTcpTmpl = "RTP/AVP/TCP;unicast;interleaved=%d-%d;mode=record" HeaderTransportServerPlayTmpl = "RTP/AVP/UDP;unicast;client_port=%d-%d;server_port=%d-%d" HeaderTransportServerRecordTmpl = "RTP/AVP/UDP;unicast;client_port=%d-%d;server_port=%d-%d;mode=record" )
const ( TransportFieldClientPort = "client_port" TransportFieldServerPort = "server_port" TransportFieldInterleaved = "interleaved" )
const (
Interleaved = uint8(0x24)
)
Variables ¶
var Log = nazalog.GetGlobalLogger()
var ResponseAnnounceTmpl = "RTSP/1.0 200 OK\r\n" +
"CSeq: %s\r\n" +
"\r\n"
ResponseAnnounceTmpl CSeq
var ResponseAuthorizedTmpl = "RTSP/1.0 401 Unauthorized\r\n" +
"CSeq: %s\r\n" +
"Date: %s\r\n" +
"WWW-Authenticate: %s\r\n" +
"\r\n"
var ResponseDescribeTmpl = "RTSP/1.0 200 OK\r\n" +
"CSeq: %s\r\n" +
"Date: %s\r\n" +
"Content-Type: application/sdp\r\n" +
"Content-Length: %d\r\n" +
"\r\n" +
"%s"
ResponseDescribeTmpl CSeq, Date, Content-Length,
var ResponseOptionsTmpl = "RTSP/1.0 200 OK\r\n" + "Server: " + base.LalRtspOptionsResponseServer + "\r\n" + "CSeq: %s\r\n" + "Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, PAUSE, RECORD, TEARDOWN\r\n" + "\r\n"
ResponseOptionsTmpl CSeq
var ResponsePlayTmpl = "RTSP/1.0 200 OK\r\n" +
"CSeq: %s\r\n" +
"Date: %s\r\n" +
"\r\n"
ResponsePlayTmpl CSeq Date
var ResponseRecordTmpl = "RTSP/1.0 200 OK\r\n" +
"CSeq: %s\r\n" +
"Session: %s\r\n" +
"\r\n"
ResponseRecordTmpl CSeq, Session
var ResponseSetupTmpl = "RTSP/1.0 200 OK\r\n" +
"CSeq: %s\r\n" +
"Date: %s\r\n" +
"Session: %s\r\n" +
"Transport: %s\r\n" +
"\r\n"
ResponseSetupTmpl rfc2326 10.4 SETUP CSeq, Date, Session, Transport
var ResponseTeardownTmpl = "RTSP/1.0 200 OK\r\n" +
"CSeq: %s\r\n" +
"\r\n"
ResponseTeardownTmpl CSeq
Functions ¶
func PackRequest ¶ added in v0.19.0
PackRequest @param body 可以为空
func PackResponseAnnounce ¶ added in v0.13.0
func PackResponseAuthorized ¶ added in v0.30.0
func PackResponseDescribe ¶ added in v0.13.0
func PackResponseOptions ¶
func PackResponsePlay ¶ added in v0.13.0
func PackResponseRecord ¶ added in v0.13.0
func PackResponseSetup ¶
func PackResponseTeardown ¶ added in v0.14.0
Types ¶
type Auth ¶ added in v0.18.0
type Auth struct { Username string Password string Typ string Realm string Nonce string Algorithm string Uri string Response string Opaque string // 暂时没用 Stale string // 暂时没用 }
func (*Auth) CheckAuthorization ¶ added in v0.30.0
CheckAuthorization 验证第二轮请求,server side使用
func (*Auth) FeedWwwAuthenticate ¶ added in v0.23.0
FeedWwwAuthenticate 使用第一轮回复,client side使用
func (*Auth) MakeAuthenticate ¶ added in v0.30.0
MakeAuthenticate 生成第一轮的回复,server side使用
func (*Auth) MakeAuthorization ¶ added in v0.18.0
MakeAuthorization 生成第二轮请求,client side使用
如果没有调用`FeedWwwAuthenticate`初始化过,则直接返回空字符串
func (*Auth) ParseAuthorization ¶ added in v0.30.0
ParseAuthorization 解析字段,server side使用
type AvPacketQueue ¶ added in v0.23.0
type AvPacketQueue struct {
// contains filtered or unexported fields
}
func NewAvPacketQueue ¶ added in v0.23.0
func NewAvPacketQueue(onAvPacket OnAvPacket) *AvPacketQueue
func (*AvPacketQueue) Feed ¶ added in v0.23.0
func (a *AvPacketQueue) Feed(pkt base.AvPacket)
Feed 注意,调用方保证,音频相较于音频,视频相较于视频,时间戳是线性递增的。
func (*AvPacketQueue) PopAllByForce ¶ added in v0.23.0
func (a *AvPacketQueue) PopAllByForce()
type BaseInSession ¶ added in v0.18.0
type BaseInSession struct {
// contains filtered or unexported fields
}
func NewBaseInSession ¶ added in v0.19.0
func NewBaseInSession(sessionType base.SessionType, cmdSession IInterleavedPacketWriter) *BaseInSession
func NewBaseInSessionWithObserver ¶ added in v0.19.0
func NewBaseInSessionWithObserver(sessionType base.SessionType, cmdSession IInterleavedPacketWriter, observer IBaseInSessionObserver) *BaseInSession
func (*BaseInSession) Dispose ¶ added in v0.18.0
func (session *BaseInSession) Dispose() error
Dispose 文档请参考: IClientSessionLifecycle interface
func (*BaseInSession) GetSdp ¶ added in v0.23.0
func (session *BaseInSession) GetSdp() sdp.LogicContext
func (*BaseInSession) GetStat ¶ added in v0.18.0
func (session *BaseInSession) GetStat() base.StatSession
func (*BaseInSession) HandleInterleavedPacket ¶ added in v0.18.0
func (session *BaseInSession) HandleInterleavedPacket(b []byte, channel int)
func (*BaseInSession) InitWithSdp ¶ added in v0.23.0
func (session *BaseInSession) InitWithSdp(sdpCtx sdp.LogicContext)
func (*BaseInSession) IsAlive ¶ added in v0.18.0
func (session *BaseInSession) IsAlive() (readAlive, writeAlive bool)
func (*BaseInSession) SetObserver ¶ added in v0.18.0
func (session *BaseInSession) SetObserver(observer IBaseInSessionObserver)
SetObserver 如果没有设置回调监听对象,可以通过该函数设置,调用方保证调用该函数发生在调用InitWithSdp之后
func (*BaseInSession) SetupWithChannel ¶ added in v0.18.0
func (session *BaseInSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
func (*BaseInSession) SetupWithConn ¶ added in v0.18.0
func (session *BaseInSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
func (*BaseInSession) UniqueKey ¶ added in v0.18.0
func (session *BaseInSession) UniqueKey() string
func (*BaseInSession) UpdateStat ¶ added in v0.18.0
func (session *BaseInSession) UpdateStat(intervalSec uint32)
func (*BaseInSession) WaitChan ¶ added in v0.25.0
func (session *BaseInSession) WaitChan() <-chan error
WaitChan 文档请参考: IClientSessionLifecycle interface
注意,目前只有一种情况,即上层主动调用Dispose函数,此时error为nil
func (*BaseInSession) WriteRtpRtcpDummy ¶ added in v0.23.0
func (session *BaseInSession) WriteRtpRtcpDummy()
WriteRtpRtcpDummy 发现pull时,需要先给对端发送数据,才能收到数据
type BaseOutSession ¶ added in v0.19.0
type BaseOutSession struct {
// contains filtered or unexported fields
}
BaseOutSession out的含义是音视频由本端发送至对端
func NewBaseOutSession ¶ added in v0.19.0
func NewBaseOutSession(sessionType base.SessionType, cmdSession IInterleavedPacketWriter) *BaseOutSession
func (*BaseOutSession) Dispose ¶ added in v0.19.0
func (session *BaseOutSession) Dispose() error
Dispose 文档请参考: IClientSessionLifecycle interface
func (*BaseOutSession) GetStat ¶ added in v0.19.0
func (session *BaseOutSession) GetStat() base.StatSession
func (*BaseOutSession) HandleInterleavedPacket ¶ added in v0.19.0
func (session *BaseOutSession) HandleInterleavedPacket(b []byte, channel int)
func (*BaseOutSession) InitWithSdp ¶ added in v0.23.0
func (session *BaseOutSession) InitWithSdp(sdpCtx sdp.LogicContext)
func (*BaseOutSession) IsAlive ¶ added in v0.19.0
func (session *BaseOutSession) IsAlive() (readAlive, writeAlive bool)
func (*BaseOutSession) SetupWithChannel ¶ added in v0.19.0
func (session *BaseOutSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
func (*BaseOutSession) SetupWithConn ¶ added in v0.19.0
func (session *BaseOutSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
func (*BaseOutSession) UniqueKey ¶ added in v0.19.0
func (session *BaseOutSession) UniqueKey() string
func (*BaseOutSession) UpdateStat ¶ added in v0.19.0
func (session *BaseOutSession) UpdateStat(intervalSec uint32)
func (*BaseOutSession) WaitChan ¶ added in v0.25.0
func (session *BaseOutSession) WaitChan() <-chan error
WaitChan 文档请参考: IClientSessionLifecycle interface
注意,目前只有一种情况,即上层主动调用Dispose函数,此时error为nil
func (*BaseOutSession) WriteRtpPacket ¶ added in v0.23.0
func (session *BaseOutSession) WriteRtpPacket(packet rtprtcp.RtpPacket) error
type ClientCommandSession ¶ added in v0.19.0
type ClientCommandSession struct {
// contains filtered or unexported fields
}
ClientCommandSession Push和Pull共用,封装了客户端底层信令信令部分。 业务方应该使用PushSession和PullSession,而不是直接使用ClientCommandSession,除非你确定要这么做。
func NewClientCommandSession ¶ added in v0.19.0
func NewClientCommandSession(t ClientCommandSessionType, uniqueKey string, observer IClientCommandSessionObserver, modOptions ...ModClientCommandSessionOption) *ClientCommandSession
func (*ClientCommandSession) AppName ¶ added in v0.19.0
func (session *ClientCommandSession) AppName() string
func (*ClientCommandSession) Dispose ¶ added in v0.19.0
func (session *ClientCommandSession) Dispose() error
Dispose 文档请参考: IClientSessionLifecycle interface
func (*ClientCommandSession) Do ¶ added in v0.19.0
func (session *ClientCommandSession) Do(rawUrl string) error
func (*ClientCommandSession) InitWithSdp ¶ added in v0.23.0
func (session *ClientCommandSession) InitWithSdp(sdpCtx sdp.LogicContext)
InitWithSdp only for PushSession
func (*ClientCommandSession) RawQuery ¶ added in v0.19.0
func (session *ClientCommandSession) RawQuery() string
func (*ClientCommandSession) RemoteAddr ¶ added in v0.19.0
func (session *ClientCommandSession) RemoteAddr() string
func (*ClientCommandSession) StreamName ¶ added in v0.19.0
func (session *ClientCommandSession) StreamName() string
func (*ClientCommandSession) UniqueKey ¶ added in v0.19.0
func (session *ClientCommandSession) UniqueKey() string
func (*ClientCommandSession) Url ¶ added in v0.23.0
func (session *ClientCommandSession) Url() string
func (*ClientCommandSession) WaitChan ¶ added in v0.20.0
func (session *ClientCommandSession) WaitChan() <-chan error
WaitChan 文档请参考: IClientSessionLifecycle interface
func (*ClientCommandSession) WriteInterleavedPacket ¶ added in v0.19.0
func (session *ClientCommandSession) WriteInterleavedPacket(packet []byte, channel int) error
type ClientCommandSessionOption ¶ added in v0.19.0
type ClientCommandSessionType ¶ added in v0.19.0
type ClientCommandSessionType int
const ( CcstPullSession ClientCommandSessionType = iota CcstPushSession )
type IBaseInSessionObserver ¶ added in v0.28.0
type IBaseInSessionObserver interface { OnSdp(sdpCtx sdp.LogicContext) // OnRtpPacket 回调收到的RTP包 // OnRtpPacket(pkt rtprtcp.RtpPacket) // OnAvPacket // // @param pkt: pkt结构体中字段含义见 rtprtcp.OnAvPacket // OnAvPacket(pkt base.AvPacket) }
IBaseInSessionObserver
BaseInSession会向上层回调两种格式的数据(本质上是一份数据,业务方可自由选择使用): 1. 原始的rtp packet 2. rtp合并后的av packet
type IClientCommandSessionObserver ¶ added in v0.28.0
type IClientCommandSessionObserver interface { OnConnectResult() // OnDescribeResponse only for PullSession OnDescribeResponse(sdpCtx sdp.LogicContext) OnSetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int) OnSetupResult() OnInterleavedPacket(packet []byte, channel int) }
type IInterleavedPacketWriter ¶ added in v0.19.0
type IPubSessionObserver ¶ added in v0.28.0
type IPubSessionObserver interface { IBaseInSessionObserver }
type IPullSessionObserver ¶ added in v0.28.0
type IPullSessionObserver interface { IBaseInSessionObserver }
type IServerCommandSessionObserver ¶ added in v0.28.0
type IServerCommandSessionObserver interface { // OnNewRtspPubSession // // @brief Announce阶段回调 // @return 如果返回非nil,则表示上层要强制关闭这个推流请求 // OnNewRtspPubSession(session *PubSession) error // OnNewRtspSubSessionDescribe // // Describe阶段回调 // // 上层的几种逻辑对应的返回值的组合情况: // // 1. 强制关闭这个session:`ok`设置为false // 2. (当前有sdp)在回调中设置sdp,让session按正常逻辑往下走:`ok`设置为true,`sdp`设置为对应的值 // 3. (当前没有sdp)后续在回调外通过 ServerCommandSession.FeedSdp 可以让session按正常逻辑往下走:`ok`设置为true,`sdp`设置为nil // // TODO(chef): bool参数类型统一为error类型 202206 // OnNewRtspSubSessionDescribe(session *SubSession) (ok bool, sdp []byte) // OnNewRtspSubSessionPlay // // @brief Play阶段回调 // @return ok 如果返回非nil,则表示上层要强制关闭这个拉流请求 // OnNewRtspSubSessionPlay(session *SubSession) error }
type IServerObserver ¶ added in v0.28.0
type IServerObserver interface { // OnNewRtspSessionConnect @brief 使得上层有能力管理未进化到Pub、Sub阶段的Session OnNewRtspSessionConnect(session *ServerCommandSession) // OnDelRtspSession @brief 注意,对于已经进化到了Pub、Sub阶段的Session,该回调依然会被调用 OnDelRtspSession(session *ServerCommandSession) // OnNewRtspPubSession // // @brief Announce阶段回调 // @return 如果返回非nil,则表示上层要强制关闭这个推流请求 // OnNewRtspPubSession(session *PubSession) error OnDelRtspPubSession(session *PubSession) // OnNewRtspSubSessionDescribe // // @return 如果返回false,则表示上层要强制关闭这个拉流请求 // @return sdp // OnNewRtspSubSessionDescribe(session *SubSession) (ok bool, sdp []byte) // OnNewRtspSubSessionPlay // // @brief Play阶段回调 // @return ok 如果返回非nil,则表示上层要强制关闭这个拉流请求 // OnNewRtspSubSessionPlay(session *SubSession) error OnDelRtspSubSession(session *SubSession) }
type ModClientCommandSessionOption ¶ added in v0.19.0
type ModClientCommandSessionOption func(option *ClientCommandSessionOption)
type ModPullSessionOption ¶ added in v0.18.0
type ModPullSessionOption func(option *PullSessionOption)
type ModPushSessionOption ¶ added in v0.19.0
type ModPushSessionOption func(option *PushSessionOption)
type OnAvPacket ¶ added in v0.23.0
type PubSession ¶ added in v0.14.0
type PubSession struct {
// contains filtered or unexported fields
}
func NewPubSession ¶ added in v0.14.0
func NewPubSession(urlCtx base.UrlContext, cmdSession *ServerCommandSession) *PubSession
func (*PubSession) AppName ¶ added in v0.18.0
func (session *PubSession) AppName() string
func (*PubSession) Dispose ¶ added in v0.14.0
func (session *PubSession) Dispose() error
func (*PubSession) GetSdp ¶ added in v0.23.0
func (session *PubSession) GetSdp() sdp.LogicContext
func (*PubSession) GetStat ¶ added in v0.16.0
func (session *PubSession) GetStat() base.StatSession
func (*PubSession) HandleInterleavedPacket ¶ added in v0.18.0
func (session *PubSession) HandleInterleavedPacket(b []byte, channel int)
func (*PubSession) InitWithSdp ¶ added in v0.23.0
func (session *PubSession) InitWithSdp(sdpCtx sdp.LogicContext)
func (*PubSession) IsAlive ¶ added in v0.17.0
func (session *PubSession) IsAlive() (readAlive, writeAlive bool)
func (*PubSession) RawQuery ¶ added in v0.18.0
func (session *PubSession) RawQuery() string
func (*PubSession) SetObserver ¶ added in v0.14.0
func (session *PubSession) SetObserver(observer IPubSessionObserver)
func (*PubSession) SetupWithChannel ¶ added in v0.18.0
func (session *PubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
func (*PubSession) SetupWithConn ¶ added in v0.18.0
func (session *PubSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
func (*PubSession) StreamName ¶ added in v0.14.0
func (session *PubSession) StreamName() string
func (*PubSession) UniqueKey ¶ added in v0.14.0
func (session *PubSession) UniqueKey() string
func (*PubSession) UpdateStat ¶ added in v0.16.0
func (session *PubSession) UpdateStat(intervalSec uint32)
func (*PubSession) Url ¶ added in v0.23.0
func (session *PubSession) Url() string
func (*PubSession) WriteInterleavedPacket ¶ added in v0.19.0
func (session *PubSession) WriteInterleavedPacket(packet []byte, channel int) error
WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseInSession
type PullSession ¶ added in v0.18.0
type PullSession struct {
// contains filtered or unexported fields
}
func NewPullSession ¶ added in v0.18.0
func NewPullSession(observer IPullSessionObserver, modOptions ...ModPullSessionOption) *PullSession
func (*PullSession) AppName ¶ added in v0.18.0
func (session *PullSession) AppName() string
AppName 文档请参考: interface ISessionUrlContext
func (*PullSession) Dispose ¶ added in v0.18.0
func (session *PullSession) Dispose() error
Dispose 文档请参考: IClientSessionLifecycle interface
func (*PullSession) GetSdp ¶ added in v0.23.0
func (session *PullSession) GetSdp() sdp.LogicContext
func (*PullSession) GetStat ¶ added in v0.18.0
func (session *PullSession) GetStat() base.StatSession
GetStat 文档请参考: interface ISessionStat
func (*PullSession) IsAlive ¶ added in v0.18.0
func (session *PullSession) IsAlive() (readAlive, writeAlive bool)
IsAlive 文档请参考: interface ISessionStat
func (*PullSession) OnConnectResult ¶ added in v0.19.0
func (session *PullSession) OnConnectResult()
OnConnectResult IClientCommandSessionObserver, callback by ClientCommandSession
func (*PullSession) OnDescribeResponse ¶ added in v0.19.0
func (session *PullSession) OnDescribeResponse(sdpCtx sdp.LogicContext)
OnDescribeResponse IClientCommandSessionObserver, callback by ClientCommandSession
func (*PullSession) OnInterleavedPacket ¶ added in v0.19.0
func (session *PullSession) OnInterleavedPacket(packet []byte, channel int)
OnInterleavedPacket IClientCommandSessionObserver, callback by ClientCommandSession
func (*PullSession) OnSetupResult ¶ added in v0.19.0
func (session *PullSession) OnSetupResult()
OnSetupResult IClientCommandSessionObserver, callback by ClientCommandSession
func (*PullSession) OnSetupWithChannel ¶ added in v0.19.0
func (session *PullSession) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)
OnSetupWithChannel IClientCommandSessionObserver, callback by ClientCommandSession
func (*PullSession) OnSetupWithConn ¶ added in v0.19.0
func (session *PullSession) OnSetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection)
OnSetupWithConn IClientCommandSessionObserver, callback by ClientCommandSession
func (*PullSession) Pull ¶ added in v0.18.0
func (session *PullSession) Pull(rawUrl string) error
Pull 阻塞直到和对端完成拉流前,握手部分的工作(也即收到RTSP Play response),或者发生错误
func (*PullSession) RawQuery ¶ added in v0.18.0
func (session *PullSession) RawQuery() string
RawQuery 文档请参考: interface ISessionUrlContext
func (*PullSession) StreamName ¶ added in v0.18.0
func (session *PullSession) StreamName() string
StreamName 文档请参考: interface ISessionUrlContext
func (*PullSession) UniqueKey ¶ added in v0.18.0
func (session *PullSession) UniqueKey() string
UniqueKey 文档请参考: interface IObject
func (*PullSession) UpdateStat ¶ added in v0.18.0
func (session *PullSession) UpdateStat(intervalSec uint32)
UpdateStat 文档请参考: interface ISessionStat
func (*PullSession) Url ¶ added in v0.23.0
func (session *PullSession) Url() string
Url 文档请参考: interface ISessionUrlContext
func (*PullSession) WaitChan ¶ added in v0.20.0
func (session *PullSession) WaitChan() <-chan error
WaitChan 文档请参考: IClientSessionLifecycle interface
func (*PullSession) WithOnDescribeResponse ¶ added in v0.30.0
func (session *PullSession) WithOnDescribeResponse(onDescribeResponse func()) *PullSession
func (*PullSession) WriteInterleavedPacket ¶ added in v0.19.0
func (session *PullSession) WriteInterleavedPacket(packet []byte, channel int) error
WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseInSession
type PullSessionOption ¶ added in v0.18.0
type PushSession ¶ added in v0.19.0
type PushSession struct {
// contains filtered or unexported fields
}
func NewPushSession ¶ added in v0.19.0
func NewPushSession(modOptions ...ModPushSessionOption) *PushSession
func (*PushSession) AppName ¶ added in v0.19.0
func (session *PushSession) AppName() string
AppName 文档请参考: interface ISessionUrlContext
func (*PushSession) Dispose ¶ added in v0.19.0
func (session *PushSession) Dispose() error
Dispose 文档请参考: IClientSessionLifecycle interface
func (*PushSession) GetStat ¶ added in v0.19.0
func (session *PushSession) GetStat() base.StatSession
GetStat 文档请参考: interface ISessionStat
func (*PushSession) IsAlive ¶ added in v0.19.0
func (session *PushSession) IsAlive() (readAlive, writeAlive bool)
IsAlive 文档请参考: interface ISessionStat
func (*PushSession) OnConnectResult ¶ added in v0.19.0
func (session *PushSession) OnConnectResult()
OnConnectResult IClientCommandSessionObserver, callback by ClientCommandSession
func (*PushSession) OnDescribeResponse ¶ added in v0.19.0
func (session *PushSession) OnDescribeResponse(sdpCtx sdp.LogicContext)
OnDescribeResponse IClientCommandSessionObserver, callback by ClientCommandSession
func (*PushSession) OnInterleavedPacket ¶ added in v0.19.0
func (session *PushSession) OnInterleavedPacket(packet []byte, channel int)
OnInterleavedPacket IClientCommandSessionObserver, callback by ClientCommandSession
func (*PushSession) OnSetupResult ¶ added in v0.19.0
func (session *PushSession) OnSetupResult()
OnSetupResult IClientCommandSessionObserver, callback by ClientCommandSession
func (*PushSession) OnSetupWithChannel ¶ added in v0.19.0
func (session *PushSession) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)
OnSetupWithChannel IClientCommandSessionObserver, callback by ClientCommandSession
func (*PushSession) OnSetupWithConn ¶ added in v0.19.0
func (session *PushSession) OnSetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection)
OnSetupWithConn IClientCommandSessionObserver, callback by ClientCommandSession
func (*PushSession) Push ¶ added in v0.19.0
func (session *PushSession) Push(rawUrl string, sdpCtx sdp.LogicContext) error
Push 阻塞直到和对端完成推流前,握手部分的工作(也即收到RTSP Record response),或者发生错误
func (*PushSession) RawQuery ¶ added in v0.19.0
func (session *PushSession) RawQuery() string
RawQuery 文档请参考: interface ISessionUrlContext
func (*PushSession) StreamName ¶ added in v0.19.0
func (session *PushSession) StreamName() string
StreamName 文档请参考: interface ISessionUrlContext
func (*PushSession) UniqueKey ¶ added in v0.19.0
func (session *PushSession) UniqueKey() string
UniqueKey 文档请参考: interface IObject
func (*PushSession) UpdateStat ¶ added in v0.19.0
func (session *PushSession) UpdateStat(intervalSec uint32)
UpdateStat 文档请参考: interface ISessionStat
func (*PushSession) Url ¶ added in v0.23.0
func (session *PushSession) Url() string
Url 文档请参考: interface ISessionUrlContext
func (*PushSession) WaitChan ¶ added in v0.20.0
func (session *PushSession) WaitChan() <-chan error
WaitChan 文档请参考: IClientSessionLifecycle interface
func (*PushSession) WriteInterleavedPacket ¶ added in v0.19.0
func (session *PushSession) WriteInterleavedPacket(packet []byte, channel int) error
WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseOutSession
func (*PushSession) WriteRtpPacket ¶ added in v0.23.0
func (session *PushSession) WriteRtpPacket(packet rtprtcp.RtpPacket) error
type PushSessionOption ¶ added in v0.19.0
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(addr string, observer IServerObserver, auth ServerAuthConfig) *Server
func (*Server) OnDelRtspPubSession ¶ added in v0.23.0
func (s *Server) OnDelRtspPubSession(session *PubSession)
func (*Server) OnDelRtspSubSession ¶ added in v0.23.0
func (s *Server) OnDelRtspSubSession(session *SubSession)
func (*Server) OnNewRtspPubSession ¶ added in v0.23.0
func (s *Server) OnNewRtspPubSession(session *PubSession) error
func (*Server) OnNewRtspSubSessionDescribe ¶ added in v0.23.0
func (s *Server) OnNewRtspSubSessionDescribe(session *SubSession) (ok bool, sdp []byte)
func (*Server) OnNewRtspSubSessionPlay ¶ added in v0.23.0
func (s *Server) OnNewRtspSubSessionPlay(session *SubSession) error
type ServerAuthConfig ¶ added in v0.30.0
type ServerCommandSession ¶ added in v0.18.0
type ServerCommandSession struct {
// contains filtered or unexported fields
}
func NewServerCommandSession ¶ added in v0.18.0
func NewServerCommandSession(observer IServerCommandSessionObserver, conn net.Conn, authConf ServerAuthConfig) *ServerCommandSession
func (*ServerCommandSession) Dispose ¶ added in v0.18.0
func (session *ServerCommandSession) Dispose() error
func (*ServerCommandSession) FeedSdp ¶ added in v0.27.0
func (session *ServerCommandSession) FeedSdp(b []byte)
func (*ServerCommandSession) GetStat ¶ added in v0.18.0
func (session *ServerCommandSession) GetStat() base.StatSession
func (*ServerCommandSession) IsAlive ¶ added in v0.18.0
func (session *ServerCommandSession) IsAlive() (readAlive, writeAlive bool)
func (*ServerCommandSession) RemoteAddr ¶ added in v0.19.0
func (session *ServerCommandSession) RemoteAddr() string
func (*ServerCommandSession) RunLoop ¶ added in v0.18.0
func (session *ServerCommandSession) RunLoop() error
func (*ServerCommandSession) UniqueKey ¶ added in v0.18.0
func (session *ServerCommandSession) UniqueKey() string
func (*ServerCommandSession) UpdateStat ¶ added in v0.18.0
func (session *ServerCommandSession) UpdateStat(intervalSec uint32)
func (*ServerCommandSession) WriteInterleavedPacket ¶ added in v0.19.0
func (session *ServerCommandSession) WriteInterleavedPacket(packet []byte, channel int) error
WriteInterleavedPacket
使用RTSP TCP命令连接,向对端发送RTP数据
type SubSession ¶ added in v0.17.0
type SubSession struct { ShouldWaitVideoKeyFrame bool // contains filtered or unexported fields }
func NewSubSession ¶ added in v0.17.0
func NewSubSession(urlCtx base.UrlContext, cmdSession *ServerCommandSession) *SubSession
func (*SubSession) AppName ¶ added in v0.18.0
func (session *SubSession) AppName() string
func (*SubSession) Dispose ¶ added in v0.18.0
func (session *SubSession) Dispose() error
func (*SubSession) FeedSdp ¶ added in v0.31.0
func (session *SubSession) FeedSdp(sdpCtx sdp.LogicContext)
FeedSdp 供上层调用
func (*SubSession) GetStat ¶ added in v0.18.0
func (session *SubSession) GetStat() base.StatSession
func (*SubSession) HandleInterleavedPacket ¶ added in v0.19.0
func (session *SubSession) HandleInterleavedPacket(b []byte, channel int)
func (*SubSession) InitWithSdp ¶ added in v0.23.0
func (session *SubSession) InitWithSdp(sdpCtx sdp.LogicContext)
InitWithSdp 供 ServerCommandSession 调用
func (*SubSession) IsAlive ¶ added in v0.18.0
func (session *SubSession) IsAlive() (readAlive, writeAlive bool)
func (*SubSession) RawQuery ¶ added in v0.18.0
func (session *SubSession) RawQuery() string
func (*SubSession) SetupWithChannel ¶ added in v0.18.0
func (session *SubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error
func (*SubSession) SetupWithConn ¶ added in v0.18.0
func (session *SubSession) SetupWithConn(uri string, rtpConn, rtcpConn *nazanet.UdpConnection) error
func (*SubSession) StreamName ¶ added in v0.17.0
func (session *SubSession) StreamName() string
func (*SubSession) UniqueKey ¶ added in v0.17.0
func (session *SubSession) UniqueKey() string
func (*SubSession) UpdateStat ¶ added in v0.18.0
func (session *SubSession) UpdateStat(intervalSec uint32)
func (*SubSession) Url ¶ added in v0.23.0
func (session *SubSession) Url() string
func (*SubSession) WriteInterleavedPacket ¶ added in v0.19.0
func (session *SubSession) WriteInterleavedPacket(packet []byte, channel int) error
WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseOutSession
func (*SubSession) WriteRtpPacket ¶ added in v0.23.0
func (session *SubSession) WriteRtpPacket(packet rtprtcp.RtpPacket)