mirror of
https://github.com/datarhei/core.git
synced 2025-10-26 17:30:31 +08:00
Use better name for variable
This commit is contained in:
@@ -33,7 +33,10 @@ func (h *handler) handleHLSIngress(c echo.Context, _ string, data map[string]int
|
|||||||
req := c.Request()
|
req := c.Request()
|
||||||
path := req.URL.Path
|
path := req.URL.Path
|
||||||
|
|
||||||
if strings.HasSuffix(path, ".m3u8") {
|
isM3U8 := strings.HasSuffix(path, ".m3u8")
|
||||||
|
isSegment := strings.HasSuffix(path, ".ts") || strings.HasSuffix(path, ".mp4")
|
||||||
|
|
||||||
|
if isM3U8 {
|
||||||
// Read out the path of the .ts files and look them up in the ts-map.
|
// Read out the path of the .ts files and look them up in the ts-map.
|
||||||
// Add it as ingress for the respective "sessionId". The "sessionId" is the .m3u8 file name.
|
// Add it as ingress for the respective "sessionId". The "sessionId" is the .m3u8 file name.
|
||||||
reader := req.Body
|
reader := req.Body
|
||||||
@@ -81,7 +84,7 @@ func (h *handler) handleHLSIngress(c echo.Context, _ string, data map[string]int
|
|||||||
|
|
||||||
mem.Put(r.buffer)
|
mem.Put(r.buffer)
|
||||||
}()
|
}()
|
||||||
} else if strings.HasSuffix(path, ".ts") || strings.HasSuffix(path, ".mp4") {
|
} else if isSegment {
|
||||||
// Get the size of the .ts file and store it in the ts-map for later use.
|
// Get the size of the .ts file and store it in the ts-map for later use.
|
||||||
reader := req.Body
|
reader := req.Body
|
||||||
r := &bodysizeReader{
|
r := &bodysizeReader{
|
||||||
@@ -117,7 +120,7 @@ func (h *handler) handleHLSEgress(c echo.Context, _ string, data map[string]inte
|
|||||||
sessionID := c.QueryParam("session")
|
sessionID := c.QueryParam("session")
|
||||||
|
|
||||||
isM3U8 := strings.HasSuffix(path, ".m3u8")
|
isM3U8 := strings.HasSuffix(path, ".m3u8")
|
||||||
isTS := strings.HasSuffix(path, ".ts") || strings.HasSuffix(path, ".mp4")
|
isSegment := strings.HasSuffix(path, ".ts") || strings.HasSuffix(path, ".mp4")
|
||||||
|
|
||||||
rewrite := false
|
rewrite := false
|
||||||
|
|
||||||
@@ -213,7 +216,7 @@ func (h *handler) handleHLSEgress(c echo.Context, _ string, data map[string]inte
|
|||||||
mem.Put(rewriter.buffer)
|
mem.Put(rewriter.buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if isM3U8 || isTS {
|
if isM3U8 || isSegment {
|
||||||
if res.Status >= 200 && res.Status < 300 {
|
if res.Status >= 200 && res.Status < 300 {
|
||||||
// Collect how many bytes we've written in this session
|
// Collect how many bytes we've written in this session
|
||||||
buffer := mem.Get()
|
buffer := mem.Get()
|
||||||
@@ -221,7 +224,7 @@ func (h *handler) handleHLSEgress(c echo.Context, _ string, data map[string]inte
|
|||||||
h.hlsEgressCollector.Egress(sessionID, res.Size)
|
h.hlsEgressCollector.Egress(sessionID, res.Size)
|
||||||
mem.Put(buffer)
|
mem.Put(buffer)
|
||||||
|
|
||||||
if isTS {
|
if isSegment {
|
||||||
// Activate the session. If the session is already active, this is a noop
|
// Activate the session. If the session is already active, this is a noop
|
||||||
h.hlsEgressCollector.Activate(sessionID)
|
h.hlsEgressCollector.Activate(sessionID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ func NewWithConfig(config Config) echo.MiddlewareFunc {
|
|||||||
data["ip"] = ip
|
data["ip"] = ip
|
||||||
|
|
||||||
isM3U8 := strings.HasSuffix(path, ".m3u8")
|
isM3U8 := strings.HasSuffix(path, ".m3u8")
|
||||||
isTS := strings.HasSuffix(path, ".ts")
|
isSegment := strings.HasSuffix(path, ".ts") || strings.HasSuffix(path, ".mp4")
|
||||||
|
|
||||||
if isM3U8 || isTS {
|
if isM3U8 || isSegment {
|
||||||
return h.handleHLS(c, ctxuser, data, next)
|
return h.handleHLS(c, ctxuser, data, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user