mirror of https://bitbucket.org/ausocean/av.git
Removed session interface and mad session struct exported
This commit is contained in:
parent
9f61f33deb
commit
1b4db5b0dc
|
@ -209,7 +209,7 @@ func (s *ffmpegSender) close() error {
|
||||||
|
|
||||||
// rtmpSender implements loadSender for a native RTMP destination.
|
// rtmpSender implements loadSender for a native RTMP destination.
|
||||||
type rtmpSender struct {
|
type rtmpSender struct {
|
||||||
sess rtmp.Session
|
sess *rtmp.Session
|
||||||
|
|
||||||
url string
|
url string
|
||||||
timeout uint
|
timeout uint
|
||||||
|
@ -222,7 +222,7 @@ type rtmpSender struct {
|
||||||
var _ restarter = (*rtmpSender)(nil)
|
var _ restarter = (*rtmpSender)(nil)
|
||||||
|
|
||||||
func newRtmpSender(url string, timeout uint, retries int, log func(lvl, msg string)) (*rtmpSender, error) {
|
func newRtmpSender(url string, timeout uint, retries int, log func(lvl, msg string)) (*rtmpSender, error) {
|
||||||
var sess rtmp.Session
|
var sess *rtmp.Session
|
||||||
var err error
|
var err error
|
||||||
for n := 0; n < retries; n++ {
|
for n := 0; n < retries; n++ {
|
||||||
sess = rtmp.NewSession(url, timeout)
|
sess = rtmp.NewSession(url, timeout)
|
||||||
|
|
18
rtmp/rtmp.go
18
rtmp/rtmp.go
|
@ -259,14 +259,8 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type Session interface {
|
|
||||||
Open() error
|
|
||||||
Write([]byte) (int, error)
|
|
||||||
Close() error
|
|
||||||
}
|
|
||||||
|
|
||||||
// session provides parameters required for an rtmp communication session.
|
// session provides parameters required for an rtmp communication session.
|
||||||
type session struct {
|
type Session struct {
|
||||||
rtmp *C_RTMP
|
rtmp *C_RTMP
|
||||||
url string
|
url string
|
||||||
timeout uint
|
timeout uint
|
||||||
|
@ -440,8 +434,8 @@ type P_vu struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSession returns a new session.
|
// NewSession returns a new session.
|
||||||
func NewSession(url string, connectTimeout uint) Session {
|
func NewSession(url string, connectTimeout uint) *Session {
|
||||||
return &session{
|
return &Session{
|
||||||
url: url,
|
url: url,
|
||||||
timeout: connectTimeout,
|
timeout: connectTimeout,
|
||||||
}
|
}
|
||||||
|
@ -449,7 +443,7 @@ func NewSession(url string, connectTimeout uint) Session {
|
||||||
|
|
||||||
// Open establishes an rtmp connection with the url passed into the
|
// Open establishes an rtmp connection with the url passed into the
|
||||||
// constructor
|
// constructor
|
||||||
func (s *session) Open() error {
|
func (s *Session) Open() error {
|
||||||
if s.rtmp != nil {
|
if s.rtmp != nil {
|
||||||
return errors.New("rtmp: attempt to start already running session")
|
return errors.New("rtmp: attempt to start already running session")
|
||||||
}
|
}
|
||||||
|
@ -462,7 +456,7 @@ func (s *session) Open() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close terminates the rtmp connection
|
// Close terminates the rtmp connection
|
||||||
func (s *session) Close() error {
|
func (s *Session) Close() error {
|
||||||
if s.rtmp == nil {
|
if s.rtmp == nil {
|
||||||
return Err(3)
|
return Err(3)
|
||||||
}
|
}
|
||||||
|
@ -475,7 +469,7 @@ func (s *session) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write writes a frame (flv tag) to the rtmp connection
|
// 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 {
|
if s.rtmp == nil {
|
||||||
return 0, Err(3)
|
return 0, Err(3)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue