8000 Merge pull request #97 from GNURub/keep_hls_m3u8_after_stream_finish · invisiblecoder99/livego@8c30a7a · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c30a7a

Browse files
authored
Merge pull request gwuhaolin#97 from GNURub/keep_hls_m3u8_after_stream_finish
Keep hls after finish stream
2 parents dbf26a7 + 40052bb commit 8c30a7a

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed

configure/liveconfig.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,34 @@ type JWT struct {
3838
Algorithm string `mapstructure:"algorithm"`
3939
}
4040
type ServerCfg struct {
41-
Level string `mapstructure:"level"`
42-
ConfigFile string `mapstructure:"config_file"`
43-
FLVDir string `mapstructure:"flv_dir"`
44-
RTMPAddr string `mapstructure:"rtmp_addr"`
45-
HTTPFLVAddr string `mapstructure:"httpflv_addr"`
46-
HLSAddr string `mapstructure:"hls_addr"`
47-
APIAddr string `mapstructure:"api_addr"`
48-
RedisAddr string `mapstructure:"redis_addr"`
49-
RedisPwd string `mapstructure:"redis_pwd"`
50-
ReadTimeout int `mapstructure:"read_timeout"`
51-
WriteTimeout int `mapstructure:"write_timeout"`
52-
GopNum int `mapstructure:"gop_num"`
53-
JWT JWT `mapstructure:"jwt"`
54-
Server []Application `mapstructure:"server"`
41+
Level string `mapstructure:"level"`
42+
ConfigFile string `mapstructure:"config_file"`
43+
FLVDir string `mapstructure:"flv_dir"`
44+
RTMPAddr string `mapstructure:"rtmp_addr"`
45+
HTTPFLVAddr string `mapstructure:"httpflv_addr"`
46+
HLSAddr string `mapstructure:"hls_addr"`
47+
HLSKeepAfterEnd bool `mapstructure:"hls_keep_after_end"`
48+
APIAddr string `mapstructure:"api_addr"`
49+
RedisAddr string `mapstructure:"redis_addr"`
50+
RedisPwd string `mapstructure:"redis_pwd"`
51+
ReadTimeout int `mapstructure:"read_timeout"`
52+
WriteTimeout int `mapstructure:"write_timeout"`
53+
GopNum int `mapstructure:"gop_num"`
54+
JWT JWT `mapstructure:"jwt"`
55+
Server Applications `mapstructure:"server"`
5556
}
5657

5758
// default config
5859
var defaultConf = ServerCfg{
59-
ConfigFile: "livego.yaml",
60-
RTMPAddr: ":1935",
61-
HTTPFLVAddr: ":7001",
62-
HLSAddr: ":7002",
63-
APIAddr: ":8090",
64-
WriteTimeout: 10,
65-
ReadTimeout: 10,
66-
GopNum: 1,
60+
ConfigFile: "livego.yaml",
61+
RTMPAddr: ":1935",
62+
HTTPFLVAddr: ":7001",
63+
HLSAddr: ":7002",
64+
HLSKeepAfterEnd: false,
65+
APIAddr: ":8090",
66+
WriteTimeout: 10,
67+
ReadTimeout: 10,
68+
GopNum: 1,
6769
Server: Applications{{
6870
Appname: "live",
6971
Live: true,

livego.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
# # API Options
1717
# api_addr: ":8090"
18-
1918
server:
2019
- appname: live
2120
live: true

protocol/hls/hls.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package hls
22

33
import (
44
"fmt"
5+
"livego/configure"
56
"net"
67
"net/http"
78
"path"
@@ -82,7 +83,7 @@ func (server *Server) checkStop() {
8283
<-time.After(5 * time.Second)
8384
for item := range server.conns.IterBuffered() {
8485
v := item.Val.(*Source)
85-
if !v.Alive() {
86+
if !v.Alive() && !configure.Config.GetBool("hls_keep_after_end") {
8687
log.Debug("check stop and remove: ", v.Info())
8788
server.conns.Remove(item.Key)
8889
}

protocol/hls/source.go

Lines changed: 2 additions & 1 deletion
< 67F4 div data-testid="neutral diffstat" class="DiffSquares-module__diffSquare--h5kjy DiffSquares-module__neutral--VlyoP">
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package hls
33
import (
44
"bytes"
55
"fmt"
6+
"livego/configure"
67
"time"
78

89
"livego/av"
@@ -180,7 +181,7 @@ func (source *Source) cleanup() {
180181

181182
func (source *Source) Close(err error) {
182183
log.Debug("hls source closed: ", source.info)
183-
if !source.closed {
184+
if !source.closed && !configure.Config.GetBool("hls_keep_after_end") {
184185
source.cleanup()
185186
}
186187
source.closed = true

0 commit comments

Comments
 (0)
0