Skip to content

Commit

Permalink
Merge pull request #322 from ixugo/dev
Browse files Browse the repository at this point in the history
[fix] hls: 修复获取record.m3u8和playlist.m3u8对应的流名称不正确的问题 #320
  • Loading branch information
q191201771 authored Oct 18, 2023
2 parents 6f2cffc + ab9a894 commit 3f10132
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/hls/server_sub_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
package hls

import (
"github.com/q191201771/lal/pkg/base"
"github.com/q191201771/naza/pkg/connection"
"github.com/q191201771/naza/pkg/nazamd5"
"net/http"
"strings"
"time"

"github.com/q191201771/lal/pkg/base"
"github.com/q191201771/naza/pkg/connection"
"github.com/q191201771/naza/pkg/nazamd5"
)

type SubSession struct {
Expand Down Expand Up @@ -121,5 +122,14 @@ func GetAppNameFromUrlCtx(urlCtx base.UrlContext, hlsUrlPattern string) string {
}

func GetStreamNameFromUrlCtx(urlCtx base.UrlContext) string {
return urlCtx.GetFilenameWithoutType()
filename := urlCtx.LastItemOfPath
filetype := urlCtx.GetFileType()
if filetype == "m3u8" && (filename == playlistM3u8FileName || filename == recordM3u8FileName) {
uriItems := strings.Split(urlCtx.Path, "/")
if l := len(uriItems); l >= 2 {
return uriItems[len(uriItems)-2]
}
}
fileNameWithoutType := urlCtx.GetFilenameWithoutType()
return fileNameWithoutType
}

0 comments on commit 3f10132

Please sign in to comment.