Skip to content

Commit

Permalink
Prevent segment index overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Thor77 committed Dec 19, 2020
1 parent 7300288 commit 35ff213
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"io"
"math"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -92,7 +93,7 @@ func publishHandler(conn *rtmp.Conn) {
return
}

i := 0
var i uint8 = 0
clientConnected := true
var lastPacketTime time.Duration = 0
for clientConnected {
Expand Down Expand Up @@ -168,7 +169,11 @@ func publishHandler(conn *rtmp.Conn) {
}

// increase segment index
i++
if i == (math.MaxUint8 - 1) {
i = 0
} else {
i++
}
}

filesToRemove := make([]string, len(playlist.Segments)+1)
Expand Down

0 comments on commit 35ff213

Please sign in to comment.