diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 791c1b93..4d432a00 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -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: