rtsp

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package rtsp *

  • @Author: W.w.
  • @File: i_rtsp_server_observer
  • @Date: 2023-06-07 14:45
  • @Description:

Package rtsp *

  • @Author: W.w.
  • @File: server
  • @Date: 2023-06-07 14:37
  • @Description:

Index

Constants

View Source
const (
	AuthTypeDigest = "Digest"
	AuthTypeBasic  = "Basic"
	AuthAlgorithm  = "MD5"
	RtspRealm      = "rtsp"
)
View Source
const (
	MethodOptions      = "OPTIONS"
	MethodAnnounce     = "ANNOUNCE"
	MethodDescribe     = "DESCRIBE"
	MethodSetup        = "SETUP"
	MethodRecord       = "RECORD"
	MethodPlay         = "PLAY"
	MethodTeardown     = "TEARDOWN"
	MethodGetParameter = "GET_PARAMETER"
)
View Source
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"
)
View Source
const (
	TransportFieldClientPort  = "client_port"
	TransportFieldServerPort  = "server_port"
	TransportFieldInterleaved = "interleaved"
)
View Source
const (
	Interleaved = uint8(0x24)
)
View Source
const RtspOptionsResponseServer = "media-server"

Variables

View Source
var ResponseAnnounceTmpl = "RTSP/1.0 200 OK\r\n" +
	"CSeq: %s\r\n" +
	"\r\n"

ResponseAnnounceTmpl CSeq

View Source
var ResponseAuthorizedTmpl = "RTSP/1.0 401 Unauthorized\r\n" +
	"CSeq: %s\r\n" +
	"Date: %s\r\n" +
	"WWW-Authenticate: %s\r\n" +
	"\r\n"
View Source
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,

View Source
var ResponseErrorCodeTmpl = "RTSP/1.0 %d %s\r\n" +
	"CSeq: %s\r\n" +
	"Date: %s\r\n" +
	"\r\n"

ResponseErrorCodeTmpl ErrorCode ErrorReason CSeq Date

View Source
var ResponseGetParameterTmpl = "RTSP/1.0 200 OK\r\n" +
	"CSeq: %s\r\n" +
	"Date: %s\r\n" +
	"\r\n"

ResponseGetParameterTmpl CSeq, Date

View Source
var ResponseOptionsTmpl = "RTSP/1.0 200 OK\r\n" +
	"Server: " + RtspOptionsResponseServer + "\r\n" +
	"CSeq: %s\r\n" +
	"Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, PAUSE, RECORD, TEARDOWN\r\n" +
	"\r\n"

ResponseOptionsTmpl CSeq

View Source
var ResponsePlayTmpl = "RTSP/1.0 200 OK\r\n" +
	"CSeq: %s\r\n" +
	"Date: %s\r\n" +
	"\r\n"

ResponsePlayTmpl CSeq Date

View Source
var ResponseRecordTmpl = "RTSP/1.0 200 OK\r\n" +
	"CSeq: %s\r\n" +
	"Session: %s\r\n" +
	"\r\n"

ResponseRecordTmpl CSeq, Session

View Source
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

View Source
var ResponseTeardownTmpl = "RTSP/1.0 200 OK\r\n" +
	"CSeq: %s\r\n" +
	"\r\n"

ResponseTeardownTmpl CSeq

Functions

func PackRequest

func PackRequest(method, uri string, headers map[string]string, body string) (ret string)

PackRequest @param body 可以为空

func PackResponseAnnounce

func PackResponseAnnounce(cseq string) string

func PackResponseAuthorized

func PackResponseAuthorized(cseq, authenticate string) string

func PackResponseDescribe

func PackResponseDescribe(cseq, sdp string) string

func PackResponseError

func PackResponseError(errorCode uint, errorReason, cseq string) string

func PackResponseGetParameter

func PackResponseGetParameter(cseq string) string

func PackResponseOptions

func PackResponseOptions(cseq string) string

func PackResponsePlay

func PackResponsePlay(cseq string) string

func PackResponseRecord

func PackResponseRecord(cseq string, sessionId string) string

func PackResponseSetup

func PackResponseSetup(cseq string, htv string, sessionId string) string

func PackResponseTeardown

func PackResponseTeardown(cseq string) string

Types

type Auth

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

func (a *Auth) CheckAuthorization(method, username, password string) bool

CheckAuthorization 验证第二轮请求,server side使用

func (*Auth) FeedWwwAuthenticate

func (a *Auth) FeedWwwAuthenticate(auths []string, username, password string)

FeedWwwAuthenticate 使用第一轮回复,client side使用

func (*Auth) MakeAuthenticate

func (a *Auth) MakeAuthenticate(method string) string

MakeAuthenticate 生成第一轮的回复,server side使用

func (*Auth) MakeAuthorization

func (a *Auth) MakeAuthorization(method, uri string) string

MakeAuthorization 生成第二轮请求,client side使用

如果没有调用`FeedWwwAuthenticate`初始化过,则直接返回空字符串

func (*Auth) ParseAuthorization

func (a *Auth) ParseAuthorization(authStr string) (err error)

ParseAuthorization 解析字段,server side使用

type AvPacketQueue

type AvPacketQueue struct {
	// contains filtered or unexported fields
}

func NewAvPacketQueue

func NewAvPacketQueue(onAvPacket OnAvPacket) *AvPacketQueue

func (*AvPacketQueue) Feed

func (a *AvPacketQueue) Feed(pkt media.AvPacket)

Feed 注意,调用方保证,音频相较于音频,视频相较于视频,时间戳是线性递增的。

func (*AvPacketQueue) PopAllByForce

func (a *AvPacketQueue) PopAllByForce()

type BaseInSession

type BaseInSession struct {
	// contains filtered or unexported fields
}

func NewBaseInSession

func NewBaseInSession(sessionType rtsp_base.SessionType, interleavedPacketWriter IInterleavedPacketWriter) *BaseInSession

func NewBaseInSessionWithObserver

func NewBaseInSessionWithObserver(sessionType rtsp_base.SessionType, interleavedPacketWriter IInterleavedPacketWriter, observer IBaseInSessionObserver) *BaseInSession

func (*BaseInSession) Dispose

func (session *BaseInSession) Dispose() error

Dispose 文档请参考: IClientSessionLifecycle interface

func (*BaseInSession) GetSdp

func (session *BaseInSession) GetSdp() sdp.LogicContext

func (*BaseInSession) GetStat

func (session *BaseInSession) GetStat() rtsp_base.StatSession

func (*BaseInSession) HandleInterleavedPacket

func (session *BaseInSession) HandleInterleavedPacket(b []byte, channel int)

func (*BaseInSession) InitWithSdp

func (session *BaseInSession) InitWithSdp(sdpCtx sdp.LogicContext)

func (*BaseInSession) IsAlive

func (session *BaseInSession) IsAlive() (readAlive, writeAlive bool)

func (*BaseInSession) SetObserver

func (session *BaseInSession) SetObserver(observer IBaseInSessionObserver)

SetObserver 如果没有设置回调监听对象,可以通过该函数设置,调用方保证调用该函数发生在调用InitWithSdp之后

func (*BaseInSession) SetupWithChannel

func (session *BaseInSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error

func (*BaseInSession) SetupWithConn

func (session *BaseInSession) SetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection) error

func (*BaseInSession) UniqueKey

func (session *BaseInSession) UniqueKey() string

func (*BaseInSession) UpdateStat

func (session *BaseInSession) UpdateStat(intervalSec uint32)

func (*BaseInSession) WaitChan

func (session *BaseInSession) WaitChan() <-chan error

WaitChan 文档请参考: IClientSessionLifecycle interface

注意,目前只有一种情况,即上层主动调用Dispose函数,此时error为nil

func (*BaseInSession) WriteRtpRtcpDummy

func (session *BaseInSession) WriteRtpRtcpDummy()

WriteRtpRtcpDummy 发现pull时,需要先给对端发送数据,才能收到数据

type BaseOutSession

type BaseOutSession struct {
	// contains filtered or unexported fields
}

BaseOutSession out的含义是音视频由本端发送至对端

func NewBaseOutSession

func NewBaseOutSession(sessionType rtsp_base.SessionType, interleavedPacketWriter IInterleavedPacketWriter) *BaseOutSession

func (*BaseOutSession) Dispose

func (session *BaseOutSession) Dispose() error

Dispose 文档请参考: IClientSessionLifecycle interface

func (*BaseOutSession) GetStat

func (session *BaseOutSession) GetStat() rtsp_base.StatSession

func (*BaseOutSession) HandleInterleavedPacket

func (session *BaseOutSession) HandleInterleavedPacket(b []byte, channel int)

HandleInterleavedPacket *****************************************************

  • @Description: 拉流不处理收流
  • @receiver session
  • @param b
  • @param channel *****************************************************

func (*BaseOutSession) InitWithSdp

func (session *BaseOutSession) InitWithSdp(sdpCtx sdp.LogicContext)

func (*BaseOutSession) IsAlive

func (session *BaseOutSession) IsAlive() (readAlive, writeAlive bool)

func (*BaseOutSession) SetupWithChannel

func (session *BaseOutSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error

func (*BaseOutSession) SetupWithConn

func (session *BaseOutSession) SetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection) error

func (*BaseOutSession) UniqueKey

func (session *BaseOutSession) UniqueKey() string

func (*BaseOutSession) UpdateStat

func (session *BaseOutSession) UpdateStat(intervalSec uint32)

func (*BaseOutSession) WaitChan

func (session *BaseOutSession) WaitChan() <-chan error

WaitChan 文档请参考: IClientSessionLifecycle interface

注意,目前只有一种情况,即上层主动调用Dispose函数,此时error为nil

func (*BaseOutSession) WriteRtpPacket

func (session *BaseOutSession) WriteRtpPacket(packet rtprtcp.RTPPacket) error

type ClientRtspSession

type ClientRtspSession struct {
	utils.Ctx
	// contains filtered or unexported fields
}

ClientRtspSession Push和Pull共用,封装了客户端底层信令信令部分。 业务方应该使用PushSession和PullSession,而不是直接使用ClientRtspSession。

func NewClientRtspSession

func NewClientRtspSession(t ClientRtspSessionType, uniqueKey string, observer IClientRtspSessionObserver,
	modOptions ...ModClientRtspSessionOption) *ClientRtspSession

func (*ClientRtspSession) AppName

func (session *ClientRtspSession) AppName() string

func (*ClientRtspSession) Dispose

func (session *ClientRtspSession) Dispose() error

Dispose 文档请参考: IClientSessionLifecycle interface

func (*ClientRtspSession) Do

func (session *ClientRtspSession) Do(rawUrl string) error

func (*ClientRtspSession) InitWithSdp

func (session *ClientRtspSession) InitWithSdp(sdpCtx sdp.LogicContext)

InitWithSdp only for PushSession

func (*ClientRtspSession) RawQuery

func (session *ClientRtspSession) RawQuery() string

func (*ClientRtspSession) RemoteAddr

func (session *ClientRtspSession) RemoteAddr() string

func (*ClientRtspSession) StreamName

func (session *ClientRtspSession) StreamName() string

func (*ClientRtspSession) UniqueKey

func (session *ClientRtspSession) UniqueKey() string

func (*ClientRtspSession) Url

func (session *ClientRtspSession) Url() string

func (*ClientRtspSession) WaitChan

func (session *ClientRtspSession) WaitChan() <-chan error

WaitChan 文档请参考: IClientSessionLifecycle interface

func (*ClientRtspSession) WriteInterleavedPacket

func (session *ClientRtspSession) WriteInterleavedPacket(packet []byte, channel int) error

type ClientRtspSessionOption

type ClientRtspSessionOption struct {
	DoTimeoutMs int  //协议连接超时时间
	OverTcp     bool //媒体是否走tcp
}

type ClientRtspSessionType

type ClientRtspSessionType int
const (
	CcstPullSession ClientRtspSessionType = iota
	CcstPushSession
)

type IBaseInSessionObserver

type IBaseInSessionObserver interface {
	OnSdp(sdpCtx sdp.LogicContext)

	// OnRtpPacket 回调收到的RTP包
	//
	OnRtpPacket(pkt rtprtcp.RTPPacket)

	// OnAvPacket
	//
	// @param pkt: pkt结构体中字段含义见 rtprtcp.OnAvPacket
	//
	OnAvPacket(pkt media.AvPacket)
}

IBaseInSessionObserver

BaseInSession会向上层回调两种格式的数据(本质上是一份数据,业务方可自由选择使用): 1. 原始的rtp packet 2. rtp合并后的av packet

type IClientRtspSessionObserver

type IClientRtspSessionObserver interface {
	OnConnectResult()

	// OnDescribeResponse only for PullSession
	OnDescribeResponse(sdpCtx sdp.LogicContext)

	OnSetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection)
	OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)
	OnSetupResult()

	OnInterleavedPacket(packet []byte, channel int)
}

type IInterleavedPacketWriter

type IInterleavedPacketWriter interface {
	WriteInterleavedPacket(packet []byte, channel int) error
}

type IPubSessionObserver

type IPubSessionObserver interface {
	IBaseInSessionObserver
}

type IPullSessionObserver

type IPullSessionObserver interface {
	IBaseInSessionObserver
}

type IRtspServerObserver

type IRtspServerObserver interface {
	// OnNewRtspSessionConnect @brief 使得上层有能力管理未进化到Pub、Sub阶段的Session
	OnNewRtspSessionConnect(session *ServerRTSPSession)

	// OnDelRtspSession @brief 注意,对于已经进化到了Pub、Sub阶段的Session,该回调依然会被调用
	OnDelRtspSession(session *ServerRTSPSession)

	// OnNewRtspPubSession
	//
	// @brief  Announce阶段回调
	// @return 如果返回非nil,则表示上层要强制关闭这个推流请求
	//
	OnNewRtspPubSession(session *PubSession) error

	OnDelRtspPubSession(session *PubSession)

	// OnNewRtspSubSessionDescribe
	//
	// @return 如果返回false,则表示上层要强制关闭这个拉流请求
	// @return sdp
	//
	OnNewRtspSubSessionDescribe(session *SubSession) (err error, sdp []byte)

	// OnNewRtspSubSessionPlay
	//
	// @brief Play阶段回调
	// @return ok  如果返回非nil,则表示上层要强制关闭这个拉流请求
	//
	OnNewRtspSubSessionPlay(session *SubSession) error

	OnDelRtspSubSession(session *SubSession)
}

type IServerRtspSessionObserver

type IServerRtspSessionObserver interface {
	// OnNewRtspPubSession
	/******************************************************
	 * @Description: Announce阶段回调
	 * @param session
	 * @return error  如果返回非nil,则表示上层要强制关闭这个推流请求
	 ******************************************************/
	OnNewRtspPubSession(session *PubSession) error

	// OnNewRtspSubSessionDescribe
	/******************************************************
	 * @Description: Describe阶段回调,只有设置了sdp才会回复Describe
	 * @param session
	 * @return err  不为nil强制关闭这个session
	 * @return sdp  当前有sdp: 在回调中设置sdp,让session按正常逻辑往下走
	 *              当前没有sdp: 后续在回调外通过 ServerRTSPSession.FeedSdp 可以让session按正常逻辑往下走 `sdp`设置为nil
	 ******************************************************/
	OnNewRtspSubSessionDescribe(session *SubSession) (err error, sdp []byte)

	// OnNewRtspSubSessionPlay
	/******************************************************
	 * @Description:  Play阶段回调
	 * @param session
	 * @return error   如果返回非nil,则表示上层要强制关闭这个拉流请求
	 ******************************************************/
	OnNewRtspSubSessionPlay(session *SubSession) error
}

IServerRtspSessionObserver *****************************************************

  • @Description: 给上层回调接口 *****************************************************

type ModClientRtspSessionOption

type ModClientRtspSessionOption func(option *ClientRtspSessionOption)

type ModPullSessionOption

type ModPullSessionOption func(option *PullSessionOption)

type ModPushSessionOption

type ModPushSessionOption func(option *PushSessionOption)

type OnAvPacket

type OnAvPacket func(pkt media.AvPacket)

type PubSession

type PubSession struct {
	// contains filtered or unexported fields
}

func NewPubSession

func NewPubSession(urlCtx httpUtils.UrlContext, rtspSession *ServerRTSPSession) *PubSession

func (*PubSession) AppName

func (session *PubSession) AppName() string

func (*PubSession) Dispose

func (session *PubSession) Dispose() error

func (*PubSession) GetSdp

func (session *PubSession) GetSdp() sdp.LogicContext

func (*PubSession) GetStat

func (session *PubSession) GetStat() rtsp_base.StatSession

func (*PubSession) HandleInterleavedPacket

func (session *PubSession) HandleInterleavedPacket(b []byte, channel int)

func (*PubSession) InitWithSdp

func (session *PubSession) InitWithSdp(sdpCtx sdp.LogicContext)

func (*PubSession) IsAlive

func (session *PubSession) IsAlive() (readAlive, writeAlive bool)

func (*PubSession) RawQuery

func (session *PubSession) RawQuery() string

func (*PubSession) SetObserver

func (session *PubSession) SetObserver(observer IPubSessionObserver)

func (*PubSession) SetupWithChannel

func (session *PubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error

func (*PubSession) SetupWithConn

func (session *PubSession) SetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection) error

func (*PubSession) StreamName

func (session *PubSession) StreamName() string

func (*PubSession) UniqueKey

func (session *PubSession) UniqueKey() string

func (*PubSession) UpdateStat

func (session *PubSession) UpdateStat(intervalSec uint32)

func (*PubSession) Url

func (session *PubSession) Url() string

func (*PubSession) WriteInterleavedPacket

func (session *PubSession) WriteInterleavedPacket(packet []byte, channel int) error

WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseInSession

type PullSession

type PullSession struct {
	// contains filtered or unexported fields
}

func NewPullSession

func NewPullSession(observer IPullSessionObserver, modOptions ...ModPullSessionOption) *PullSession

func (*PullSession) AppName

func (session *PullSession) AppName() string

AppName 文档请参考: interface ISessionUrlContext

func (*PullSession) Dispose

func (session *PullSession) Dispose() error

Dispose 文档请参考: IClientSessionLifecycle interface

func (*PullSession) GetSdp

func (session *PullSession) GetSdp() sdp.LogicContext

func (*PullSession) GetStat

func (session *PullSession) GetStat() rtsp_base.StatSession

GetStat 文档请参考: interface ISessionStat

func (*PullSession) IsAlive

func (session *PullSession) IsAlive() (readAlive, writeAlive bool)

IsAlive 文档请参考: interface ISessionStat

func (*PullSession) OnConnectResult

func (session *PullSession) OnConnectResult()

OnConnectResult IClientRtspSessionObserver, callback by ClientRtspSession

func (*PullSession) OnDescribeResponse

func (session *PullSession) OnDescribeResponse(sdpCtx sdp.LogicContext)

OnDescribeResponse IClientRtspSessionObserver, callback by ClientRtspSession

func (*PullSession) OnInterleavedPacket

func (session *PullSession) OnInterleavedPacket(packet []byte, channel int)

OnInterleavedPacket IClientRtspSessionObserver, callback by ClientRtspSession

func (*PullSession) OnSetupResult

func (session *PullSession) OnSetupResult()

OnSetupResult IClientRtspSessionObserver, callback by ClientRtspSession

func (*PullSession) OnSetupWithChannel

func (session *PullSession) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)

OnSetupWithChannel IClientRtspSessionObserver, callback by ClientRtspSession

func (*PullSession) OnSetupWithConn

func (session *PullSession) OnSetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection)

OnSetupWithConn IClientRtspSessionObserver, callback by ClientRtspSession

func (*PullSession) Pull

func (session *PullSession) Pull(rawUrl string) error

Pull 阻塞直到和对端完成拉流前,握手部分的工作(也即收到RTSP Play response),或者发生错误

func (*PullSession) RawQuery

func (session *PullSession) RawQuery() string

RawQuery 文档请参考: interface ISessionUrlContext

func (*PullSession) StreamName

func (session *PullSession) StreamName() string

StreamName 文档请参考: interface ISessionUrlContext

func (*PullSession) UniqueKey

func (session *PullSession) UniqueKey() string

UniqueKey 文档请参考: interface IBaseSession

func (*PullSession) UpdateStat

func (session *PullSession) UpdateStat(intervalSec uint32)

UpdateStat 文档请参考: interface ISessionStat

func (*PullSession) Url

func (session *PullSession) Url() string

Url 文档请参考: interface ISessionUrlContext

func (*PullSession) WaitChan

func (session *PullSession) WaitChan() <-chan error

WaitChan 文档请参考: IClientSessionLifecycle interface

func (*PullSession) WithOnDescribeResponse

func (session *PullSession) WithOnDescribeResponse(onDescribeResponse func()) *PullSession

func (*PullSession) WriteInterleavedPacket

func (session *PullSession) WriteInterleavedPacket(packet []byte, channel int) error

WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseInSession

type PullSessionOption

type PullSessionOption struct {
	// PullTimeoutMs
	/**
	 * @Description: 从调用Pull函数,到接收音视频数据的前一步,也即收到rtsp play response的超时时间 如果为0,则没有超时时间
	 * 单位: 毫秒
	 */
	PullTimeoutMs int

	// OverTcp
	/**
	 * @Description: 是否使用interleaved模式,也即是否通过rtsp command tcp连接传输rtp/rtcp数据
	 */
	OverTcp bool
}

type PushSession

type PushSession struct {
	// contains filtered or unexported fields
}

func NewPushSession

func NewPushSession(modOptions ...ModPushSessionOption) *PushSession

func (*PushSession) AppName

func (session *PushSession) AppName() string

AppName 文档请参考: interface ISessionUrlContext

func (*PushSession) Dispose

func (session *PushSession) Dispose() error

Dispose 文档请参考: IClientSessionLifecycle interface

func (*PushSession) GetStat

func (session *PushSession) GetStat() rtsp_base.StatSession

GetStat 文档请参考: interface ISessionStat

func (*PushSession) IsAlive

func (session *PushSession) IsAlive() (readAlive, writeAlive bool)

IsAlive 文档请参考: interface ISessionStat

func (*PushSession) OnConnectResult

func (session *PushSession) OnConnectResult()

OnConnectResult IClientRtspSessionObserver, callback by ClientRtspSession

func (*PushSession) OnDescribeResponse

func (session *PushSession) OnDescribeResponse(sdpCtx sdp.LogicContext)

OnDescribeResponse IClientRtspSessionObserver, callback by ClientRtspSession

func (*PushSession) OnInterleavedPacket

func (session *PushSession) OnInterleavedPacket(packet []byte, channel int)

OnInterleavedPacket IClientRtspSessionObserver, callback by ClientRtspSession

func (*PushSession) OnSetupResult

func (session *PushSession) OnSetupResult()

OnSetupResult IClientRtspSessionObserver, callback by ClientRtspSession

func (*PushSession) OnSetupWithChannel

func (session *PushSession) OnSetupWithChannel(uri string, rtpChannel, rtcpChannel int)

OnSetupWithChannel IClientRtspSessionObserver, callback by ClientRtspSession

func (*PushSession) OnSetupWithConn

func (session *PushSession) OnSetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection)

OnSetupWithConn IClientRtspSessionObserver, callback by ClientRtspSession

func (*PushSession) Push

func (session *PushSession) Push(rawUrl string, sdpCtx sdp.LogicContext) error

Push 阻塞直到和对端完成推流前,握手部分的工作(也即收到RTSP Record response),或者发生错误

func (*PushSession) RawQuery

func (session *PushSession) RawQuery() string

RawQuery 文档请参考: interface ISessionUrlContext

func (*PushSession) StreamName

func (session *PushSession) StreamName() string

StreamName 文档请参考: interface ISessionUrlContext

func (*PushSession) UniqueKey

func (session *PushSession) UniqueKey() string

UniqueKey 文档请参考: interface IBaseSession

func (*PushSession) UpdateStat

func (session *PushSession) UpdateStat(intervalSec uint32)

UpdateStat 文档请参考: interface ISessionStat

func (*PushSession) Url

func (session *PushSession) Url() string

Url 文档请参考: interface ISessionUrlContext

func (*PushSession) WaitChan

func (session *PushSession) WaitChan() <-chan error

WaitChan 文档请参考: IClientSessionLifecycle interface

func (*PushSession) WriteInterleavedPacket

func (session *PushSession) WriteInterleavedPacket(packet []byte, channel int) error

WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseOutSession

func (*PushSession) WriteRtpPacket

func (session *PushSession) WriteRtpPacket(packet rtprtcp.RTPPacket) error

type PushSessionOption

type PushSessionOption struct {
	PushTimeoutMs int
	OverTcp       bool
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string, observer IRtspServerObserver, auth ServerAuthConfig) *Server

func (*Server) Dispose

func (s *Server) Dispose()

func (*Server) Listen

func (s *Server) Listen() (err error)

func (*Server) ListenWithTLS

func (s *Server) ListenWithTLS(certFile, keyFile string) (err error)

func (*Server) OnDelRtspPubSession

func (s *Server) OnDelRtspPubSession(session *PubSession)

func (*Server) OnDelRtspSubSession

func (s *Server) OnDelRtspSubSession(session *SubSession)

func (*Server) OnNewRtspPubSession

func (s *Server) OnNewRtspPubSession(session *PubSession) error

func (*Server) OnNewRtspSubSessionDescribe

func (s *Server) OnNewRtspSubSessionDescribe(session *SubSession) (err error, sdp []byte)

func (*Server) OnNewRtspSubSessionPlay

func (s *Server) OnNewRtspSubSessionPlay(session *SubSession) error

func (*Server) RunLoop

func (s *Server) RunLoop() error

type ServerAuthConfig

type ServerAuthConfig struct {
	AuthEnable bool
	AuthMethod int
	UserName   string
	PassWord   string
}

type ServerRTSPSession

type ServerRTSPSession struct {
	// contains filtered or unexported fields
}

func NewServerRTSPSession

func NewServerRTSPSession(observer IServerRtspSessionObserver, conn net.Conn, authConf ServerAuthConfig) *ServerRTSPSession

func (*ServerRTSPSession) Dispose

func (session *ServerRTSPSession) Dispose() error

func (*ServerRTSPSession) FeedSdp

func (session *ServerRTSPSession) FeedSdp(b []byte)

func (*ServerRTSPSession) GetStat

func (session *ServerRTSPSession) GetStat() rtsp_base.StatSession

func (*ServerRTSPSession) IsAlive

func (session *ServerRTSPSession) IsAlive() (readAlive, writeAlive bool)

func (*ServerRTSPSession) RemoteAddr

func (session *ServerRTSPSession) RemoteAddr() string

func (*ServerRTSPSession) RunLoop

func (session *ServerRTSPSession) RunLoop() error

func (*ServerRTSPSession) UniqueKey

func (session *ServerRTSPSession) UniqueKey() string

func (*ServerRTSPSession) UpdateStat

func (session *ServerRTSPSession) UpdateStat(intervalSec uint32)

func (*ServerRTSPSession) WriteInterleavedPacket

func (session *ServerRTSPSession) WriteInterleavedPacket(packet []byte, channel int) error

WriteInterleavedPacket

使用RTSP TCP命令连接,向对端发送RTP数据

type SubSession

type SubSession struct {
	ShouldWaitVideoKeyFrame bool
	// contains filtered or unexported fields
}

func NewSubSession

func NewSubSession(urlCtx httpUtils.UrlContext, rtspSession *ServerRTSPSession) *SubSession

func (*SubSession) AppName

func (session *SubSession) AppName() string

func (*SubSession) Dispose

func (session *SubSession) Dispose() error

func (*SubSession) FeedSdp

func (session *SubSession) FeedSdp(sdpCtx sdp.LogicContext)

FeedSdp 供上层调用

func (*SubSession) GetQuery

func (session *SubSession) GetQuery(key string) string

func (*SubSession) GetStat

func (session *SubSession) GetStat() rtsp_base.StatSession

func (*SubSession) HandleInterleavedPacket

func (session *SubSession) HandleInterleavedPacket(b []byte, channel int)

func (*SubSession) InitWithSdp

func (session *SubSession) InitWithSdp(sdpCtx sdp.LogicContext)

InitWithSdp 供 ServerRTSPSession 调用

func (*SubSession) IsAlive

func (session *SubSession) IsAlive() (readAlive, writeAlive bool)

func (*SubSession) RawQuery

func (session *SubSession) RawQuery() string

func (*SubSession) SetupWithChannel

func (session *SubSession) SetupWithChannel(uri string, rtpChannel, rtcpChannel int) error

func (*SubSession) SetupWithConn

func (session *SubSession) SetupWithConn(uri string, rtpConn, rtcpConn *netUdp.UdpConnection) error

func (*SubSession) StreamName

func (session *SubSession) StreamName() string

func (*SubSession) UniqueKey

func (session *SubSession) UniqueKey() string

func (*SubSession) UpdateStat

func (session *SubSession) UpdateStat(intervalSec uint32)

func (*SubSession) Url

func (session *SubSession) Url() string

func (*SubSession) WriteInterleavedPacket

func (session *SubSession) WriteInterleavedPacket(packet []byte, channel int) error

WriteInterleavedPacket IInterleavedPacketWriter, callback by BaseOutSession

func (*SubSession) WriteRtpPacket

func (session *SubSession) WriteRtpPacket(packet rtprtcp.RTPPacket)

Directories

Path Synopsis
Package rtsp_base *
Package rtsp_base *

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL