mirror of https://bitbucket.org/ausocean/av.git
Started using session interface again - tested and everything seems to be working
This commit is contained in:
parent
1c7fc111f0
commit
ed536b2cdd
16
rtmp/rtmp.go
16
rtmp/rtmp.go
|
@ -215,8 +215,14 @@ var RTMPProtocolStringsLower = [...]string{
|
|||
"rtmfp",
|
||||
}
|
||||
|
||||
type Session interface {
|
||||
Open() error
|
||||
Write([]byte) (int, error)
|
||||
Close() error
|
||||
}
|
||||
|
||||
// session provides parameters required for an rtmp communication session.
|
||||
type Session struct {
|
||||
type session struct {
|
||||
rtmp *C.RTMP
|
||||
url string
|
||||
timeout uint
|
||||
|
@ -374,7 +380,7 @@ type C_AMFObject struct {
|
|||
|
||||
// NewSession returns a new session.
|
||||
func NewSession(url string, connectTimeout uint) Session {
|
||||
return Session{
|
||||
return &session{
|
||||
url: url,
|
||||
timeout: connectTimeout,
|
||||
}
|
||||
|
@ -382,7 +388,7 @@ func NewSession(url string, connectTimeout uint) Session {
|
|||
|
||||
// Open establishes an rtmp connection with the url passed into the
|
||||
// constructor
|
||||
func (s *Session) Open() error {
|
||||
func (s *session) Open() error {
|
||||
if s.rtmp != nil {
|
||||
return errors.New("rtmp: attempt to start already running session")
|
||||
}
|
||||
|
@ -395,7 +401,7 @@ func (s *Session) Open() error {
|
|||
}
|
||||
|
||||
// Close terminates the rtmp connection
|
||||
func (s *Session) Close() error {
|
||||
func (s *session) Close() error {
|
||||
if s.rtmp == nil {
|
||||
return Err(3)
|
||||
}
|
||||
|
@ -408,7 +414,7 @@ func (s *Session) Close() error {
|
|||
}
|
||||
|
||||
// Write writes a frame (flv tag) to the rtmp connection
|
||||
func (s *Session) Write(data []byte) (int, error) {
|
||||
func (s *session) Write(data []byte) (int, error) {
|
||||
if s.rtmp == nil {
|
||||
return 0, Err(3)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue