Simplifed connectStream().

This commit is contained in:
scruzin 2019-01-11 00:01:26 +10:30
parent f635be6712
commit 53bccaaaa7
1 changed files with 7 additions and 10 deletions

View File

@ -192,22 +192,19 @@ func connect(s *Session) error {
// connectStream reads a packet and handles it
func connectStream(s *Session) error {
var err error
for !s.isPlaying && s.isConnected() {
for !s.isPlaying {
pkt := packet{}
err = pkt.read(s)
if err != nil {
break
}
if pkt.bodySize == 0 {
continue
}
if pkt.packetType == RTMP_PACKET_TYPE_AUDIO ||
pkt.packetType == RTMP_PACKET_TYPE_VIDEO ||
pkt.packetType == RTMP_PACKET_TYPE_INFO {
s.log(DebugLevel, pkg+"got packet before play; ignoring")
continue
}
switch pkt.packetType {
case RTMP_PACKET_TYPE_AUDIO, RTMP_PACKET_TYPE_VIDEO, RTMP_PACKET_TYPE_INFO:
s.log(WarnLevel, pkg+"got packet before play; ignoring", "type", pkt.packetType)
default:
handlePacket(s, &pkt) // ignore errors
}
err = handlePacket(s, &pkt)
if err != nil {
break