api: decode durations from strings instead of numbers

This allows to use human-readable durations with the API,
for instance: "5s" instead of 5000000000
This commit is contained in:
aler9 2021-09-26 23:06:40 +02:00
parent 64808863ed
commit ca9645c2f9
19 changed files with 242 additions and 147 deletions

View file

@ -8,10 +8,10 @@ import (
"net"
"strconv"
"sync"
"time"
"github.com/aler9/gortsplib"
"github.com/aler9/rtsp-simple-server/internal/conf"
"github.com/aler9/rtsp-simple-server/internal/logger"
)
@ -20,8 +20,8 @@ type rtmpServerParent interface {
}
type rtmpServer struct {
readTimeout time.Duration
writeTimeout time.Duration
readTimeout conf.StringDuration
writeTimeout conf.StringDuration
readBufferCount int
rtspAddress string
runOnConnect string
@ -45,8 +45,8 @@ type rtmpServer struct {
func newRTMPServer(
parentCtx context.Context,
address string,
readTimeout time.Duration,
writeTimeout time.Duration,
readTimeout conf.StringDuration,
writeTimeout conf.StringDuration,
readBufferCount int,
rtspAddress string,
runOnConnect string,