@ -34,7 +34,7 @@ type rtspSessionParent interface {
type rtspSession struct {
type rtspSession struct {
isTLS bool
isTLS bool
protocols map [ conf . Protocol ] struct { }
protocols map [ conf . Protocol ] struct { }
ss * gortsplib . ServerSession
se ssion * gortsplib . ServerSession
author * gortsplib . ServerConn
author * gortsplib . ServerConn
externalCmdPool * externalcmd . Pool
externalCmdPool * externalcmd . Pool
pathManager rtspSessionPathManager
pathManager rtspSessionPathManager
@ -52,7 +52,7 @@ type rtspSession struct {
func newRTSPSession (
func newRTSPSession (
isTLS bool ,
isTLS bool ,
protocols map [ conf . Protocol ] struct { } ,
protocols map [ conf . Protocol ] struct { } ,
ss * gortsplib . ServerSession ,
se ssion * gortsplib . ServerSession ,
sc * gortsplib . ServerConn ,
sc * gortsplib . ServerConn ,
externalCmdPool * externalcmd . Pool ,
externalCmdPool * externalcmd . Pool ,
pathManager rtspSessionPathManager ,
pathManager rtspSessionPathManager ,
@ -61,7 +61,7 @@ func newRTSPSession(
s := & rtspSession {
s := & rtspSession {
isTLS : isTLS ,
isTLS : isTLS ,
protocols : protocols ,
protocols : protocols ,
ss : ss ,
se ssion : se ssion ,
author : sc ,
author : sc ,
externalCmdPool : externalCmdPool ,
externalCmdPool : externalCmdPool ,
pathManager : pathManager ,
pathManager : pathManager ,
@ -77,7 +77,7 @@ func newRTSPSession(
// Close closes a Session.
// Close closes a Session.
func ( s * rtspSession ) close ( ) {
func ( s * rtspSession ) close ( ) {
s . ss . Close ( )
s . se ssion . Close ( )
}
}
// isRTSPSession implements pathRTSPSession.
// isRTSPSession implements pathRTSPSession.
@ -100,7 +100,7 @@ func (s *rtspSession) log(level logger.Level, format string, args ...interface{}
// onClose is called by rtspServer.
// onClose is called by rtspServer.
func ( s * rtspSession ) onClose ( err error ) {
func ( s * rtspSession ) onClose ( err error ) {
if s . ss . State ( ) == gortsplib . ServerSessionStatePlay {
if s . se ssion . State ( ) == gortsplib . ServerSessionStatePlay {
if s . onReadCmd != nil {
if s . onReadCmd != nil {
s . onReadCmd . Close ( )
s . onReadCmd . Close ( )
s . onReadCmd = nil
s . onReadCmd = nil
@ -108,7 +108,7 @@ func (s *rtspSession) onClose(err error) {
}
}
}
}
switch s . ss . State ( ) {
switch s . se ssion . State ( ) {
case gortsplib . ServerSessionStatePrePlay , gortsplib . ServerSessionStatePlay :
case gortsplib . ServerSessionStatePrePlay , gortsplib . ServerSessionStatePlay :
s . path . readerRemove ( pathReaderRemoveReq { author : s } )
s . path . readerRemove ( pathReaderRemoveReq { author : s } )
@ -181,7 +181,7 @@ func (s *rtspSession) onSetup(c *rtspConn, ctx *gortsplib.ServerHandlerOnSetupCt
}
}
}
}
switch s . ss . State ( ) {
switch s . se ssion . State ( ) {
case gortsplib . ServerSessionStateInitial , gortsplib . ServerSessionStatePrePlay : // play
case gortsplib . ServerSessionStateInitial , gortsplib . ServerSessionStatePrePlay : // play
res := s . pathManager . readerAdd ( pathReaderAddReq {
res := s . pathManager . readerAdd ( pathReaderAddReq {
author : s ,
author : s ,
@ -247,19 +247,19 @@ func (s *rtspSession) onSetup(c *rtspConn, ctx *gortsplib.ServerHandlerOnSetupCt
func ( s * rtspSession ) onPlay ( ctx * gortsplib . ServerHandlerOnPlayCtx ) ( * base . Response , error ) {
func ( s * rtspSession ) onPlay ( ctx * gortsplib . ServerHandlerOnPlayCtx ) ( * base . Response , error ) {
h := make ( base . Header )
h := make ( base . Header )
if s . ss . State ( ) == gortsplib . ServerSessionStatePrePlay {
if s . se ssion . State ( ) == gortsplib . ServerSessionStatePrePlay {
s . path . readerStart ( pathReaderStartReq { author : s } )
s . path . readerStart ( pathReaderStartReq { author : s } )
tracks := make ( gortsplib . Tracks , len ( s . ss . SetuppedTracks ( ) ) )
tracks := make ( gortsplib . Tracks , len ( s . se ssion . SetuppedTracks ( ) ) )
n := 0
n := 0
for id := range s . ss . SetuppedTracks ( ) {
for id := range s . se ssion . SetuppedTracks ( ) {
tracks [ n ] = s . stream . tracks ( ) [ id ]
tracks [ n ] = s . stream . tracks ( ) [ id ]
n ++
n ++
}
}
s . log ( logger . Info , "is reading from path '%s', with %s, %s" ,
s . log ( logger . Info , "is reading from path '%s', with %s, %s" ,
s . path . Name ( ) ,
s . path . Name ( ) ,
s . ss . SetuppedTransport ( ) ,
s . se ssion . SetuppedTransport ( ) ,
sourceTrackInfo ( tracks ) )
sourceTrackInfo ( tracks ) )
if s . path . Conf ( ) . RunOnRead != "" {
if s . path . Conf ( ) . RunOnRead != "" {
@ -289,7 +289,7 @@ func (s *rtspSession) onPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Respo
func ( s * rtspSession ) onRecord ( ctx * gortsplib . ServerHandlerOnRecordCtx ) ( * base . Response , error ) {
func ( s * rtspSession ) onRecord ( ctx * gortsplib . ServerHandlerOnRecordCtx ) ( * base . Response , error ) {
res := s . path . publisherStart ( pathPublisherStartReq {
res := s . path . publisherStart ( pathPublisherStartReq {
author : s ,
author : s ,
tracks : s . ss . AnnouncedTracks ( ) ,
tracks : s . se ssion . AnnouncedTracks ( ) ,
generateRTPPackets : false ,
generateRTPPackets : false ,
} )
} )
if res . err != nil {
if res . err != nil {
@ -300,8 +300,8 @@ func (s *rtspSession) onRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base.R
s . log ( logger . Info , "is publishing to path '%s', with %s, %s" ,
s . log ( logger . Info , "is publishing to path '%s', with %s, %s" ,
s . path . Name ( ) ,
s . path . Name ( ) ,
s . ss . SetuppedTransport ( ) ,
s . se ssion . SetuppedTransport ( ) ,
sourceTrackInfo ( s . ss . AnnouncedTracks ( ) ) )
sourceTrackInfo ( s . se ssion . AnnouncedTracks ( ) ) )
s . stream = res . stream
s . stream = res . stream
@ -316,7 +316,7 @@ func (s *rtspSession) onRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base.R
// onPause is called by rtspServer.
// onPause is called by rtspServer.
func ( s * rtspSession ) onPause ( ctx * gortsplib . ServerHandlerOnPauseCtx ) ( * base . Response , error ) {
func ( s * rtspSession ) onPause ( ctx * gortsplib . ServerHandlerOnPauseCtx ) ( * base . Response , error ) {
switch s . ss . State ( ) {
switch s . se ssion . State ( ) {
case gortsplib . ServerSessionStatePlay :
case gortsplib . ServerSessionStatePlay :
if s . onReadCmd != nil {
if s . onReadCmd != nil {
s . log ( logger . Info , "runOnRead command stopped" )
s . log ( logger . Info , "runOnRead command stopped" )
@ -381,7 +381,7 @@ func (s *rtspSession) apiSourceDescribe() interface{} {
func ( s * rtspSession ) onPacketRTP ( ctx * gortsplib . ServerHandlerOnPacketRTPCtx ) {
func ( s * rtspSession ) onPacketRTP ( ctx * gortsplib . ServerHandlerOnPacketRTPCtx ) {
var err error
var err error
switch s . ss . AnnouncedTracks ( ) [ ctx . TrackID ] . ( type ) {
switch s . se ssion . AnnouncedTracks ( ) [ ctx . TrackID ] . ( type ) {
case * gortsplib . TrackH264 :
case * gortsplib . TrackH264 :
err = s . stream . writeData ( & dataH264 {
err = s . stream . writeData ( & dataH264 {
trackID : ctx . TrackID ,
trackID : ctx . TrackID ,