Documentation ¶
Index ¶
- Constants
- func GetEncodeNameByCodecId(cid RTSP_CODEC_ID) string
- type ClientHandle
- type ClientOption
- type HeadFiled
- type LowerTransport
- type OnSampleCallBack
- type OutPutCallBack
- type PacketCallBack
- type RTSP_CODEC_ID
- type RangeTime
- type RangeType
- type RtpInfo
- type RtspClient
- func (client *RtspClient) AddTrack(track *RtspTrack)
- func (client *RtspClient) EnableRTCP()
- func (client *RtspClient) GetTrack(trackName string) (track *RtspTrack, found bool)
- func (client *RtspClient) Input(data []byte) (err error)
- func (client *RtspClient) KeepAlive(method string) error
- func (client *RtspClient) Pause() (err error)
- func (client *RtspClient) Play()
- func (client *RtspClient) SessionDescribe() string
- func (client *RtspClient) SetOutput(output OutPutCallBack)
- func (client *RtspClient) SetRange(timeRange RangeTime)
- func (client *RtspClient) SetScale(scale float32)
- func (client *RtspClient) SetSessionDescribe(sdp *sdp.Sdp)
- func (client *RtspClient) SetSpeed(speed float32)
- func (client *RtspClient) Start() error
- func (client *RtspClient) TearDown() (err error)
- type RtspCodec
- type RtspRequest
- type RtspResponse
- type RtspSample
- type RtspServer
- type RtspTrack
- func (track *RtspTrack) Bye() error
- func (track *RtspTrack) EnableTCP()
- func (track *RtspTrack) GetRtcpRecvContext() *rtcp.RtcpContext
- func (track *RtspTrack) GetRtcpSendContext() *rtcp.RtcpContext
- func (track *RtspTrack) GetTransport() *RtspTransport
- func (track *RtspTrack) Input(data []byte, isRtcp bool) error
- func (track *RtspTrack) OnPacket(f PacketCallBack)
- func (track *RtspTrack) OnSample(onsample OnSampleCallBack)
- func (track *RtspTrack) OpenTrack()
- func (track *RtspTrack) ReceiveReport() error
- func (track *RtspTrack) SendReport() error
- func (track *RtspTrack) SetCodecParamHandle(handle sdp.FmtpCodecParamParser)
- func (track *RtspTrack) SetExtraData(extra interface{})
- func (track *RtspTrack) SetTransport(transport *RtspTransport)
- func (track *RtspTrack) SourceDescription(sdesType uint8, content string) error
- func (track *RtspTrack) WriteSample(sample RtspSample) error
- type RtspTransport
- func (transport *RtspTransport) Decode(data []byte) error
- func (transport *RtspTransport) DecodeString(data string) error
- func (transport *RtspTransport) EncodeString() string
- func (transport *RtspTransport) SetClientUdpPort(rtpPort uint16, rtcpPort uint16)
- func (transport *RtspTransport) SetInterleaved(interleaved [2]int)
- func (transport *RtspTransport) SetServerUdpPort(rtpPort uint16, rtcpPort uint16)
- type ServerHandle
- type ServerOption
- type TrackCallBack
- type TrackOption
- type TransportOption
Constants ¶
View Source
const ( STATE_Init = iota STATE_Ready STATE_Playing STATE_Recording )
View Source
const ( RTSP_1_0 = 1 RTSP_2_0 = 2 )
View Source
const ( OPTIONS = "OPTIONS" DESCRIBE = "DESCRIBE" SETUP = "SETUP" PLAY = "PLAY" GET_PARAMETER = "GET_PARAMETER" SET_PARAMETER = "SET_PARAMETER" ANNOUNCE = "ANNOUNCE" PAUSE = "PAUSE" RECORD = "RECORD" REDIRECT = "REDIRECT" TEARDOWN = "TEARDOWN" )
method direction object requirement DESCRIBE C->S P,S recommended ANNOUNCE C->S, S->C P,S optional GET_PARAMETER C->S, S->C P,S optional OPTIONS C->S, S->C P,S required
(S->C: optional)
PAUSE C->S P,S recommended PLAY C->S P,S required RECORD C->S P,S optional REDIRECT S->C P,S optional SETUP C->S S required SET_PARAMETER C->S, S->C P,S optional TEARDOWN C->S P,S required
View Source
const ( Accept = "Accept" AcceptEncoding = "AcceptEncoding" AcceptLanguage = "AcceptLanguage" Allow = "Allow" Authorization = "Authorization" Bandwidth = "Bandwidth" Blocksize = "Blocksize" CacheControl = "CacheControl" Conference = "Conference" Connection = "Connection" ContentBase = "Content-Base" ContentEncoding = "Content-Encoding" ContentLanguage = "Content-Language" ContentLength = "Content-Length" ContentLocation = "Content-Location" ContentType = "Content-Type" CSeq = "CSeq" Date = "Date" Expires = "Expires" From = "From" IfModifiedSince = "IfModifiedSince" LastModified = "LastModified" ProxyAuthenticate = "ProxyAuthenticate" ProxyRequire = "ProxyRequire" Public = "Public" Range = "Range" Referer = "Referer" Require = "Require" RetryAfter = "RetryAfter" RTPInfo = "RTPInfo" Scale = "Scale" Session = "Session" Server = "Server" Speed = "Speed" Transport = "Transport" Unsupported = "Unsupported" UserAgent = "UserAgent" Via = "Via" WWWAuthenticate = "WWW-Authenticate" Location = "Location" )
View Source
const ( OK = 200 MOVED_Permanently = 300 MOVED_Temporarily = 301 BAD_REQUEST = 400 Not_Found = 404 Session_Not_Found = 454 Unsupported_Transport = 461 Internal_Server_Error = 500 Not_Implemented = 501 Version_Not_Supported = 505 )
View Source
const ( MODE_PLAY = "PLAY" MODE_RECORD = "RECORD" )
Variables ¶
This section is empty.
Functions ¶
func GetEncodeNameByCodecId ¶
func GetEncodeNameByCodecId(cid RTSP_CODEC_ID) string
Types ¶
type ClientHandle ¶
type ClientHandle interface { HandleOption(cli *RtspClient, res RtspResponse, public []string) error HandleDescribe(cli *RtspClient, res RtspResponse, sdp *sdp.Sdp, tracks map[string]*RtspTrack) error HandleSetup(cli *RtspClient, res RtspResponse, currentTrack *RtspTrack, tracks map[string]*RtspTrack, sessionId string, timeout int) error HandleAnnounce(cli *RtspClient, res RtspResponse) error HandlePlay(cli *RtspClient, res RtspResponse, timeRange *RangeTime, info *RtpInfo) error HandlePause(cli *RtspClient, res RtspResponse) error HandleTeardown(cli *RtspClient, res RtspResponse) error HandleGetParameter(cli *RtspClient, res RtspResponse) error HandleSetParameter(cli *RtspClient, res RtspResponse) error HandleRedirect(cli *RtspClient, req RtspRequest, location string, timeRange *RangeTime) error HandleRecord(cli *RtspClient, res RtspResponse, timeRange *RangeTime, info *RtpInfo) error HandleRequest(cli *RtspClient, req RtspRequest) error }
type ClientOption ¶
type ClientOption func(cli *RtspClient)
func WithEnableRecord ¶
func WithEnableRecord() ClientOption
type OnSampleCallBack ¶
type OnSampleCallBack func(sample RtspSample)
type OutPutCallBack ¶
type PacketCallBack ¶
type RTSP_CODEC_ID ¶
type RTSP_CODEC_ID int
const ( RTSP_CODEC_H264 RTSP_CODEC_ID = iota RTSP_CODEC_H265 RTSP_CODEC_AAC RTSP_CODEC_G711A RTSP_CODEC_G711U RTSP_CODEC_PS RTSP_CODEC_TS )
func GetCodecIdByEncodeName ¶
func GetCodecIdByEncodeName(name string) RTSP_CODEC_ID
type RangeTime ¶
type RangeTime struct {
// contains filtered or unexported fields
}
func (RangeTime) EncodeString ¶
type RtspClient ¶
type RtspClient struct {
// contains filtered or unexported fields
}
func NewRtspClient ¶
func NewRtspClient(uri string, handle ClientHandle, opt ...ClientOption) (*RtspClient, error)
func (*RtspClient) AddTrack ¶
func (client *RtspClient) AddTrack(track *RtspTrack)
func (*RtspClient) EnableRTCP ¶
func (client *RtspClient) EnableRTCP()
func (*RtspClient) GetTrack ¶
func (client *RtspClient) GetTrack(trackName string) (track *RtspTrack, found bool)
func (*RtspClient) Input ¶
func (client *RtspClient) Input(data []byte) (err error)
func (*RtspClient) KeepAlive ¶
func (client *RtspClient) KeepAlive(method string) error
func (*RtspClient) Pause ¶
func (client *RtspClient) Pause() (err error)
func (*RtspClient) Play ¶
func (client *RtspClient) Play()
func (*RtspClient) SessionDescribe ¶
func (client *RtspClient) SessionDescribe() string
func (*RtspClient) SetOutput ¶
func (client *RtspClient) SetOutput(output OutPutCallBack)
func (*RtspClient) SetRange ¶
func (client *RtspClient) SetRange(timeRange RangeTime)
func (*RtspClient) SetScale ¶
func (client *RtspClient) SetScale(scale float32)
func (*RtspClient) SetSessionDescribe ¶
func (client *RtspClient) SetSessionDescribe(sdp *sdp.Sdp)
func (*RtspClient) SetSpeed ¶
func (client *RtspClient) SetSpeed(speed float32)
func (*RtspClient) Start ¶
func (client *RtspClient) Start() error
func (*RtspClient) TearDown ¶
func (client *RtspClient) TearDown() (err error)
type RtspCodec ¶
type RtspCodec struct { Cid RTSP_CODEC_ID //H264,H265,PCMU,PCMA... PayloadType uint8 SampleRate uint32 ChannelCount uint8 }
func NewApplicatioCodec ¶
func NewAudioCodec ¶
type RtspRequest ¶
func (*RtspRequest) Encode ¶
func (req *RtspRequest) Encode() string
type RtspResponse ¶
func (*RtspResponse) Encode ¶
func (res *RtspResponse) Encode() string
type RtspSample ¶
type RtspSample struct { Cid RTSP_CODEC_ID Sample []byte Timestamp uint32 //in milliseconds Completed bool }
type RtspServer ¶
type RtspServer struct {
// contains filtered or unexported fields
}
func NewRtspServer ¶
func NewRtspServer(handle ServerHandle, opt ...ServerOption) *RtspServer
func (*RtspServer) AddTrack ¶
func (server *RtspServer) AddTrack(track *RtspTrack)
func (*RtspServer) Input ¶
func (server *RtspServer) Input(data []byte) (err error)
func (*RtspServer) SetOutput ¶
func (server *RtspServer) SetOutput(output OutPutCallBack)
type RtspTrack ¶
type RtspTrack struct { TrackName string //video/audio/application Codec RtspCodec // contains filtered or unexported fields }
func NewAudioTrack ¶
func NewAudioTrack(codec RtspCodec, opt ...TrackOption) *RtspTrack
func NewMetaTrack ¶
func NewMetaTrack(codec RtspCodec, opt ...TrackOption) *RtspTrack
func NewVideoTrack ¶
func NewVideoTrack(codec RtspCodec, opt ...TrackOption) *RtspTrack
func (*RtspTrack) GetRtcpRecvContext ¶
func (track *RtspTrack) GetRtcpRecvContext() *rtcp.RtcpContext
func (*RtspTrack) GetRtcpSendContext ¶
func (track *RtspTrack) GetRtcpSendContext() *rtcp.RtcpContext
func (*RtspTrack) GetTransport ¶
func (track *RtspTrack) GetTransport() *RtspTransport
func (*RtspTrack) OnPacket ¶
func (track *RtspTrack) OnPacket(f PacketCallBack)
func (*RtspTrack) OnSample ¶
func (track *RtspTrack) OnSample(onsample OnSampleCallBack)
func (*RtspTrack) ReceiveReport ¶
func (*RtspTrack) SendReport ¶
func (*RtspTrack) SetCodecParamHandle ¶
func (track *RtspTrack) SetCodecParamHandle(handle sdp.FmtpCodecParamParser)
func (*RtspTrack) SetExtraData ¶
func (track *RtspTrack) SetExtraData(extra interface{})
func (*RtspTrack) SetTransport ¶
func (track *RtspTrack) SetTransport(transport *RtspTransport)
func (*RtspTrack) SourceDescription ¶
func (*RtspTrack) WriteSample ¶
func (track *RtspTrack) WriteSample(sample RtspSample) error
type RtspTransport ¶
type RtspTransport struct { IsMultiCast bool Proto LowerTransport Client_ports [2]uint16 Server_ports [2]uint16 Interleaved [2]int // contains filtered or unexported fields }
func NewRtspTransport ¶
func NewRtspTransport(opt ...TransportOption) *RtspTransport
func (*RtspTransport) Decode ¶
func (transport *RtspTransport) Decode(data []byte) error
func (*RtspTransport) DecodeString ¶
func (transport *RtspTransport) DecodeString(data string) error
func (*RtspTransport) EncodeString ¶
func (transport *RtspTransport) EncodeString() string
func (*RtspTransport) SetClientUdpPort ¶
func (transport *RtspTransport) SetClientUdpPort(rtpPort uint16, rtcpPort uint16)
func (*RtspTransport) SetInterleaved ¶
func (transport *RtspTransport) SetInterleaved(interleaved [2]int)
func (*RtspTransport) SetServerUdpPort ¶
func (transport *RtspTransport) SetServerUdpPort(rtpPort uint16, rtcpPort uint16)
type ServerHandle ¶
type ServerHandle interface { HandleOption(svr *RtspServer, req RtspRequest, res *RtspResponse) HandleDescribe(svr *RtspServer, req RtspRequest, res *RtspResponse) HandleSetup(svr *RtspServer, req RtspRequest, res *RtspResponse, transport *RtspTransport, tracks *RtspTrack) HandleAnnounce(svr *RtspServer, req RtspRequest, tracks map[string]*RtspTrack) HandlePlay(svr *RtspServer, req RtspRequest, res *RtspResponse, timeRange *RangeTime, info []*RtpInfo) HandlePause(svr *RtspServer, req RtspRequest, res *RtspResponse) HandleTeardown(svr *RtspServer, req RtspRequest, res *RtspResponse) HandleGetParameter(svr *RtspServer, req RtspRequest, res *RtspResponse) HandleSetParameter(svr *RtspServer, req RtspRequest, res *RtspResponse) HandleRecord(svr *RtspServer, req RtspRequest, res *RtspResponse, timeRange *RangeTime, info []*RtpInfo) HandleResponse(svr *RtspServer, res RtspResponse) }
type ServerOption ¶
type ServerOption func(*RtspServer)
func WithAuthType ¶
func WithAuthType(authType string) ServerOption
func WithRealm ¶
func WithRealm(realm string) ServerOption
func WithUserInfo ¶
func WithUserInfo(userName, passwd string) ServerOption
type TrackCallBack ¶
type TrackCallBack func(track *RtspTrack)
type TrackOption ¶
type TrackOption func(t *RtspTrack)
func WithCodecParamHandler ¶
func WithCodecParamHandler(handler sdp.FmtpCodecParamParser) TrackOption
func WithDisableRtcpRR ¶
func WithDisableRtcpRR() TrackOption
type TransportOption ¶
type TransportOption func(transport *RtspTransport)
func WithClientUdpPort ¶
func WithClientUdpPort(rtpPort uint16, rtcpPort uint16) TransportOption
func WithEnableUdp ¶
func WithEnableUdp() TransportOption
func WithMode ¶
func WithMode(mode string) TransportOption
func WithServerUdpPort ¶
func WithServerUdpPort(rtpPort uint16, rtcpPort uint16) TransportOption
func WithTcpInterleaved ¶
func WithTcpInterleaved(interleaved [2]int) TransportOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.