Documentation ¶
Index ¶
- Constants
- Variables
- type ClientType
- type CommandError
- type MediaType
- type NetSession
- func (session *NetSession) CheckStateMachine(methodName string) bool
- func (session *NetSession) CloseSession() error
- func (session *NetSession) GoNextState(methodName string) bool
- func (session *NetSession) ProcessPackage(pack interface{}) error
- func (session *NetSession) ProcessSdpMessage(sdpMessage *sdp.Message, rtspPackage *Package, pps *PusherPullersSession) error
- func (session *NetSession) ReadPackage() (interface{}, error)
- func (session *NetSession) WritePackage(pack interface{}) error
- type Package
- type PackageType
- type PullerClientInfo
- type PusherPullersPair
- type PusherPullersSession
- func (session *PusherPullersSession) AddRtpRtcpSession(clientType ClientType, mediaType MediaType, ...) error
- func (session *PusherPullersSession) PauseSession(rtspSessionID *string) []error
- func (session *PusherPullersSession) StartSession(rtspSessionID *string) []error
- func (session *PusherPullersSession) StopSession(rtspSessionID *string) []error
- func (session *PusherPullersSession) TCPPackageProcess() error
- type ResponseInfo
- type RtpRtcpPackage
- type RtpRtcpSession
- func (session *RtpRtcpSession) BeginTransfer(rtpChan, rtcpChan chan RtpRtcpPackage) error
- func (session *RtpRtcpSession) PauseTransfer() error
- func (session *RtpRtcpSession) StartRtpRtcpSession(clientType ClientType, mediaType MediaType, pullerClientInfo *PullerClientInfo, ...) error
- func (session *RtpRtcpSession) StopTransfer() error
- type Server
Constants ¶
const ( //ServerInit The initial state, no valid SETUP has been received yet. ServerInit string = "Init" //ServerReady last SETUP received was successful,reply sent or after playing, //last PAUSE received was successful,reply sent. ServerReady string = "Ready" //ServerPlaying last PLAY received was successful, reply sent. Data is being sent. ServerPlaying string = "Playing" //ServerRecording the server is recording media data. ServerRecording string = "Recording" )
server state machine
const ( //SETUP rtsp method SETUP SETUP string = "SETUP" //TEARDOWN rtsp method TEARDOWN TEARDOWN string = "TEARDOWN" //PLAY rtsp method PLAY PLAY string = "PLAY" //RECORD rtsp method RECORD RECORD string = "RECORD" //PAUSE rtsp method PAUSE PAUSE string = "PAUSE" //DESCRIBE rtsp method DESCRIBE DESCRIBE string = "DESCRIBE" //ANNOUNCE rtsp method ANNOUNCE ANNOUNCE string = "ANNOUNCE" //OPTIONS rtsp method OPTIONS OPTIONS string = "OPTIONS" )
method name
Variables ¶
var ( //ReadBufferSize bio&tcp&udp read buffer size ReadBufferSize int //WriteBufferSize bio&tcp&udp write buffer size WriteBufferSize int //PushChannelBufferSize pusher channel buffer size PushChannelBufferSize int //PullChannelBufferSize puller channel buffer size PullChannelBufferSize int )
Functions ¶
This section is empty.
Types ¶
type ClientType ¶
type ClientType int
ClientType rtsp client type(remote end point of connection)func (session *RtpRtcpSession)
const ( //PusherClient the rtsp client is pusher PusherClient ClientType = 0 //PullerClient the rtsp client is puller PullerClient ClientType = 1 )
type CommandError ¶
type CommandError string
CommandError rtsp command error number
const ( //Ok it's ok Ok CommandError = "200 OK" //NotSupport not support this mothod NotSupport CommandError = "405 Method Not Allowed" //InternalServerError internal server error InternalServerError CommandError = "500 Internal Server Error" //UnsupportedMediaType Unsupported Media Type UnsupportedMediaType CommandError = "415 Unsupported Media Type" //UnsupportedTransport Unsupported Transport UnsupportedTransport CommandError = "461 Unsupported transport" //BadRequest bad request like url invalid BadRequest CommandError = "400 Bad Request" //Forbidden forbidden request like pusher's request's resource path already used Forbidden CommandError = "403 Forbidden" //NotFound not found the resource path for puller client NotFound CommandError = "404 Not Found" //MethodNotValid method not valid in tis state , see rtsp state machine MethodNotValid CommandError = "455 Method Not Valid in This State" )
type NetSession ¶
type NetSession struct { protocolinterface.BasicNetSession SessionType ClientType // type for pusher or puller AudioStreamName string // audio stream name VideoStreamName string // video stream name RtspURL *url.URL // resource path in url PusherPullersSessionMap map[string]*PusherPullersSession // map url's resource to sessions PusherPullersSessionMapMutex *sync.Mutex // provide ResourceMap's atom SdpContent string // sdp raw data from announce request ReourcePath string // Resource Path of request url // contains filtered or unexported fields }
NetSession rtsp net session
func (*NetSession) CheckStateMachine ¶
func (session *NetSession) CheckStateMachine(methodName string) bool
CheckStateMachine check server state machine
func (*NetSession) CloseSession ¶
func (session *NetSession) CloseSession() error
CloseSession close session's connection and bufio
func (*NetSession) GoNextState ¶
func (session *NetSession) GoNextState(methodName string) bool
GoNextState go to next server state
func (*NetSession) ProcessPackage ¶
func (session *NetSession) ProcessPackage(pack interface{}) error
ProcessPackage process input package
func (*NetSession) ProcessSdpMessage ¶
func (session *NetSession) ProcessSdpMessage( sdpMessage *sdp.Message, rtspPackage *Package, pps *PusherPullersSession) error
ProcessSdpMessage print sdp message content
func (*NetSession) ReadPackage ¶
func (session *NetSession) ReadPackage() (interface{}, error)
ReadPackage read package for rtsp
func (*NetSession) WritePackage ¶
func (session *NetSession) WritePackage(pack interface{}) error
WritePackage write package for rtsp
type Package ¶
type Package struct { protocolinterface.NetPackage RtspHeaderMap map[string]string Method string URL string Version string Content []byte ResponseInfo }
Package rtsp package
type PackageType ¶
type PackageType int
PackageType package type
const ( //RtpPackage stand for rtp RtpPackage PackageType = 0 //RtcpPackage stand for rtcp RtcpPackage PackageType = 1 )
type PullerClientInfo ¶
type PullerClientInfo struct {
RtpRemotePort, RtcpRemotePort, IPRemote *string
}
PullerClientInfo the puller 's info as input to create rtp/rtcp
type PusherPullersPair ¶
type PusherPullersPair struct { Pusher *RtpRtcpSession Pullers *list.List PullersMutex sync.Mutex IfStop bool // contains filtered or unexported fields }
PusherPullersPair one pusher maps multiple pullers
func (*PusherPullersPair) Pause ¶
func (session *PusherPullersPair) Pause(rtspSessionID *string) []error
Pause pause package(rtp/rtcp) transfer from pusher to pullers
func (*PusherPullersPair) Start ¶
func (session *PusherPullersPair) Start(rtspSessionID *string) []error
Start start package(rtp/rtcp) transfer from pusher to pullers
func (*PusherPullersPair) StartDispatch ¶
func (session *PusherPullersPair) StartDispatch() error
StartDispatch begin package(rtp/rtcp) dispatch from pusher to pullers
func (*PusherPullersPair) Stop ¶
func (session *PusherPullersPair) Stop(rtspSessionID *string) []error
Stop stop package(rtp/rtcp) transfer from pusher to pullers
type PusherPullersSession ¶
type PusherPullersSession struct { PusherPullersPairMap map[MediaType]*PusherPullersPair // has vidio and audio SdpMessage *sdp.Message // sdp info from pusher SdpContent *string // sdp raw content AudioStreamName *string // audio stream name from sdp content VideoStreamName *string // video stream name from sdp content }
PusherPullersSession session includes pusher and pullers
func (*PusherPullersSession) AddRtpRtcpSession ¶
func (session *PusherPullersSession) AddRtpRtcpSession( clientType ClientType, mediaType MediaType, rtpPort, rtcpPort, remoteIP *string, rtspSessionID string) error
AddRtpRtcpSession add a rtp-rtcp-session to this pusher-pullers-session
func (*PusherPullersSession) PauseSession ¶
func (session *PusherPullersSession) PauseSession(rtspSessionID *string) []error
PauseSession Pause goroutines(rtp/rtcp) created by rtspSessionID
func (*PusherPullersSession) StartSession ¶
func (session *PusherPullersSession) StartSession(rtspSessionID *string) []error
StartSession start goroutines(rtp/rtcp) created by rtspSessionID
func (*PusherPullersSession) StopSession ¶
func (session *PusherPullersSession) StopSession(rtspSessionID *string) []error
StopSession stop goroutines(rtp/rtcp) created by rtspSessionID
func (*PusherPullersSession) TCPPackageProcess ¶
func (session *PusherPullersSession) TCPPackageProcess() error
TCPPackageProcess transfer rtp/rtcp package throw tcp conn
type ResponseInfo ¶
type ResponseInfo struct { Error CommandError OptionsMethods string SetupTransport string DescribeContent string }
ResponseInfo response info
type RtpRtcpSession ¶
type RtpRtcpSession struct { RtspSessionID string // identification of rtsp session RtpUDPConnToPuller *net.UDPConn // rtp udp connection to puller RtcpUDPConnToPuller *net.UDPConn // rtcp udp connection to puller RtpUDPConnToPusher *net.UDPConn // rtp udp connection to pusher RtcpUDPConnToPusher *net.UDPConn // rtcp udp connection to pusher RtpServerPort *string // rtp Server port in udp session RtcpServerPort *string // rtcp Server port in udp session SessionMediaType MediaType // this session's media type SessionClientType ClientType // this session's client type(connected to pusher or puller) RtpPackageChannel chan *RtpRtcpPackage // rtp packages for puller RtcpPackageChannel chan *RtpRtcpPackage // rtcp packages for puller IfStop bool // if stop is true,then stop go routines created by this session IfPause bool // if pause transfer }
RtpRtcpSession a pair of rtp-rtcp sessions
func (*RtpRtcpSession) BeginTransfer ¶
func (session *RtpRtcpSession) BeginTransfer(rtpChan, rtcpChan chan RtpRtcpPackage) error
BeginTransfer begin recieving packages from pusher,then push into channel
func (*RtpRtcpSession) PauseTransfer ¶
func (session *RtpRtcpSession) PauseTransfer() error
PauseTransfer pause this transfer
func (*RtpRtcpSession) StartRtpRtcpSession ¶
func (session *RtpRtcpSession) StartRtpRtcpSession( clientType ClientType, mediaType MediaType, pullerClientInfo *PullerClientInfo, rtspSessionID string) error
StartRtpRtcpSession Start a pair of rtp-rtcp sessions
func (*RtpRtcpSession) StopTransfer ¶
func (session *RtpRtcpSession) StopTransfer() error
StopTransfer stop this transfer
type Server ¶
type Server struct { protocolinterface.BasicNet PusherPullersSessionMap map[string]*PusherPullersSession PusherPullersSessionMapMutex sync.Mutex }
Server rtsp server