Propagate errors from handleInvoke().

This commit is contained in:
scruzin 2019-01-10 23:48:11 +10:30
parent 058cc41356
commit f635be6712
1 changed files with 24 additions and 16 deletions

View File

@ -121,6 +121,7 @@ var (
errUnknownScheme = errors.New("rtmp: unknown scheme")
errConnected = errors.New("rtmp: already connected")
errNotConnected = errors.New("rtmp: not connected")
errNotWritable = errors.New("rtmp: connection not writable")
errHandshake = errors.New("rtmp: handshake failed")
errConnSend = errors.New("rtmp: connection send error")
errConnStream = errors.New("rtmp: connection stream error")
@ -675,27 +676,31 @@ func handleInvoke(s *Session, body []byte) error {
case av_connect:
if s.link.token != "" {
s.log(FatalLevel, pkg+"no support for link token")
}
if (s.link.protocol & RTMP_FEATURE_WRITE) != 0 {
sendReleaseStream(s)
sendFCPublish(s)
} else {
s.log(FatalLevel, pkg+"link protocol has no RTMP_FEATURE_WRITE")
}
sendCreateStream(s)
if (s.link.protocol & RTMP_FEATURE_WRITE) == 0 {
s.log(FatalLevel, pkg+"link protocol has no RTMP_FEATURE_WRITE")
return errNotWritable
}
err := sendReleaseStream(s)
if err != nil {
return err
}
err = sendFCPublish(s)
if err != nil {
return err
}
err = sendCreateStream(s)
if err != nil {
return err
}
case av_createStream:
s.streamID = int32(C_AMFProp_GetNumber(C_AMF_GetProp(&obj, "", 3)))
if s.link.protocol&RTMP_FEATURE_WRITE != 0 {
sendPublish(s)
} else {
s.log(FatalLevel, pkg+"link protocol has no RTMP_FEATURE_WRITE")
if s.link.protocol&RTMP_FEATURE_WRITE == 0 {
return errNotWritable
}
err := sendPublish(s)
if err != nil {
return err
}
case av_play, av_publish:
@ -704,7 +709,10 @@ func handleInvoke(s *Session, body []byte) error {
case av_onBWDone:
if s.checkCounter == 0 { // ToDo: why is this always zero?
sendCheckBW(s)
err := sendCheckBW(s)
if err != nil {
return err
}
}
case av_onFCUnsubscribe, av_onFCSubscribe: